[gxml] Fixed NS for document_element with no-prefix
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] Fixed NS for document_element with no-prefix
- Date: Mon, 23 Jan 2017 20:36:43 +0000 (UTC)
commit f5a6366aa88697e21d06f25abe17d33878dec19e
Author: Daniel Espinosa <esodan gmail com>
Date: Mon Jan 23 14:36:05 2017 -0600
Fixed NS for document_element with no-prefix
gxml/XParser.vala | 17 +++++++++++++----
test/GomDocumentTest.vala | 7 +++----
2 files changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/gxml/XParser.vala b/gxml/XParser.vala
index 7656c1c..cdddf5a 100644
--- a/gxml/XParser.vala
+++ b/gxml/XParser.vala
@@ -597,11 +597,20 @@ public class GXml.XParser : Object, GXml.Parser {
#endif
if ((node as DomElement).namespace_uri != null) {
#if DEBUG
- GLib.message ("Writting namespace definition for node");
+ GLib.message ("Writting namespace definition for node");
#endif
- tw.start_element_ns ((node as DomElement).prefix,
- (node as DomElement).local_name,
- (node as DomElement).namespace_uri);
+ string lpns = (node.parent_node).lookup_prefix ((node as DomElement).namespace_uri);
+ if (lpns == (node as DomElement).prefix
+ && (node as DomElement).prefix != null) {
+ tw.start_element (node.node_name);
+#if DEBUG
+ message ("Setting null NS URI for element: "+(node as DomElement).local_name);
+#endif
+ }
+ else
+ tw.start_element_ns ((node as DomElement).prefix,
+ (node as DomElement).local_name,
+ (node as DomElement).namespace_uri);
} else
tw.start_element ((node as DomElement).local_name);
#if DEBUG
diff --git a/test/GomDocumentTest.vala b/test/GomDocumentTest.vala
index 2a2ac8d..64b429a 100644
--- a/test/GomDocumentTest.vala
+++ b/test/GomDocumentTest.vala
@@ -167,9 +167,8 @@ class GomDocumentTest : GXmlTest {
assert ("<shortdesc xml:lang=\"en\">GObject XML and Serialization
API</shortdesc>"
in s);
assert ("<homepage rdf:resource=\"https://wiki.gnome.org/GXml\"/>" in s);
- assert ("<foaf:Person" in s);
- assert ("<foaf:name " in s);
- assert ("Daniel Espinosa</foaf:name>"in s);
+ assert ("<foaf:Person>" in s);
+ assert ("<foaf:name>Daniel Espinosa</foaf:name>" in s);
} catch (GLib.Error e) {
GLib.message ("Error: "+e.message);
assert_not_reached ();
@@ -184,7 +183,7 @@ class GomDocumentTest : GXmlTest {
assert (r.namespace_uri == "http://live.gnome.org/GXml");
var parser = new XParser (doc);
string s = parser.write_string ();
- GLib.message (@"DOC: "+s);
+ Test.message (@"DOC: "+s);
assert ("<root xmlns=\"http://live.gnome.org/GXml\"/>" in s);
doc.document_element.set_attribute_ns ("http://www.w3.org/2000/xmlns/",
"xmlns",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]