Daniel Veillard, 10.08.2012 07:21: > BTW do you have a git commit for 2.9.0 preparation in lxml now ? I may > forward this to the packager for Fedora.
Hmm, I'm fixing it up only for lxml 3.0. Due to various changes in the code base, that won't apply directly to the latest 2.3.x, and I'm not sure I want to add support in the 2.3.x series. I might ... The fixes aren't all that complex, though. If it's just to get it working, the attached patch should show the necessary changes, but it won't apply to 2.3.x as is. BTW, with my latest changes, I get lots of XSLT test failures like this when I run it with libxslt 1.1.26: """ Failed example: str(result) Expected: '<?xml version="1.0"?>\n<foo><child>NEW TEXT</child></foo>\n' Got: '<?xml version=?>\n<foo><child>NEW TEXT</child></foo>\n' """ You might have seen these before. Stefan
# HG changeset patch # Parent a071dfc78c525bb6fda60746bbe694ff1b257200 adapt to upcoming buffer changes in libxml2 2.9 diff -r a071dfc78c52 -r e5da17790fc2 src/lxml/includes/etree_defs.h --- a/src/lxml/includes/etree_defs.h Thu Aug 09 17:06:50 2012 +0200 +++ b/src/lxml/includes/etree_defs.h Thu Aug 09 18:24:42 2012 +0200 @@ -152,6 +152,13 @@ # define xmlSchematronSetValidStructuredErrors(ctxt, errorfunc, data) #endif +#include "libxml/tree.h" +#ifndef LIBXML2_NEW_BUFFER + typedef xmlBuffer xmlBuf; +# define xmlBufContent(buf) xmlBufferContent(buf) +# define xmlBufLength(buf) xmlBufferLength(buf) +#endif + /* libexslt 1.1.25+ support EXSLT functions in XPath */ #if LIBXSLT_VERSION < 10125 #define exsltDateXpathCtxtRegister(ctxt, prefix) diff -r a071dfc78c52 -r e5da17790fc2 src/lxml/includes/tree.pxd --- a/src/lxml/includes/tree.pxd Thu Aug 09 17:06:50 2012 +0200 +++ b/src/lxml/includes/tree.pxd Thu Aug 09 18:24:42 2012 +0200 @@ -285,9 +285,11 @@ ctypedef struct xmlBuffer + ctypedef struct xmlBuf # new in libxml2 2.9 + ctypedef struct xmlOutputBuffer: - xmlBuffer* buffer - xmlBuffer* conv + xmlBuf* buffer + xmlBuf* conv int error const_xmlChar* XML_XML_NAMESPACE @@ -359,6 +361,8 @@ cdef void xmlBufferFree(xmlBuffer* buf) nogil cdef const_xmlChar* xmlBufferContent(xmlBuffer* buf) nogil cdef int xmlBufferLength(xmlBuffer* buf) nogil + cdef const_xmlChar* xmlBufContent(xmlBuf* buf) nogil # new in libxml2 2.9 + cdef size_t xmlBufLength(xmlBuf* buf) nogil # new in libxml2 2.9 cdef int xmlKeepBlanksDefault(int val) nogil cdef xmlChar* xmlNodeGetBase(xmlDoc* doc, xmlNode* node) nogil cdef void xmlNodeSetBase(xmlNode* node, const_xmlChar* uri) nogil diff -r a071dfc78c52 -r e5da17790fc2 src/lxml/serializer.pxi --- a/src/lxml/serializer.pxi Thu Aug 09 17:06:50 2012 +0200 +++ b/src/lxml/serializer.pxi Thu Aug 09 18:24:42 2012 +0200 @@ -81,7 +81,7 @@ tree. """ cdef tree.xmlOutputBuffer* c_buffer - cdef tree.xmlBuffer* c_result_buffer + cdef tree.xmlBuf* c_result_buffer cdef tree.xmlCharEncodingHandler* enchandler cdef const_char* c_enc cdef const_xmlChar* c_version @@ -133,11 +133,11 @@ try: if encoding is _unicode: - result = (<unsigned char*>tree.xmlBufferContent( - c_result_buffer))[:tree.xmlBufferLength(c_result_buffer)].decode('UTF-8') + result = (<unsigned char*>tree.xmlBufContent( + c_result_buffer))[:tree.xmlBufLength(c_result_buffer)].decode('UTF-8') else: - result = <bytes>(<unsigned char*>tree.xmlBufferContent( - c_result_buffer))[:tree.xmlBufferLength(c_result_buffer)] + result = <bytes>(<unsigned char*>tree.xmlBufContent( + c_result_buffer))[:tree.xmlBufLength(c_result_buffer)] finally: error_result = tree.xmlOutputBufferClose(c_buffer) if error_result < 0: @@ -287,6 +288,9 @@ tree.xmlOutputBufferWrite(c_buffer, 3, ' [\n') if c_dtd.notations != NULL: - tree.xmlDumpNotationTable(c_buffer.buffer, - <tree.xmlNotationTable*>c_dtd.notations) + c_buf = tree.xmlBufferCreate() + tree.xmlDumpNotationTable(c_buf, <tree.xmlNotationTable*>c_dtd.notations) + tree.xmlOutputBufferWrite( + c_buffer, tree.xmlBufferLength(c_buf), <const_char*>tree.xmlBufferContent(c_buf)) + tree.xmlBufferFree(c_buf) c_node = c_dtd.children while c_node is not NULL:
_______________________________________________ xml mailing list, project page http://xmlsoft.org/ xml@gnome.org https://mail.gnome.org/mailman/listinfo/xml