From: Jim Evins Date: Tue, 25 Mar 2008 01:36:12 +0000 (+0000) Subject: 2008-03-24 Jim Evins X-Git-Tag: glabels-2_2_5~30 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=77e287c50a70b8f21c1f6168e109ede934eeea15;p=glabels 2008-03-24 Jim Evins * src/xml-label.c: (xml_doc_to_label): Bug #1872584. Don't refuse to parse label file if namespace is unrecognized -- it may be from a newer version of glabels. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/branches/glabels-2_2@764 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index e0e34033..a27e0e7f 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,9 @@ +2008-03-24 Jim Evins + + * src/xml-label.c: (xml_doc_to_label): + Bug #1872584. Don't refuse to parse label file if namespace is + unrecognized -- it may be from a newer version of glabels. + 2008-03-15 Jim Evins * data/templates/Makefile.am: diff --git a/glabels2/src/xml-label.c b/glabels2/src/xml-label.c index 39729a51..0f8e104c 100644 --- a/glabels2/src/xml-label.c +++ b/glabels2/src/xml-label.c @@ -249,7 +249,6 @@ xml_doc_to_label (xmlDocPtr doc, glXMLLabelStatus *status) { xmlNodePtr root; - xmlNsPtr ns; glLabel *label; gl_debug (DEBUG_XML, "START"); @@ -265,36 +264,36 @@ xml_doc_to_label (xmlDocPtr doc, return NULL; } - ns = xmlSearchNsByHref (doc, root, (xmlChar *)LGL_XML_NAME_SPACE); - if (ns == NULL) { - /* Try compatability mode 2.0 */ - ns = xmlSearchNsByHref (doc, root, (xmlChar *)COMPAT20_NAME_SPACE); + /* Try compatability mode 0.1 */ + if (xmlSearchNsByHref (doc, root, (xmlChar *)COMPAT01_NAME_SPACE)) + { + g_message (_("Importing from glabels 0.1 format")); + g_message ("TODO"); + label = NULL; /* TODO */ + return label; + } + + /* Try compatability mode 0.4 */ + if (xmlSearchNsByHref (doc, root, (xmlChar *)COMPAT04_NAME_SPACE)) + { + g_message (_("Importing from glabels 0.4 format")); + label = gl_xml_label_04_parse (root, status); + return label; + } + + /* Test for current namespaces. */ + if ( !xmlSearchNsByHref (doc, root, (xmlChar *)COMPAT20_NAME_SPACE) && + !xmlSearchNsByHref (doc, root, (xmlChar *)LGL_XML_NAME_SPACE) ) + { + g_message (_("Unknown glabels Namespace -- Using %s"), + LGL_XML_NAME_SPACE); + } + + label = xml_parse_label (root, status); + if (label) + { + gl_label_set_compression (label, xmlGetDocCompressMode (doc)); } - if (ns != NULL) { - label = xml_parse_label (root, status); - if (label) - gl_label_set_compression (label, xmlGetDocCompressMode (doc)); - } else { - /* Try compatability mode 0.1 */ - ns = xmlSearchNsByHref (doc, root, (xmlChar *)COMPAT01_NAME_SPACE); - if (ns != NULL) { - g_message (_("Importing from glabels 0.1 format")); - g_message ("TODO"); - label = NULL; /* TODO */ - } else { - /* Try compatability mode 0.4 */ - ns = xmlSearchNsByHref (doc, root, - (xmlChar *)COMPAT04_NAME_SPACE); - if (ns != NULL) { - g_message (_("Importing from glabels 0.4 format")); - label = gl_xml_label_04_parse (root, status); - } else { - g_message (_("bad document, unknown glabels Namespace")); - *status = XML_LABEL_ERROR_OPEN_PARSE; - return NULL; - } - } - } gl_debug (DEBUG_XML, "END");