[gxml] XParser: error reading provides line number



commit 62d1bfd1da433bdd827c6a853111af4a22d77c2f
Author: Daniel Espinosa <esodan gmail com>
Date:   Wed Aug 18 18:25:46 2021 -0500

    XParser: error reading provides line number

 gxml/XParser.vala      |  4 ++--
 test/DocumentTest.vala | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/gxml/XParser.vala b/gxml/XParser.vala
index ba5c0d1b..08b312f0 100644
--- a/gxml/XParser.vala
+++ b/gxml/XParser.vala
@@ -268,7 +268,7 @@ public class GXml.XParser : GLib.Object, GXml.Parser {
       throw new ParserError.INVALID_DATA_ERROR (_("Internal Error: No TextReader was set"));
     int res = tr.read ();
     if (res == -1)
-      throw new ParserError.INVALID_DATA_ERROR (_("Can't read node data"));
+      throw new ParserError.INVALID_DATA_ERROR (_("Can't read node data at line: %d"), 
tr.get_parser_line_number ());
     if (res == 0) {
       return false;
     }
@@ -332,7 +332,7 @@ public class GXml.XParser : GLib.Object, GXml.Parser {
     for (int i = 0; i < nattr; i++) {
       var c = tr.move_to_attribute_no (i);
       if (c != 1) {
-        throw new DomError.HIERARCHY_REQUEST_ERROR (_("Parsing ERROR: Fail to move to attribute number: 
%i").printf (i));
+        throw new DomError.HIERARCHY_REQUEST_ERROR (_("Parsing ERROR: Fail to move to attribute number: %i 
at line: %d"), i, tr.get_parser_line_number ());
       }
       if (tr.is_namespace_decl () == 1) {
         string nsp = tr.const_local_name ();
diff --git a/test/DocumentTest.vala b/test/DocumentTest.vala
index 9008677a..a8de25bb 100644
--- a/test/DocumentTest.vala
+++ b/test/DocumentTest.vala
@@ -752,6 +752,25 @@ class DocumentTest : GLib.Object {
                    assert_not_reached ();
                  }
                });
+               Test.add_func ("/gxml/document/doc-type/read/html", () => {
+                       try {
+                               var d = new GXml.Document.from_string ("<!DOCTYPE html><html/>");
+                               message (d.write_string ());
+                               message (d.child_nodes.length.to_string ());
+                               assert (d.child_nodes.length == 2);
+                               var dt1 = d.child_nodes[0] as DomDocumentType;
+                               assert (dt1 != null);
+                               assert (dt1 is DomDocumentType);
+                               assert (dt1.node_type == DomNode.NodeType.DOCUMENT_TYPE_NODE);
+                               assert (dt1.node_name == "!DOCTYPE");
+                               assert (dt1.name == "html");
+                               assert (dt1.public_id == null);
+                               assert (dt1.system_id == null);
+                       } catch (GLib.Error e) {
+                   GLib.message ("Error: "+e.message);
+                   assert_not_reached ();
+                 }
+               });
                Test.add_func ("/gxml/gom-document/element-id", () => {
                        try {
                                var d = new GXml.Document.from_string ("""<root><child id="id1"/><child 
id="id2"/></root>""") as DomDocument;


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