Hi Petr, Petr van Blokland wrote:
I get a very consistent error when including an XSL stylesheet from another XSL stylesheet using xsl:include or xsl:import But the problem is so basic that I cannot believe it could be something inside lxml.
the following error is raised:
File "xslt.pxi", line 261, in etree.XSLT.__init__ File "etree.pyx", line 133, in etree._ExceptionContext._raise_if_stored etree.XSLTParseError: Cannot resolve URI XSLT://para.xsl
What do I do wrong that XSLT cannot resolve the para.xsl file?
Nothing. That was a bug in lxml, thanks for reporting it. It stopped working when I started making lxml read file-like objects directly where ever it can. The problem was that libxml2 doesn't get to know the file name in this case and thus can't store it in the document when you call parse(). This prevents the stylesheet from knowing where it came from. Here's a patch: Index: src/lxml/parser.pxi =================================================================== --- src/lxml/parser.pxi (Revision 28159) +++ src/lxml/parser.pxi (Arbeitskopie) @@ -419,6 +419,8 @@ if result is NULL: _raiseParseError(ctxt, c_filename) + elif result.URL is NULL and c_filename is not NULL: + result.URL = tree.xmlStrdup(c_filename) return result ############################################################ BTW, you can also call parse on the filename rather than an open file. That's even more efficient as it doesn't go through Python to read the file. Sorry for the inconvenience, Stefan