[lxml-dev] broken document('') in xslt ..

I am having trouble with a transform on 2.0alpha5 (and 2.0alpha3). It works on a system with a newer libxml2/libxslt, but fails on a slightly older libxml2/libxslt. However when using xsltproc on the "older" system, the transform works. So I think maybe there is an issue with custom resolvers. basically the .xsl looks like this: <xsl_:for-each select="document('')//const:css/const:file"> <xsl_:variable name="file" select="."/> <link rel="stylesheet" type="text/css"> <xsl_:attribute name="href"> <xsl_:value-of select="concat('/css/', $file)"/> </xsl_:attribute> </link> </xsl_:for-each> And elsewhere in the xsl file is: <const:css id="number_pad_css"> <const:file>manage_pending.css</const:file> </const:css> I am using a custom resolver. I don't see any requests to resolve '' (and I wouldn't expect any either). At first I thought this was a 2.0alpha5 issue, but I downgraded to 2.0alpha3 and I still have the problem on one system, but it works on the other. working system, centos 4, lxml 2.0alpha3 libxml2 (2, 6, 28) / libxslt (1, 1, 20) non-working system, centos 4, lxml 2.0alpha3 (or 5), libxml2 (2, 6, 23) / libxslt (1, 1, 15) On the non-working system, if I use xsltproc, the transform works correctly. [bkc@sch package_data]$ xsltproc -version Using libxml 20623, libxslt 10115 and libexslt 812 xsltproc was compiled against libxml 20623, libxslt 10115 and libexslt 812 libxslt 10115 was compiled against libxml 20623 libexslt 812 was compiled against libxml 20623 output (in part) <link rel="stylesheet" type="text/css" href="/css/manage_pending.css" /> I tried going through the libxslt changelog, but nothing appears obvious to me as being a candidate issue. Can anyone suggest something? (upgrading libxslt on this system will be difficult) -- Brad Clements, bkc@murkworks.com (315)268-1000 http://www.murkworks.com AOL-IM: BKClements

Hi, Brad Clements wrote:
I am having trouble with a transform on 2.0alpha5 (and 2.0alpha3). It works on a system with a newer libxml2/libxslt, but fails on a slightly older libxml2/libxslt. However when using xsltproc on the "older" system, the transform works.
We actually do have test cases for "document('')" in XSLT and my last test didn't show any problems here. Maybe it's only an issue when custom resolvers come into play. I'll look into this.
Can anyone suggest something? (upgrading libxslt on this system will be difficult)
It looks like you have a sane build environment available. You can try to build a recent libxml2 and libxslt by hand (without installing them) and link them statically into lxml to work around this. It will add some 4-5 megs to the size of the lxml install, though. This should get you going: http://codespeak.net/lxml/dev/build.html#static-linking-on-windows Stefan

Hi, Brad Clements wrote:
I am having trouble with a transform on 2.0alpha5 (and 2.0alpha3). It works on a system with a newer libxml2/libxslt, but fails on a slightly older libxml2/libxslt. However when using xsltproc on the "older" system, the transform works. So I think maybe there is an issue with custom resolvers.
I added the following test case, which works for me on the current lxml 2.0 trunk and also on 2.0alpha5 using libxml2 2.6.20-30 and libxslt 1.1.15-22. Is there anything you do different? Stefan def test_xslt_document_XML_resolver(self): assertEquals = self.assertEquals called = {'count' : 0} class TestResolver(etree.Resolver): def resolve(self, url, id, context): assertEquals(url, 'file://ANYTHING') called['count'] += 1 return self.resolve_string('<CALLED/>', context) parser = etree.XMLParser() parser.resolvers.add(TestResolver()) xslt = etree.XSLT(etree.XML("""\ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:l="local"> <xsl:template match="/"> <test> <xsl:for-each select="document('')//l:data/l:entry"> <xsl:copy-of select="document('file://ANYTHING')"/> <xsl:copy> <xsl:attribute name="value"> <xsl:value-of select="."/> </xsl:attribute> </xsl:copy> </xsl:for-each> </test> </xsl:template> <l:data> <l:entry>A</l:entry> <l:entry>B</l:entry> </l:data> </xsl:stylesheet> """, parser)) self.assertEquals(called['count'], 0) result = xslt(etree.XML('<a/>')) self.assertEquals(called['count'], 1) root = result.getroot() self.assertEquals(root.tag, 'test') self.assertEquals(len(root), 4) self.assertEquals(root[0].tag, 'CALLED') self.assertEquals(root[1].tag, '{local}entry') self.assertEquals(root[1].text, None) self.assertEquals(root[1].get("value"), 'A') self.assertEquals(root[2].tag, 'CALLED') self.assertEquals(root[3].tag, '{local}entry') self.assertEquals(root[3].text, None) self.assertEquals(root[3].get("value"), 'B')
participants (2)
-
Brad Clements
-
Stefan Behnel