[lxml-dev] custom resolver, why does system url start with XSLT:?

Brad Clements bkc at murkworks.com
Sat Oct 20 01:34:38 CEST 2007


Stefan Behnel wrote:
>
> If you are you parsing your stylesheets from a string, without providing a
> URL, lxml will come up with a fake URL-like string to make sure we can
> identify the stylesheet on request. I think what happens here is that libxml2
> parses that string and extracts what it understands of it to prepend it to the
> relative path of the referenced document.
>   
ah, my libxml2 version does this:

xml_doc = libxml2.readDoc(xml_src_object.get_source(), # a string
                                       uri,
                                       None, 0)

I looked for similar functionality for etree.parse, but I could not 
find  it in the docs how to pass a uri

oh duh, *now* I see it

http://codespeak.net/lxml/parsing.html#parsers

> If you want to parse from memory and still provide a base URL for the 
> document (e.g. to support relative paths in an XInclude), you can pass 
> the base_url keyword argument:

(I didn't see that before, sorry!)

Well, it didn't seem to help.

I changed my code to this:

xml_doc = etree.fromstring(xml_src_object.get_source(), parser, 
base_url=uri)

but I still get this:

resolve url 'XSLT:///xml/navigation.xml' id None ctext 
<lxml.etree._XSLTResolverContext object at 0xb697286c>
resolve url '/xml/carrier_payables_navigation.xml' id None ctext 
<lxml.etree._XSLTResolverContext object at 0xb697286c>
resolve url 'XSLT:///services/+payment_accounts' id None ctext 
<lxml.etree._XSLTResolverContext object at 0xb697286c>


Maybe the etree.Resolver.resolve_string needs to pass the URI back into 
libxml2 when loading the string?

Perhaps that's also an issue? I don't know.



-- 
Brad Clements,                bkc at murkworks.com    (315)268-1000
http://www.murkworks.com                          
AOL-IM: BKClements



More information about the lxml-dev mailing list