[xslt] python saveResultToFile
- From: Sam Brauer <sam webslingerZ com>
- To: <xslt gnome org>
- Subject: [xslt] python saveResultToFile
- Date: Sun, 31 Mar 2002 06:24:30 -0500 (EST)
Hello!
I'm able to use saveResultToFilename() just fine, but would like to be
able to use saveResultToFile() so that I can save the result to a
cStringIO (or plain old StringIO) object then get the value as a string to
be further manipulated.
However, when I call saveResultToFile() no output seems to be written to
the file object, and the method returns as if everything went ok.
The following is an example of what I'm trying to do:
-----------------------------------------------
import libxml2
import libxslt
import cStringIO
styledoc = libxml2.parseFile("test.xsl")
style = libxslt.parseStylesheetDoc(styledoc)
doc = libxml2.parseFile("test.xml")
result = style.applyStylesheet(doc, None)
out = cStringIO.StringIO()
style.saveResultToFile(out, result)
result.freeDoc()
style.freeStylesheet()
doc.freeDoc()
out.flush()
s = out.getvalue()
out.close()
print s
-----------------------------------------------
I also tried saving to a "normal" file (out = open("foo", "w")), and the
same thing happens. In other words, saveResultToFile() doesn't raise an
exception, but the file is empty.
Am I doing something wrong, or is this a bug?
By the way, I'm using Python 2.1.2, libxml2-2.4.19 and libxslt 1.0.15.
Thanks for your help,
Sam
--
Sam Brauer
Systems Programmer
sam@webslingerZ.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]