libxslt, libxml and xmldoc problem
aseem at neurobs.com
Wed Aug 21 07:21:40 CEST 2002
I am trying to convert XML docs to HTML docs using an XSL file on the
fly, on a web server (Zope-Zserver). The function (external method :
altho it can apply to apache and cgi too) that I have which does it is
## code begin
styledoc = libxml2.parseFile("help_page.xsl")
style = libxslt.parseStylesheetDoc(styledoc)
doc = libxml2.parseFile("A_First_Scenario.xml")
result = style.applyStylesheet(doc, None)
style.saveResultToFilename("-", result, 0)
## code end
Now the only problem with this is that result which is an xmldoc
object can only save to a file, I looked at the source of
libxml.py:xmldoc. It can dump and save in a variety of ways but only
to a file or if the arg is "-", as above, to the standard output.
I wanted to save the contents of result to a string which I could then
send back as part of the RESPONSE object.
So I have two ques:
1. If possible, how do I save the contents directly to a string so as
to bypass the whole "print open(html_file).read()" thing??
2. How do I trap the output being sent to stdout and capture it into a
More information about the Python-list