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

Stefan Behnel stefan_ml at behnel.de
Tue Oct 16 08:50:05 CEST 2007


Brad Clements wrote:
> I have a project (XSL based TAL) that has used libxml2 and libxslt for a 
> couple of years. I have a custom resolver that has worked "ok" with this.
> 
> Now I have converted the project to use lxml. I am creating a parser and 
> adding my resolver.
> 
> when my resolver gets called, the URIs are weirdly mangled like this:
> 
> resolve url 'XSLT:///xml/navigation.xml' id None ctext 
> <lxml.etree._XSLTResolverContext object at 0xb6a5353c>
> 
> resolve url '/xml/carrier_payables_navigation.xml' id None ctext 
> <lxml.etree._XSLTResolverContext object at 0xb6a5353c>
> 
> resolve url 'XSLT:///services/+payment_accounts' id None ctext 
> <lxml.etree._XSLTResolverContext object at 0xb6a5353c>
> 
> (the 2nd one is not mangled, looks ok to me)
> 
> What's the story with XSLT:// being stuck on the front of the system urls?
>
> The last example url, comes from using document() in a stylesheet, (the
> converted form of this:)
>
> <option tal:repeat="account
> document('/services/+payment_accounts')/data/accounts/item"
>    tal:attributes="value $account/id"
>    tal:content="concat($account/name, ' ($', $account/currency, ')')" />
>
> The 2nd example url above (the non-mangled one), also comes from a
> document call, like this:
>
> <tal:block tal:omit-tag="" tal:repeat="tab
> document($const/@secondary_navigation)/root/tab">

Never seen that before. Maybe it's a context hint provided by libxslt?
Something like "please evaluate this URL in the context of (i.e. relative to)
the current stylesheet"?

I would scan the libxslt sources (starting with document.c and the document()
function) or ask on the libxslt mailing list.

In the case that it is meant to be evaluated relative to the stylesheet, then
lxml should do that for you internally. So if you can figure it out, I'd be
glad to provide the fix.


> Maybe the difference is due to one document() using a constant string,
> the other using a variable..?

Possibly. The libxslt list would be a good place to find out.


> I am using 2.0 alpha4 and 2.0 alpha 3  (two different systems, same 
> problem). I can't see how from lxml to tell you which version of libxml2 
> and libxslt I am using.

http://codespeak.net/lxml/dev/FAQ.html#i-think-i-have-found-a-bug-in-lxml-what-should-i-do

Stefan



More information about the lxml-dev mailing list