[libgsf] xls: introduce new flag GSF_XML_2ND



commit 10c316f0d569d3fb57530b75ff59e4e06836b67f
Author: Morten Welinder <terra gnome org>
Date:   Mon Mar 30 10:33:49 2015 -0400

    xls: introduce new flag GSF_XML_2ND
    
    This explicitly identifies duplicate nodes for re-using a subtree.
    The new flag allows us to check that this feature is used right.

 ChangeLog        |    5 +++++
 NEWS             |    1 +
 gsf/gsf-libxml.c |   30 ++++++++++++++++++++++--------
 gsf/gsf-libxml.h |    3 ++-
 4 files changed, 30 insertions(+), 9 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5cedf27..bab795f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-03-30  Morten Welinder  <terra gnome org>
+
+       * gsf/gsf-libxml.c (gsf_xml_in_doc_add_nodes): Introduce new flag
+       GSF_XML_2ND to explicitly identify duplicate nodes.
+
 2015-03-13  Morten Welinder  <terra gnome org>
 
        * gsf/gsf-libxml.c (gsf_xml_in_set_silent_unknowns): New function.
diff --git a/NEWS b/NEWS
index 1a15e3d..aa21a8b 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ libgsf 1.14.33
 Morten:
        * Ensure floats roundtrip through our xml functions.
        * Improve handling of unknown xml tags.
+       * xml parser improvements.
 
 --------------------------------------------------------------------------
 libgsf 1.14.32
diff --git a/gsf/gsf-libxml.c b/gsf/gsf-libxml.c
index e5365ab..a17cd93 100644
--- a/gsf/gsf-libxml.c
+++ b/gsf/gsf-libxml.c
@@ -1182,23 +1182,37 @@ gsf_xml_in_doc_add_nodes (GsfXMLInDoc *doc,
                          GsfXMLInNode const *nodes)
 {
        GsfXMLInNode const *e_node;
-       GsfXMLInNodeInternal *tmp, *node;
 
        g_return_if_fail (doc != NULL);
        g_return_if_fail (nodes != NULL);
 
        for (e_node = nodes; e_node->id != NULL ; e_node++ ) {
-               node = g_hash_table_lookup (doc->symbols, e_node->id);
+               GsfXMLInNodeInternal *tmp, *node =
+                       g_hash_table_lookup (doc->symbols, e_node->id);
                if (node != NULL) {
-                       /* if its empty then this is just a recusion */
-                       if (e_node->start != NULL || e_node->end != NULL ||
-                           e_node->has_content != GSF_XML_NO_CONTENT ||
-                           e_node->user_data.v_int != 0) {
-                               g_warning ("ID '%s' has already been registered.\n"
-                                          "The additional decls should not specify start,end,content,data", 
e_node->id);
+                       /*
+                        * We use the repeat of a node name to attach an
+                        * entire subtree in another place too.  The second
+                        * node should either be empty (old method) or
+                        * use GSF_XML_2ND (new, as-of 1.14.33).
+                        */
+                       if (e_node->has_content == GSF_XML_2ND) {
+                               /* Nothing, but e_node contents ignored. */
+                       } else if (e_node->start != NULL || e_node->end != NULL ||
+                                e_node->has_content != GSF_XML_NO_CONTENT ||
+                                e_node->user_data.v_int != 0) {
+                               g_warning ("ID '%s' has already been registered.",
+                                       e_node->id);
                                continue;
                        }
                } else {
+                       if (e_node->has_content == GSF_XML_2ND) {
+                               g_warning ("ID '%s' is declared 2nd, but is missing.",
+                                       e_node->id);
+                               /* Hence e_node contents ignored. */
+                               continue;
+                       }                       
+
                        node = g_new0 (GsfXMLInNodeInternal, 1);
                        node->pub = *e_node;
                        /* WARNING VILE HACK :
diff --git a/gsf/gsf-libxml.h b/gsf/gsf-libxml.h
index 9686716..5e736bd 100644
--- a/gsf/gsf-libxml.h
+++ b/gsf/gsf-libxml.h
@@ -65,7 +65,8 @@ gboolean gsf_xml_probe (GsfInput *input,
 typedef enum {
        GSF_XML_NO_CONTENT = FALSE,
        GSF_XML_CONTENT,
-       GSF_XML_SHARED_CONTENT
+       GSF_XML_SHARED_CONTENT,
+       GSF_XML_2ND                 /* Second definition */
 } GsfXMLContent;
 typedef gboolean (*GsfXMLInUnknownFunc) (GsfXMLIn *xin,
                                         xmlChar const *elem, xmlChar const **attrs);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]