Re: [xslt] xsltApplyStylesheet and xsltSaveResultTo



On Mon, Jan 14, 2002 at 04:02:58PM -0800, Dave Guerrieri wrote:
> 
> 
> I would like to add the resulting node set of an XSLT tranformation to the end
> of an XML document.  The transformation happens to do some accounting work
> summing up numbers of elements, etc.  Can I do this with the result from
> xsltApplyStylesheet?  For example, can I use something like this:
> 
> doc = xmlParseMemory(buffer, len);
> cur = xsltParseStylesheetFile(stylesheet_path);
> res = xsltApplyStylesheet(cur, doc, NULL);
> fragNode = xmlNewDocFragment(res);
> docRoot = xmlDocGetRootElement(doc);
> xmlAddChild(docRoot, fragNode);
> xmlSaveFile(filename,docRoot);
> 
> It seems like something like this should work,

  yes though there is a lot of other stuff needed for example to
deallocate the right parts and such, but yes something like this should
work ...

> but I am thrown by the fact that
> xsltSaveResultTo needs the stylesheet again.  If all xsltSaveResultTo was doing
> was outputting the resulting transformed tree, why would it need the stylesheet?

  Because a number of parameters of XSLT stylesheets releated to the
serialization are not representable in the intermediate tree, like
the xsl:output parameters.

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]