[Lxml-checkins] r53645 - in lxml/trunk: . src/lxml

scoder at codespeak.net scoder at codespeak.net
Thu Apr 10 09:00:15 CEST 2008


Author: scoder
Date: Thu Apr 10 09:00:14 2008
New Revision: 53645

Modified:
   lxml/trunk/   (props changed)
   lxml/trunk/src/lxml/etree_defs.h
   lxml/trunk/src/lxml/schematron.pxd
   lxml/trunk/src/lxml/schematron.pxi
Log:
 r3923 at delle:  sbehnel | 2008-04-10 08:43:38 +0200
 untested support for schematron error reporting (only used with libxml2 2.6.32+)


Modified: lxml/trunk/src/lxml/etree_defs.h
==============================================================================
--- lxml/trunk/src/lxml/etree_defs.h	(original)
+++ lxml/trunk/src/lxml/etree_defs.h	Thu Apr 10 09:00:14 2008
@@ -70,6 +70,10 @@
 /* schematron was added in libxml2 2.6.21 */
 #ifdef LIBXML_SCHEMATRON_ENABLED
 #  define ENABLE_SCHEMATRON 1
+#  if LIBXML_VERSION < 20632
+     /* schematron error reporting was added in libxml2 2.6.32 */
+#    define xmlSchematronSetValidStructuredErrors(ctxt, errorfunc, data)
+#  endif
 #else
 #  define ENABLE_SCHEMATRON 0
 #  define XML_SCHEMATRON_OUT_QUIET 0
@@ -85,8 +89,10 @@
 #  define xmlSchematronNewValidCtxt(schema, options) NULL
 #  define xmlSchematronValidateDoc(ctxt, doc) 0
 #  define xmlSchematronFreeValidCtxt(ctxt)
+#  define xmlSchematronSetValidStructuredErrors(ctxt, errorfunc, data)
 #endif
 
+
 /* work around MSDEV 6.0 */
 #if (_MSC_VER == 1200) && (WINVER < 0x0500)
 long _ftol( double ); //defined by VC6 C libs

Modified: lxml/trunk/src/lxml/schematron.pxd
==============================================================================
--- lxml/trunk/src/lxml/schematron.pxd	(original)
+++ lxml/trunk/src/lxml/schematron.pxd	Thu Apr 10 09:00:14 2008
@@ -1,4 +1,4 @@
-cimport tree
+cimport tree, xmlerror
 from tree cimport xmlDoc, xmlDtd
 
 cdef extern from "libxml/schematron.h":
@@ -28,3 +28,6 @@
     cdef void xmlSchematronFreeParserCtxt(xmlSchematronParserCtxt* ctxt) nogil
     cdef void xmlSchematronFreeValidCtxt(xmlSchematronValidCtxt* ctxt) nogil
     cdef void xmlSchematronFree(xmlSchematron* schema) nogil
+    cdef void xmlSchematronSetValidStructuredErrors(
+        xmlSchematronValidCtxt* ctxt,
+        xmlerror.xmlStructuredErrorFunc error_func, void *data)

Modified: lxml/trunk/src/lxml/schematron.pxi
==============================================================================
--- lxml/trunk/src/lxml/schematron.pxi	(original)
+++ lxml/trunk/src/lxml/schematron.pxi	Thu Apr 10 09:00:14 2008
@@ -141,10 +141,12 @@
         doc = _documentOrRaise(etree)
         root_node = _rootNodeOrRaise(etree)
 
-        options = schematron.XML_SCHEMATRON_OUT_QUIET
-        #if tree.LIBXML_VERSION <= 20630: # ... and later?
-        # hack to switch off stderr output
-        options = options | schematron.XML_SCHEMATRON_OUT_XML
+        if _LIBXML_VERSION_INT >= 20632:
+            options = schematron.XML_SCHEMATRON_OUT_ERROR
+        else:
+            options = schematron.XML_SCHEMATRON_OUT_QUIET
+            # hack to switch off stderr output
+            options = options | schematron.XML_SCHEMATRON_OUT_XML
 
         valid_ctxt = schematron.xmlSchematronNewValidCtxt(
             self._c_schema, options)
@@ -152,6 +154,8 @@
             return python.PyErr_NoMemory()
 
         self._error_log.connect()
+        schematron.xmlSchematronSetValidStructuredErrors(
+            valid_ctxt, _receiveError, <void*>self.error_log)
         c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
         with nogil:
             ret = schematron.xmlSchematronValidateDoc(valid_ctxt, c_doc)


More information about the lxml-checkins mailing list