diff options
Diffstat (limited to 'python')
-rw-r--r-- | python/Makefile.in | 2 | ||||
-rw-r--r-- | python/drv_libxml2.py | 20 | ||||
-rw-r--r-- | python/libxml.py | 11 | ||||
-rw-r--r-- | python/libxml2-py.c | 172 | ||||
-rwxr-xr-x | python/setup.py | 2 | ||||
-rw-r--r-- | python/tests/Makefile.in | 2 |
6 files changed, 137 insertions, 72 deletions
diff --git a/python/Makefile.in b/python/Makefile.in index f1fed8a..a1054fc 100644 --- a/python/Makefile.in +++ b/python/Makefile.in @@ -226,6 +226,7 @@ WITH_XINCLUDE = @WITH_XINCLUDE@ WITH_XPATH = @WITH_XPATH@ WITH_XPTR = @WITH_XPTR@ XINCLUDE_OBJ = @XINCLUDE_OBJ@ +XMLLINT = @XMLLINT@ XML_CFLAGS = @XML_CFLAGS@ XML_INCLUDEDIR = @XML_INCLUDEDIR@ XML_LIBDIR = @XML_LIBDIR@ @@ -233,6 +234,7 @@ XML_LIBS = @XML_LIBS@ XML_LIBTOOLLIBS = @XML_LIBTOOLLIBS@ XPATH_OBJ = @XPATH_OBJ@ XPTR_OBJ = @XPTR_OBJ@ +XSLTPROC = @XSLTPROC@ Z_CFLAGS = @Z_CFLAGS@ Z_LIBS = @Z_LIBS@ ac_ct_AR = @ac_ct_AR@ diff --git a/python/drv_libxml2.py b/python/drv_libxml2.py index 421f945..e43fb1d 100644 --- a/python/drv_libxml2.py +++ b/python/drv_libxml2.py @@ -38,7 +38,6 @@ __author__ = u"Stéphane Bidoul <sbi@skynet.be>" __version__ = "0.3" import codecs -import sys from types import StringType, UnicodeType StringTypes = (StringType,UnicodeType) @@ -100,6 +99,7 @@ class LibXml2Reader(xmlreader.XMLReader): self.__ns = 0 self.__nspfx = 0 self.__validate = 0 + self.__extparams = 1 # parsing flag self.__parsing = 0 # additional handlers @@ -142,10 +142,13 @@ class LibXml2Reader(xmlreader.XMLReader): reader = input.newTextReader(source.getSystemId()) reader.SetErrorHandler(self._errorHandler,None) # configure reader - reader.SetParserProp(libxml2.PARSER_LOADDTD,1) - reader.SetParserProp(libxml2.PARSER_DEFAULTATTRS,1) - reader.SetParserProp(libxml2.PARSER_SUBST_ENTITIES,1) - reader.SetParserProp(libxml2.PARSER_VALIDATE,self.__validate) + if self.__extparams: + reader.SetParserProp(libxml2.PARSER_LOADDTD,1) + reader.SetParserProp(libxml2.PARSER_DEFAULTATTRS,1) + reader.SetParserProp(libxml2.PARSER_SUBST_ENTITIES,1) + reader.SetParserProp(libxml2.PARSER_VALIDATE,self.__validate) + else: + reader.SetParserProp(libxml2.PARSER_LOADDTD, 0) # we reuse attribute maps (for a slight performance gain) if self.__ns: attributesNSImpl = xmlreader.AttributesNSImpl({},{}) @@ -316,7 +319,7 @@ class LibXml2Reader(xmlreader.XMLReader): elif name == feature_external_ges: return 1 # TODO (does that relate to PARSER_LOADDTD)? elif name == feature_external_pes: - return 1 # TODO (does that relate to PARSER_LOADDTD)? + return self.__extparams else: raise SAXNotRecognizedException("Feature '%s' not recognized" % \ name) @@ -337,10 +340,7 @@ class LibXml2Reader(xmlreader.XMLReader): raise SAXNotSupportedException("Feature '%s' not supported" % \ name) elif name == feature_external_pes: - if state == 0: - # TODO (does that relate to PARSER_LOADDTD)? - raise SAXNotSupportedException("Feature '%s' not supported" % \ - name) + self.__extparams = state else: raise SAXNotRecognizedException("Feature '%s' not recognized" % \ name) diff --git a/python/libxml.py b/python/libxml.py index 1036bd9..588e862 100644 --- a/python/libxml.py +++ b/python/libxml.py @@ -1,28 +1,31 @@ import libxml2mod import types +# The root of all libxml2 errors. +class libxmlError(Exception): pass + # # Errors raised by the wrappers when some tree handling failed. # -class treeError: +class treeError(libxmlError): def __init__(self, msg): self.msg = msg def __str__(self): return self.msg -class parserError: +class parserError(libxmlError): def __init__(self, msg): self.msg = msg def __str__(self): return self.msg -class uriError: +class uriError(libxmlError): def __init__(self, msg): self.msg = msg def __str__(self): return self.msg -class xpathError: +class xpathError(libxmlError): def __init__(self, msg): self.msg = msg def __str__(self): diff --git a/python/libxml2-py.c b/python/libxml2-py.c index b562abf..1a4ba1d 100644 --- a/python/libxml2-py.c +++ b/python/libxml2-py.c @@ -156,25 +156,6 @@ libxml_xmlTextReaderExpand(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { } PyObject * -libxml_xmlAddSibling(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { - PyObject *py_retval; - xmlNodePtr c_retval; - xmlNodePtr cur; - PyObject *pyobj_cur; - xmlNodePtr elem; - PyObject *pyobj_elem; - - if (!PyArg_ParseTuple(args, (char *)"OO:xmlAddSibling", &pyobj_cur, &pyobj_elem)) - return(NULL); - cur = (xmlNodePtr) PyxmlNode_Get(pyobj_cur); - elem = (xmlNodePtr) PyxmlNode_Get(pyobj_elem); - - c_retval = xmlAddSibling(cur, elem); - py_retval = libxml_xmlNodePtrWrap((xmlNodePtr) c_retval); - return(py_retval); -} - -PyObject * libxml_xmlScanName(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { PyObject *py_retval; xmlChar * c_retval; @@ -501,6 +482,25 @@ libxml_xmlCheckLanguageID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { return(py_retval); } +#ifdef LIBXML_SCHEMAS_ENABLED +PyObject * +libxml_xmlSchemaSetValidOptions(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { + PyObject *py_retval; + int c_retval; + xmlSchemaValidCtxtPtr ctxt; + PyObject *pyobj_ctxt; + int options; + + if (!PyArg_ParseTuple(args, (char *)"Oi:xmlSchemaSetValidOptions", &pyobj_ctxt, &options)) + return(NULL); + ctxt = (xmlSchemaValidCtxtPtr) PySchemaValidCtxt_Get(pyobj_ctxt); + + c_retval = xmlSchemaSetValidOptions(ctxt, options); + py_retval = libxml_intWrap((int) c_retval); + return(py_retval); +} + +#endif /* LIBXML_SCHEMAS_ENABLED */ PyObject * libxml_xmlFreeNs(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { xmlNsPtr cur; @@ -621,6 +621,25 @@ libxml_xmlParserGetDoc(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { } PyObject * +libxml_xmlAddSibling(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { + PyObject *py_retval; + xmlNodePtr c_retval; + xmlNodePtr cur; + PyObject *pyobj_cur; + xmlNodePtr elem; + PyObject *pyobj_elem; + + if (!PyArg_ParseTuple(args, (char *)"OO:xmlAddSibling", &pyobj_cur, &pyobj_elem)) + return(NULL); + cur = (xmlNodePtr) PyxmlNode_Get(pyobj_cur); + elem = (xmlNodePtr) PyxmlNode_Get(pyobj_elem); + + c_retval = xmlAddSibling(cur, elem); + py_retval = libxml_xmlNodePtrWrap((xmlNodePtr) c_retval); + return(py_retval); +} + +PyObject * libxml_xmlNodeAddContentLen(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { xmlNodePtr cur; PyObject *pyobj_cur; @@ -2623,15 +2642,15 @@ libxml_xmlSchemaValidateDoc(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { int c_retval; xmlSchemaValidCtxtPtr ctxt; PyObject *pyobj_ctxt; - xmlDocPtr instance; - PyObject *pyobj_instance; + xmlDocPtr doc; + PyObject *pyobj_doc; - if (!PyArg_ParseTuple(args, (char *)"OO:xmlSchemaValidateDoc", &pyobj_ctxt, &pyobj_instance)) + if (!PyArg_ParseTuple(args, (char *)"OO:xmlSchemaValidateDoc", &pyobj_ctxt, &pyobj_doc)) return(NULL); ctxt = (xmlSchemaValidCtxtPtr) PySchemaValidCtxt_Get(pyobj_ctxt); - instance = (xmlDocPtr) PyxmlNode_Get(pyobj_instance); + doc = (xmlDocPtr) PyxmlNode_Get(pyobj_doc); - c_retval = xmlSchemaValidateDoc(ctxt, instance); + c_retval = xmlSchemaValidateDoc(ctxt, doc); py_retval = libxml_intWrap((int) c_retval); return(py_retval); } @@ -2951,6 +2970,27 @@ libxml_xmlUCSIsBuhid(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { return(py_retval); } +#ifdef LIBXML_SCHEMAS_ENABLED +PyObject * +libxml_xmlSchemaValidateOneElement(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { + PyObject *py_retval; + int c_retval; + xmlSchemaValidCtxtPtr ctxt; + PyObject *pyobj_ctxt; + xmlNodePtr elem; + PyObject *pyobj_elem; + + if (!PyArg_ParseTuple(args, (char *)"OO:xmlSchemaValidateOneElement", &pyobj_ctxt, &pyobj_elem)) + return(NULL); + ctxt = (xmlSchemaValidCtxtPtr) PySchemaValidCtxt_Get(pyobj_ctxt); + elem = (xmlNodePtr) PyxmlNode_Get(pyobj_elem); + + c_retval = xmlSchemaValidateOneElement(ctxt, elem); + py_retval = libxml_intWrap((int) c_retval); + return(py_retval); +} + +#endif /* LIBXML_SCHEMAS_ENABLED */ PyObject * libxml_xmlReadDoc(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { PyObject *py_retval; @@ -3733,6 +3773,25 @@ libxml_xmlValidateNmtokenValue(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) } PyObject * +libxml_xmlAddChildList(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { + PyObject *py_retval; + xmlNodePtr c_retval; + xmlNodePtr parent; + PyObject *pyobj_parent; + xmlNodePtr cur; + PyObject *pyobj_cur; + + if (!PyArg_ParseTuple(args, (char *)"OO:xmlAddChildList", &pyobj_parent, &pyobj_cur)) + return(NULL); + parent = (xmlNodePtr) PyxmlNode_Get(pyobj_parent); + cur = (xmlNodePtr) PyxmlNode_Get(pyobj_cur); + + c_retval = xmlAddChildList(parent, cur); + py_retval = libxml_xmlNodePtrWrap((xmlNodePtr) c_retval); + return(py_retval); +} + +PyObject * libxml_xmlGetNodePath(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { PyObject *py_retval; xmlChar * c_retval; @@ -5309,20 +5368,6 @@ libxml_xmlValidateNCName(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { } PyObject * -libxml_xmlUCSIsMusicalSymbols(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { - PyObject *py_retval; - int c_retval; - int code; - - if (!PyArg_ParseTuple(args, (char *)"i:xmlUCSIsMusicalSymbols", &code)) - return(NULL); - - c_retval = xmlUCSIsMusicalSymbols(code); - py_retval = libxml_intWrap((int) c_retval); - return(py_retval); -} - -PyObject * libxml_xmlUCSIsCJKCompatibility(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { PyObject *py_retval; int c_retval; @@ -7896,25 +7941,6 @@ libxml_xmlNamespaceParseNCName(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) } PyObject * -libxml_xmlAddChildList(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { - PyObject *py_retval; - xmlNodePtr c_retval; - xmlNodePtr parent; - PyObject *pyobj_parent; - xmlNodePtr cur; - PyObject *pyobj_cur; - - if (!PyArg_ParseTuple(args, (char *)"OO:xmlAddChildList", &pyobj_parent, &pyobj_cur)) - return(NULL); - parent = (xmlNodePtr) PyxmlNode_Get(pyobj_parent); - cur = (xmlNodePtr) PyxmlNode_Get(pyobj_cur); - - c_retval = xmlAddChildList(parent, cur); - py_retval = libxml_xmlNodePtrWrap((xmlNodePtr) c_retval); - return(py_retval); -} - -PyObject * libxml_xmlGetDtdEntity(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { PyObject *py_retval; xmlEntityPtr c_retval; @@ -9543,6 +9569,20 @@ libxml_htmlDocDump(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { #endif /* LIBXML_HTML_ENABLED */ PyObject * +libxml_xmlUCSIsMusicalSymbols(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { + PyObject *py_retval; + int c_retval; + int code; + + if (!PyArg_ParseTuple(args, (char *)"i:xmlUCSIsMusicalSymbols", &code)) + return(NULL); + + c_retval = xmlUCSIsMusicalSymbols(code); + py_retval = libxml_intWrap((int) c_retval); + return(py_retval); +} + +PyObject * libxml_xmlTextReaderRelaxNGValidate(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { PyObject *py_retval; int c_retval; @@ -10440,6 +10480,24 @@ libxml_xmlHandleEntity(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { return(Py_None); } +#ifdef LIBXML_SCHEMAS_ENABLED +PyObject * +libxml_xmlSchemaValidCtxtGetOptions(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { + PyObject *py_retval; + int c_retval; + xmlSchemaValidCtxtPtr ctxt; + PyObject *pyobj_ctxt; + + if (!PyArg_ParseTuple(args, (char *)"O:xmlSchemaValidCtxtGetOptions", &pyobj_ctxt)) + return(NULL); + ctxt = (xmlSchemaValidCtxtPtr) PySchemaValidCtxt_Get(pyobj_ctxt); + + c_retval = xmlSchemaValidCtxtGetOptions(ctxt); + py_retval = libxml_intWrap((int) c_retval); + return(py_retval); +} + +#endif /* LIBXML_SCHEMAS_ENABLED */ #ifdef LIBXML_XPATH_ENABLED PyObject * libxml_xmlXPathFloorFunction(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { diff --git a/python/setup.py b/python/setup.py index f094b56..6d9d1c6 100755 --- a/python/setup.py +++ b/python/setup.py @@ -226,7 +226,7 @@ else: setup (name = "libxml2-python", # On *nix, the version number is created from setup.py.in # On windows, it is set by configure.js - version = "2.6.13", + version = "2.6.14", description = descr, author = "Daniel Veillard", author_email = "veillard@redhat.com", diff --git a/python/tests/Makefile.in b/python/tests/Makefile.in index dfef491..3084356 100644 --- a/python/tests/Makefile.in +++ b/python/tests/Makefile.in @@ -191,6 +191,7 @@ WITH_XINCLUDE = @WITH_XINCLUDE@ WITH_XPATH = @WITH_XPATH@ WITH_XPTR = @WITH_XPTR@ XINCLUDE_OBJ = @XINCLUDE_OBJ@ +XMLLINT = @XMLLINT@ XML_CFLAGS = @XML_CFLAGS@ XML_INCLUDEDIR = @XML_INCLUDEDIR@ XML_LIBDIR = @XML_LIBDIR@ @@ -198,6 +199,7 @@ XML_LIBS = @XML_LIBS@ XML_LIBTOOLLIBS = @XML_LIBTOOLLIBS@ XPATH_OBJ = @XPATH_OBJ@ XPTR_OBJ = @XPTR_OBJ@ +XSLTPROC = @XSLTPROC@ Z_CFLAGS = @Z_CFLAGS@ Z_LIBS = @Z_LIBS@ ac_ct_AR = @ac_ct_AR@ |