[XML-SIG] using libxslt with strings

Paul Boddie paul.boddie at ementor.no
Mon Feb 16 04:28:34 EST 2004

Paul Tremblay [mailto:phthenry at earthlink.net] wrote:
> Can someone tell me how to save to a string when using libxslt?


> styledoc = libxml2.parseFile("/home/paul/paultemp/test.xsl")
> style = libxslt.parseStylesheetDoc(styledoc)
> doc = libxml2.parseFile("/home/paul/paultemp/test.xml")
> result = style.applyStylesheet(doc, None)
> style.freeStylesheet()
> doc.freeDoc()
> # style.saveResultToFilename("foo", result, 0)

Try this:

  s = style.saveResultToString(result)

> Now how do I store my result as a string so I can do further processing?
> I actually want to process a document with several xslt stylesheets, and
> then process it with SAX.

What would be really nice with libxslt/libxml2 is a means to write the
results to a stream that could be read from using the normal Python
file/stream objects, but without going via a temporary file. It is
possible to use StringIO on a serialised document, but I doubt that it
is particularly efficient.


More information about the XML-SIG mailing list