[xml-bindings] python xslt wrapper and xalan write



Hi,

I have a stylesheet that uses the xalan write
extension. This runs succesfully and produces
the required file from python. However the
style of the file is xml, despite me setting
<xsl:output method="text"/>. Does anyone know
if it is possible to get text output?

For example ...

mytest.xsl:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:xalan="org.apache.xalan.xslt.extensions.Redirect"
  extension-element-prefixes="xalan">

<xsl:output method="text"/>

<xsl:template match="/">

<xsl:value-of select="mytext"/>
<xsl:text>&amp;</xsl:text>

<xalan:write select="'testXalan.out'">
<xsl:value-of select="mytext"/>
<xsl:text>&amp;</xsl:text>
</xalan:write>

</xsl:template>

</xsl:stylesheet>

test.py:
#! /usr/bin/env python

import sys
import libxml2
import libxslt

styledoc = libxml2.parseFile("mytest.xsl")
style = libxslt.parseStylesheetDoc(styledoc)
doc = libxml2.parseFile("mytest.xml")
result = style.applyStylesheet(doc, None )
style.saveResultToFilename("test.out", result, 0)
style.freeStylesheet()
doc.freeDoc()
result.freeDoc()

sys.exit(0)

mytest.xml:
<mytext>
hello
</mytext>

When run I get:

ksh-2.05b$ ./test.py
ksh-2.05b$ more test.out

hello
&
ksh-2.05b$ more testXalan.out
<?xml version="1.0"?>

hello
&amp;

Any help much appreciated

Thanks

-- Rupert Ford
--
Research Fellow
Centre for Novel Computing,   rupert manchester ac uk
School of Computer Science,   http://www.cs.manchester.ac.uk/cnc
The University of Manchester  +44 (0)161 275 5724

Manchester United fans:
Join The Manchester United Supporters Trust
http://www.shareholdersunited.org



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