[xml] GetLineNumber and GetColumnNumber functions for xmlReader



The attached patch adds GetLineNumber and GetColumnNumber functions for
xmlReader
(similar to ones found in SAX2). Please let me know if you think it is
OK to check it in.

Thanks,
Aleksey


Index: xmlreader.c
===================================================================
RCS file: /cvs/gnome/gnome-xml/xmlreader.c,v
retrieving revision 1.112
diff -u -r1.112 xmlreader.c
--- xmlreader.c 24 Nov 2004 12:39:00 -0000      1.112
+++ xmlreader.c 3 Jan 2005 19:05:19 -0000
@@ -3570,6 +3570,40 @@
 }
 
 /**
+ * xmlTextReaderGetLineNumber:
+ * @ctx: the user data (XML reader context)
+ *
+ * Provide the line number of the current parsing point.
+ *
+ * Returns an int
+ */
+int
+xmlTextReaderGetLineNumber(xmlTextReaderPtr reader)
+{
+    if ((reader == NULL) || (reader->ctxt == NULL) || (reader->ctxt->input == NULL)) {
+        return(0);
+    }
+    return(reader->ctxt->input->line);
+}
+
+/**
+ * xmlTextReaderGetColumnNumber:
+ * @ctx: the user data (XML reader context)
+ *
+ * Provide the column number of the current parsing point.
+ *
+ * Returns an int
+ */
+int
+xmlTextReaderGetColumnNumber(xmlTextReaderPtr reader)
+{
+    if ((reader == NULL) || (reader->ctxt == NULL) || (reader->ctxt->input == NULL)) {
+        return(0);
+    }
+    return(reader->ctxt->input->col);
+}
+
+/**
  * xmlTextReaderCurrentNode:
  * @reader:  the xmlTextReaderPtr used
  *
Index: include/libxml/xmlreader.h
===================================================================
RCS file: /cvs/gnome/gnome-xml/include/libxml/xmlreader.h,v
retrieving revision 1.31
diff -u -r1.31 xmlreader.h
--- include/libxml/xmlreader.h  2 Jan 2005 09:53:12 -0000       1.31
+++ include/libxml/xmlreader.h  3 Jan 2005 19:05:20 -0000
@@ -243,6 +243,13 @@
                                                 int prop);
 XMLPUBFUN xmlNodePtr XMLCALL   
                    xmlTextReaderCurrentNode    (xmlTextReaderPtr reader);
+
+XMLPUBFUN int XMLCALL
+            xmlTextReaderGetLineNumber  (xmlTextReaderPtr reader);
+
+XMLPUBFUN int XMLCALL
+            xmlTextReaderGetColumnNumber(xmlTextReaderPtr reader);
+
 XMLPUBFUN xmlNodePtr XMLCALL   
                    xmlTextReaderPreserve       (xmlTextReaderPtr reader);
 #ifdef LIBXML_PATTERN_ENABLED


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