[xslt] xsltApplyStylesheet and xsltSaveResultTo




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, 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?

Can anyone please tell me the best way to do something like this?

Thanks much,
Dave






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