Commit 3fece86d authored by Morten Welinder's avatar Morten Welinder

xml: fix various dtd version problems.

The last few versions didn't seem to have made it into all the
right places.
parent 550ce6c3
2015-03-02 Morten Welinder <terra@gnome.org>
* src/xml-io-version.h (GnumericXMLVersion): Add new dtd version.
* src/xml-sax-read.c (xml_sax_wb): Bring dtd list up to date.
(xml_sax_version): Bring version list up to date.
2015-03-01 Morten Welinder <terra@gnome.org>
* src/sheet-object-widget.c
......
......@@ -31,6 +31,7 @@ Morten:
* Fix problem reading images from xls.
* Namespace fixes
* Test suite improvements.
* Fix various dtd version problems.
--------------------------------------------------------------------------
Gnumeric 1.12.20
......
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:gnm="http://www.gnumeric.org/v10.dtd"
xmlns:gnm="http://www.gnumeric.org/v14.dtd"
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
targetNamespace="http://www.gnumeric.org/v10.dtd"
targetNamespace="http://www.gnumeric.org/v14.dtd"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
......@@ -20,6 +20,7 @@
updated for 1.7.91 in Nov 2007 jody@gnome.org
partially updated for 1.10.17 in July 2011 aguelzow@pyrshep.ca
partially updated for 1.12.13 in March 2014 terra@gnome.org
updated for 1.12.21 in Feb 2015 terra@gnome.org
</xs:documentation>
</xs:annotation>
......
......@@ -20,9 +20,10 @@ typedef enum
GNM_XML_V11, /* >= 1.7.0 jump to sax exporter */
GNM_XML_V12, /* >= 1.7.3 Fix swapping of Value and ValueType in sax exporter */
GNM_XML_V13, /* >= 1.7.7 Deprecate ObjectAnchorType */
GNM_XML_V14, /* >= 1.12.21 Various */
/* NOTE : Keep this up to date (and in sync with the schema) */
GNM_XML_LATEST = GNM_XML_V13
GNM_XML_LATEST = GNM_XML_V14
} GnumericXMLVersion;
G_END_DECLS
......
......@@ -82,6 +82,9 @@
#include <string.h>
#include <errno.h>
/* libgsf defines OO_NS_OFFICE to be 0, so we need to take something different for GNM */
#define GNM 100
static void
xml_sax_barf (const char *locus, const char *reason)
{
......@@ -139,7 +142,7 @@ gnm_xml_attr_double (xmlChar const * const *attrs, char const *name, double * re
g_return_val_if_fail (attrs[0] != NULL, FALSE);
g_return_val_if_fail (attrs[1] != NULL, FALSE);
if (strcmp (CXML2C (attrs[0]), name))
if (!attr_eq (attrs[0], name))
return FALSE;
tmp = go_strtod (CXML2C (attrs[1]), &end);
......@@ -167,10 +170,10 @@ gnm_xml_attr_bool (xmlChar const * const *attrs, char const *name, gboolean *res
g_return_val_if_fail (attrs[0] != NULL, FALSE);
g_return_val_if_fail (attrs[1] != NULL, FALSE);
if (strcmp (CXML2C (attrs[0]), name))
if (!attr_eq (attrs[0], name))
return FALSE;
*res = g_ascii_strcasecmp (CXML2C (attrs[1]), "false") && !attr_eq (attrs[1], "0");
*res = g_ascii_strcasecmp (CXML2C (attrs[1]), "false") && strcmp (CXML2C (attrs[1]), "0");
return TRUE;
}
......@@ -185,7 +188,7 @@ gnm_xml_attr_int (xmlChar const * const *attrs, char const *name, int *res)
g_return_val_if_fail (attrs[0] != NULL, FALSE);
g_return_val_if_fail (attrs[1] != NULL, FALSE);
if (strcmp (CXML2C (attrs[0]), name))
if (!attr_eq (attrs[0], name))
return FALSE;
errno = 0;
......@@ -215,7 +218,7 @@ xml_sax_attr_enum (xmlChar const * const *attrs,
g_return_val_if_fail (attrs[0] != NULL, FALSE);
g_return_val_if_fail (attrs[1] != NULL, FALSE);
if (strcmp (CXML2C (attrs[0]), name))
if (!attr_eq (attrs[0], name))
return FALSE;
eclass = G_ENUM_CLASS (g_type_class_ref (etype));
......@@ -240,7 +243,7 @@ xml_sax_attr_cellpos (xmlChar const * const *attrs, char const *name, GnmCellPos
g_return_val_if_fail (attrs[0] != NULL, FALSE);
g_return_val_if_fail (attrs[1] != NULL, FALSE);
if (strcmp (CXML2C (attrs[0]), name))
if (!attr_eq (attrs[0], name))
return FALSE;
if (cellpos_parse (CXML2C (attrs[1]), gnm_sheet_get_size (sheet), val, TRUE) == NULL) {
......@@ -260,7 +263,7 @@ xml_sax_attr_color (xmlChar const * const *attrs, char const *name, GnmColor **r
g_return_val_if_fail (attrs[0] != NULL, FALSE);
g_return_val_if_fail (attrs[1] != NULL, FALSE);
if (strcmp (CXML2C (attrs[0]), name))
if (!attr_eq (attrs[0], name))
return FALSE;
if (sscanf (CXML2C (attrs[1]), "%X:%X:%X:%X", &red, &green, &blue, &alpha) < 3){
......@@ -461,13 +464,22 @@ xml_sax_wb (GsfXMLIn *xin, xmlChar const **attrs)
{
XMLSaxParseState *state = (XMLSaxParseState *)xin->user_state;
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
/*
* NOTE: If we read a file with a dtd that is newer, i.e., from the
* future, then we will not get here! For that reason we also muck
* with ->version in xml_sax_version.
*/
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2) {
if (strcmp (CXML2C (attrs[0]), "xmlns:gmr") == 0 ||
strcmp (CXML2C (attrs[0]), "xmlns:gnm") == 0) {
static struct {
char const * const id;
GnumericXMLVersion const version;
} const GnumericVersions [] = {
{ "http://www.gnumeric.org/v14.dtd", GNM_XML_V14 }, /* 1.12.21 */
{ "http://www.gnumeric.org/v13.dtd", GNM_XML_V13 }, /* 1.7.7 */
{ "http://www.gnumeric.org/v12.dtd", GNM_XML_V12 }, /* 1.7.3 */
{ "http://www.gnumeric.org/v11.dtd", GNM_XML_V11 }, /* 1.7.0 */
{ "http://www.gnumeric.org/v10.dtd", GNM_XML_V10 }, /* 1.0.3 */
{ "http://www.gnumeric.org/v9.dtd", GNM_XML_V9 }, /* 0.73 */
{ "http://www.gnumeric.org/v8.dtd", GNM_XML_V8 }, /* 0.71 */
......@@ -482,7 +494,7 @@ xml_sax_wb (GsfXMLIn *xin, xmlChar const **attrs)
};
int i;
for (i = 0 ; GnumericVersions [i].id != NULL ; ++i )
if (attr_eq (attrs[1], GnumericVersions [i].id)) {
if (strcmp (CXML2C (attrs[1]), GnumericVersions [i].id) == 0) {
if (state->version != GNM_XML_UNKNOWN)
go_io_warning (state->context,
_("Multiple version specifications. Assuming %d"),
......@@ -496,6 +508,7 @@ xml_sax_wb (GsfXMLIn *xin, xmlChar const **attrs)
} else if (attr_eq (attrs[0], "xsi:schemaLocation")) {
} else
unknown_attr (xin, attrs);
}
}
static void
......@@ -518,16 +531,22 @@ xml_sax_version (GsfXMLIn *xin, xmlChar const **attrs)
int version;
state->version = GNM_XML_V11;
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
if (gnm_xml_attr_int (attrs, "Epoch", &major)) ;
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2) {
if (gnm_xml_attr_int (attrs, "Epoch", &epoch))
/* Nothing */ ;
else if (gnm_xml_attr_int (attrs, "Major", &major))
/* Nothing */ ;
else if (gnm_xml_attr_int (attrs, "Minor", &minor))
/* Nothing */ ;
}
version = (epoch * 100 + major) * 100 + minor;
if (major >= 7) {
if (version >= 10705)
if (state->version == GNM_XML_UNKNOWN && version >= 10700) {
if (version >= 11221)
state->version = GNM_XML_V14;
else if (version >= 10707)
state->version = GNM_XML_V13;
else if (version >= 10705)
state->version = GNM_XML_V12;
else if (version >= 10700)
state->version = GNM_XML_V11;
......@@ -986,7 +1005,7 @@ xml_sax_print_scale (GsfXMLIn *xin, xmlChar const **attrs)
pi = state->sheet->print_info;
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2) {
if (attr_eq (attrs[0], "type"))
pi->scaling.type = attr_eq (attrs[1], "percentage")
pi->scaling.type = !strcmp (CXML2C (attrs[1]), "percentage")
? PRINT_SCALE_PERCENTAGE : PRINT_SCALE_FIT_PAGES;
else if (gnm_xml_attr_double (attrs, "percentage", &percentage))
pi->scaling.percentage.x = pi->scaling.percentage.y = percentage;
......@@ -2933,10 +2952,10 @@ xml_sax_go_doc (GsfXMLIn *xin, xmlChar const **attrs)
/****************************************************************************/
/* libgsf defines OO_NS_OFFICE to be 0, so we need to take something different for GNM */
#define GNM 100
static GsfXMLInNS const content_ns[] = {
GSF_XML_IN_NS (GNM, "http://www.gnumeric.org/v13.dtd"),
GSF_XML_IN_NS (GNM, "http://www.gnumeric.org/v12.dtd"),
GSF_XML_IN_NS (GNM, "http://www.gnumeric.org/v11.dtd"),
GSF_XML_IN_NS (GNM, "http://www.gnumeric.org/v10.dtd"),
GSF_XML_IN_NS (GNM, "http://www.gnumeric.org/v9.dtd"),
GSF_XML_IN_NS (GNM, "http://www.gnumeric.org/v8.dtd"),
......
......@@ -1467,7 +1467,7 @@ gnm_xml_file_save_full (G_GNUC_UNUSED GOFileSaver const *fs,
/* backwards compat, must be first */
gsf_xml_out_add_cstr_unchecked (state.output, "xmlns:gnm",
"http://www.gnumeric.org/v10.dtd");
"http://www.gnumeric.org/v14.dtd");
#if 0 /* seems to break meta data */
/* default namespace added for 1.8 */
gsf_xml_out_add_cstr_unchecked (state.output, "xmlns",
......
......@@ -9,5 +9,5 @@ use GnumericTest;
my $mode = ((shift @ARGV) || "check");
&message ("Check the sc importer.");
&test_importer ("$samples/sc/demo_func", "7faf9490256f2a7ba227bc18bb3e194cd9687eae", $mode);
&test_importer ("$samples/sc/demo_math", "0ad0351b6578e4dd49a46b06528e22d3879fcc2a", $mode);
&test_importer ("$samples/sc/demo_func", "39986c5c21cf60988221a6fa24ab482ee1606625", $mode);
&test_importer ("$samples/sc/demo_math", "fc220c4c3305228ec31e63b3528b788915889d71", $mode);
......@@ -9,4 +9,4 @@ use GnumericTest;
my $mode = ((shift @ARGV) || "check");
&message ("Check the Quattro Pro importer.");
&test_importer ("$samples/qpro/gantt.wb3", "9312bf7ad1f188a44ab805cfc09e7c0ecdd245ca", $mode);
&test_importer ("$samples/qpro/gantt.wb3", "8e8e88b72bfe729b9a82e975c2d1307406290a5c", $mode);
......@@ -9,4 +9,4 @@ use GnumericTest;
my $mode = ((shift @ARGV) || "check");
&message ("Check the applix importer.");
&test_importer ("$samples/applix/sample.as", "2a2011ca78ccf3169ef2941499f12ea589fbbd3a", $mode);
&test_importer ("$samples/applix/sample.as", "e9f0b742225fe77c6c3dab4064573e555670be84", $mode);
......@@ -9,6 +9,6 @@ use GnumericTest;
my $mode = ((shift @ARGV) || "check");
&message ("Check the sylk importer.");
&test_importer ("$samples/sylk/test.sylk", "d213d55662f13d743b3aeaa12943f97b9b75675a", $mode);
&test_importer ("$samples/sylk/encoding.sylk", "fb374a088a958e962119d65333f16744642223dd", $mode);
&test_importer ("$samples/sylk/app_b2.sylk", "b92205dce72d8b971e9f2213d9b91aa17516b42a", $mode);
&test_importer ("$samples/sylk/test.sylk", "f508b9a13f48f46fb01250acb0f9ddbc94ad918f", $mode);
&test_importer ("$samples/sylk/encoding.sylk", "bb9b8c232401e9993766bb995216b998b50fd6d5", $mode);
&test_importer ("$samples/sylk/app_b2.sylk", "3b559baea7373de85f9d6d4c633e46b052bd8598", $mode);
......@@ -9,5 +9,5 @@ use GnumericTest;
my $mode = ((shift @ARGV) || "check");
&message ("Check the mps importer.");
&test_importer ("$samples/solver/blend.mps", "d2965c64019585e2a74a0f2db1bbde4d04feaf30", $mode);
&test_importer ("$samples/solver/afiro.mps", "5ca8608a2a8eafb541d7117fc14624f742a3d955", $mode);
&test_importer ("$samples/solver/blend.mps", "62f3d23b545b8a40e4891cd8f645167a71cd387d", $mode);
&test_importer ("$samples/solver/afiro.mps", "e07455f4fcfba514b29aa43c550556f48fd19fe1", $mode);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment