[lxml-dev] RESOLVED Re: document('') and custom resolver not working again/still

Ok this is definitely not an lxml problem. Here's how you can recreate the same problem I had.. duh! If you (accidentally) use the same base_url for when loading both the xsl and xml source, there's a 50% chance that document('') will return the xml source, not the xsl source object. class Tester(object): def test(self): xsl_resolver = Resolver(fake_resolve_function) xsl_parser = etree.XMLParser(load_dtd=True) xsl_parser.resolvers.add(Resolver(resolver=xsl_resolver)) stylesheet_doc = etree.fromstring(xsl_src, xsl_parser, base_url='/carriers/view.htm') stylesheet = etree.XSLT(stylesheet_doc) xml_resolver = Resolver(fake_resolve_function) xml_parser = etree.XMLParser(load_dtd=True) xml_parser.resolvers.add(Resolver(resolver=xml_resolver)) xml_doc = etree.fromstring(xml_src, xml_parser, base_url='/carriers/view.htm') return str(stylesheet(xml_doc)) -- Brad Clements, bkc@murkworks.com (315)268-1000 http://www.murkworks.com AOL-IM: BKClements

Hi, Brad Clements wrote:
If you (accidentally) use the same base_url for when loading both the xsl and xml source, there's a 50% chance that document('') will return the xml source, not the xsl source object.
Ah, sure, that won't work if you happen to use both during the XSLT evaluation, as libxslt internally caches document references by URL. Happy to hear you've solved it. Stefan
participants (2)
-
Brad Clements
-
Stefan Behnel