Hi,
A search in the FAQ and elsewhere didnt turn up what I was looking
for. So here is my first pass :
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name="rtf">
<node>
<!-- Here is a comment -->
<child attrib="something" >value</child>
</node>
</xsl:variable>
<xsl:variable name="tmpStr">
<xsl:apply-templates select="xalan:nodeset($rtf)"
mode="convert" />
</xsl:variable>
<xsl:value-of select="$tmpStr" disable-output-escaping="yes" />
</xsl:template>
<xsl:template match="*" mode="convert">
<xsl:text><</xsl:text><xsl:value-of
select="name(.)" /><xsl:text />
<xsl:for-each select="@*">
<xsl:text> </xsl:text><xsl:value-of
select="name(.)" />="<xsl:value-of select="." />"<xsl:text />
</xsl:for-each>
<xsl:choose>
<xsl:when test="count(node()) = 0">
<xsl:text>/></xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>></xsl:text>
<xsl:apply-templates select="node()"
mode="convert" />
<xsl:text></</xsl:text><xsl:value-of select="name(.)"
/>><xsl:text />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="text()" mode="convert">
<xsl:text/><xsl:value-of select="." /><xsl:text />
</xsl:template>
<xsl:template match="comment()" mode="convert">
<xsl:comment><xsl:value-of select="." /></xsl:comment>
</xsl:template>
</xsl:stylesheet>
Unfortunately, this produces the output :
<?xml version="1.0" encoding="UTF-8"?>
<node><child attrib="something">value</child></node>
Why am I not getting the whitepsaces in my RTF or the comments?
Thanks,
Kenneth
On 6/9/05, David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk> wrote:
How can I do this? Will I have to write an XML serializer in XSL
or is there an easier way?
Yes, if you generate a node tree in the RTF then you'll have to use
x:node-set() to get the nodes back and then use templates or an
extesnion function to serialise the tree as a string. There are several
existing templates to do this in the faq or in the archives of this list.
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--