[xslt] XSLT transformation to Plain Text using Python bindings requiresusing children().serialize()?
- From: Craeg K Strong <cstrong arielpartners com>
- To: xslt gnome org
- Subject: [xslt] XSLT transformation to Plain Text using Python bindings requiresusing children().serialize()?
- Date: Thu, 22 Aug 2002 21:00:05 -0400
Hello:
I am writing a plugin for the Zope/Python environment that does
XSLT transformations. My original version worked with
4Suite/4XSLT, and I am now porting it to libxslt-py
Yes, my name is Craeg and I'm a libxslt newbie. ;-)
My very first unit test case initially failed, and
although I have a workaround I wanted to ask about it.
The problem is this:
- the result of applyStylesheet always returns an instance of
xmlDoc
- some of my stylesheets specify html or plain text
- for plain text, xmlDoc.serialize() prints
out an XML header
Perhaps there is some way to query the xmlDoc to
find the content type? Or should one always use
children().serialize() instead?
Thanks very much,
--Craeg Strong
----XML----
<?xml version="1.0"?>
<!DOCTYPE Document>
<Document>Hello, world</Document>
---XSLT------
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method = "text"/>
<xsl:template match="Document">
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
-----CODE----
...
styleDoc = libxml2.parseMemory(xsltContents, len(xsltContents))
style = libxslt.parseStylesheetDoc(styleDoc)
xmlDoc = libxml2.parseMemory(xmlContents, len(xmlContents))
result = style.applyStylesheet(xmlDoc, topLevelParams)
print "ONE"
print result.children.serialize('ascii', 1)
print "TWO"
print result.serialize('ascii', 1)
print "DONE"
----OUTPUT----
ONE
Hello, world
TWO
<?xml version="1.0" encoding="ascii"?>
Hello, world
DONE
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]