[gxml] xml name space should use default URI



commit a23b182c4757eea3b8500808564d003a0196321e
Author: Daniel Espinosa <esodan gmail com>
Date:   Tue Feb 25 13:52:00 2020 -0600

    xml name space should use default URI
    
    Any prefix using xml should be bound to http://www.w3.org/XML/1998/namespace
    according with specification 1.1 part 3.

 gxml/Element.vala      | 4 ++--
 gxml/XParser.vala      | 2 ++
 test/DocumentTest.vala | 3 +++
 3 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/gxml/Element.vala b/gxml/Element.vala
index 71d2d75..be15490 100644
--- a/gxml/Element.vala
+++ b/gxml/Element.vala
@@ -653,8 +653,8 @@ public class GXml.Element : GXml.Node,
     if (namespace_uri == null && p == "") {
        throw new DomError.NAMESPACE_ERROR (_("Invalid namespace. If prefix is null, namespace URI should not 
be null"));
     }
-    if (p == "xml" && namespace_uri != "http://www.w3.org/2000/xmlns/"; && namespace_uri != 
"http://www.w3.org/2000/xmlns";) {
-       throw new DomError.NAMESPACE_ERROR (_("Invalid namespace. If prefix is xml, namespace URI should be 
http://www.w3.org/2000/xmlns";));
+    if (p == "xml" && namespace_uri != "http://www.w3.org/XML/1998/namespace/"; && namespace_uri != 
"http://www.w3.org/XML/1998/namespace";) {
+       throw new DomError.NAMESPACE_ERROR (_("Invalid namespace. If prefix is xml, namespace URI should be 
http://www.w3.org/XML/1998/namespace";));
     }
     if (p == "xmlns" && namespace_uri != "http://www.w3.org/2000/xmlns/";
             && namespace_uri != "http://www.w3.org/2000/xmlns";) {
diff --git a/gxml/XParser.vala b/gxml/XParser.vala
index a52ceaf..abfc402 100644
--- a/gxml/XParser.vala
+++ b/gxml/XParser.vala
@@ -358,6 +358,8 @@ public class GXml.XParser : GLib.Object, GXml.Parser {
             string nsuri = null;
             if (prefix == "xmlns")
               nsuri = "http://www.w3.org/2000/xmlns/";;
+            if (prefix == "xml")
+              nsuri = "http://www.w3.org/XML/1998/namespace/";;
             else if (prefix == "xsi")
               nsuri = "http://www.w3.org/2001/XMLSchema-instance/";;
             else
diff --git a/test/DocumentTest.vala b/test/DocumentTest.vala
index 605cd55..95d336e 100644
--- a/test/DocumentTest.vala
+++ b/test/DocumentTest.vala
@@ -157,6 +157,9 @@ class GXml.DocumentTest : GXmlTest {
                                        GLib.message ("No remote file available. Skipping...");
                                        return;
                                }
+                               var m = new GLib.MemoryOutputStream.resizable ();
+                               m.splice (rf.read (), GLib.OutputStreamSpliceFlags.CLOSE_SOURCE, null);
+                               message ("File Contents:\n%s", (string)m.data);
                                var d = new GXml.Document.from_file (rf);
                                assert (d != null);
                                assert (d.document_element != null);


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