From 0bd0009193b9e28d4ddf96028399f038996d15d5 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Tue, 25 Mar 2008 01:32:29 +0000 Subject: [PATCH] 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/trunk@763 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/ChangeLog | 6 ++++ glabels2/src/xml-label.c | 59 ++++++++++++++++++++-------------------- 2 files changed, 35 insertions(+), 30 deletions(-) diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index 986bbfb4..407b4272 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"); -- 2.39.5