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

Brad Clements bkc at murkworks.com
Sun Jan 27 22:31:34 CET 2008


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 at murkworks.com    (315)268-1000
http://www.murkworks.com                          
AOL-IM: BKClements



More information about the lxml-dev mailing list