[libgsf] xml: provide a way to shut up complaints about unknown tags.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgsf] xml: provide a way to shut up complaints about unknown tags.
- Date: Sat, 14 Mar 2015 01:34:42 +0000 (UTC)
commit f66c8fb1e3fa18885779e44e85e45c455312b59b
Author: Morten Welinder <terra gnome org>
Date: Fri Mar 13 21:33:34 2015 -0400
xml: provide a way to shut up complaints about unknown tags.
xlsx has <extLst> which, by definition, contains extensions to the
format we cannot known about in advance.
ChangeLog | 4 ++++
NEWS | 1 +
gsf/gsf-libxml.c | 22 +++++++++++++++++++++-
gsf/gsf-libxml.h | 1 +
4 files changed, 27 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3d43a1e..5cedf27 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-03-13 Morten Welinder <terra gnome org>
+
+ * gsf/gsf-libxml.c (gsf_xml_in_set_silent_unknowns): New function.
+
2015-03-04 Morten Welinder <terra gnome org>
* gsf/gsf-libxml.c (gsf_xml_out_add_float): Do a better job of
diff --git a/NEWS b/NEWS
index 3bd40a7..1a15e3d 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ libgsf 1.14.33
Morten:
* Ensure floats roundtrip through our xml functions.
+ * Improve handling of unknown xml tags.
--------------------------------------------------------------------------
libgsf 1.14.32
diff --git a/gsf/gsf-libxml.c b/gsf/gsf-libxml.c
index 7097fa9..e5365ab 100644
--- a/gsf/gsf-libxml.c
+++ b/gsf/gsf-libxml.c
@@ -591,6 +591,7 @@ typedef struct {
gint unknown_depth; /* handle recursive unknown tags */
gboolean from_unknown_handler;
gboolean debug_parsing;
+ gboolean silent_unknowns;
GSList *extension_stack; /* stack of GsfXMLInExtension */
} GsfXMLInInternal;
@@ -725,7 +726,7 @@ gsf_xml_in_start_element (GsfXMLInInternal *state, xmlChar const *name, xmlChar
GSList *ptr;
char const *tmp;
int i;
- gboolean complain = TRUE;
+ gboolean complain = !state->silent_unknowns;
/* Scan for namespace declarations. Yes it is ugly to have the api
* flag that its children can declare namespaces. However, given that a
@@ -957,6 +958,7 @@ gsf_xml_in_start_document (GsfXMLInInternal *state)
state->contents_stack = NULL;
state->from_unknown_handler = FALSE;
state->debug_parsing = gsf_debug_flag ("xml-parsing");
+ state->silent_unknowns = FALSE;
}
static void
@@ -1361,6 +1363,24 @@ gsf_xml_in_get_input (GsfXMLIn const *xin)
}
/**
+ * gsf_xml_in_set_silent_unknowns:
+ * @xin: #GsfXMLIn
+ * @silent: whether to be silent about unknown tags
+ *
+ * (New in 1.14.33)
+ *
+ * This provides a means to silently ignore unknown tags in contexts where
+ * they are expected.
+ **/
+void
+gsf_xml_in_set_silent_unknowns (GsfXMLIn *xin, gboolean silent)
+{
+ GsfXMLInInternal *state = (GsfXMLInInternal *)xin;
+ state->silent_unknowns = silent;
+}
+
+
+/**
* gsf_xml_in_check_ns:
* @xin: #GsfXMLIn
* @str: string to check
diff --git a/gsf/gsf-libxml.h b/gsf/gsf-libxml.h
index bfe2812..9686716 100644
--- a/gsf/gsf-libxml.h
+++ b/gsf/gsf-libxml.h
@@ -143,6 +143,7 @@ char const *gsf_xml_in_check_ns (GsfXMLIn const *xin, char const *str,
unsigned int ns_id);
gboolean gsf_xml_in_namecmp (GsfXMLIn const *xin, char const *str,
unsigned int ns_id, char const *name);
+void gsf_xml_in_set_silent_unknowns (GsfXMLIn *xin, gboolean silent);
GType gsf_xml_in_ns_get_type (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]