logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Re: Stylesheet Processing Instruction: msg#00069

Subject: Re: Stylesheet Processing Instruction
Hi Sidnei,

Sidnei da Silva wrote:
> On Tue, Sep 19, 2006 at 06:14:04PM +0200, Stefan Behnel wrote:
> | Ok, what we are getting at in that case is that we provide a convenience
> | method for the following code:
> 
> I think there's an extra step in there:
> 
> |   tree = etree.parse(<some XML with XSLT PI>)
> |   root = tree.getroot()
> |   pi = root.getprevious()
> |   ... read 'href' value from pi.text if 'type' is XSL ...
> +   ... resolve 'href' through resolvers
> |   transform = etree.XSLT(etree.parse(href))
> |   transform(tree)

No, that's already done by parse(), see resolvers.txt.


> | The PI attribute parsing part is maybe the most tricky one.
> | 
> | Questions:
> | 
> | * is it worth special casing?
> 
> Well, since libxml2 provides such an API, there's probably value in
> it.

Bad argument. libxml2 and libxslt have all sorts of redundant APIs.


> In fact, we should probably look at the source for
> xsltLoadStylesheetPI to see if it does anything more than what you're
> proposing.
> 
> | * are there other cases where PIs can or should be special cased?
> 
> For stylesheets specifically, I've saw an example where the stylesheet
> href was a fragment identifier ('#stylesheet') and the stylesheet was
> then *in the same XML* instead of a separate file.

That could easily be handled via Python resolvers.

So, given the fact that the libxml2 API can't actually resolve URLs through
Python resolvers, we should consider not using it and instead making the way I
sketched above a bit smoother.

Stefan


<Prev in Thread] Current Thread [Next in Thread>