Re: [xslt] Apply stylesheet to a subbranch of a document



On Tue, Sep 16, 2003 at 01:02:35PM +0200, Kasimier Buchcik wrote:
> Hi,
> 
> I just wondered if one can apply a stylesheet to a subbranch of a 
> document. I learned that there is xsltApplyStylesheet that takes a 
> source document and a stylesheet, but no trace of a function that takes
> a node from the document and applies a stylesheet. Can someone point out 
> a way of doing that? Or do I have to clone the node into a separate 
> document and perform xsltApplyStylesheet on it?

  If you look at xsltApplyStylesheetInternal() code, there is a bunch
of processing needed before and after launching the recursive evaluation
done on the root node by
   xsltProcessOneNode(ctxt, ctxt->node, NULL);
I don't think it is wise to try to attempt a direct processing, and
the document passed to xsltApplyStylesheet() will be modified, you
may not want that to happen to a subtree. So I suggest building a new
document with a copy of the subtree as the cleaner approach.

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard@redhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]