[Home] [By Thread] [By Date] [Recent Entries]
Yves Forkl wrote:
Using XSLT 2 with Saxon 8.8, I am trying to insert line feeds in the resulting (main) XML document, which happens to be an XSLT stylesheet. That should not stop you from using the separator-attribute of xsl:value-of. Just use an extra variable, like this: <xsl:variable name="children">
<xsl:variable name="a-and-b" as="xs:string*">
<xsl:text>a</xsl:text>
<xsl:for-each select="('b', 'c')">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="$a-and-b" separator="| " />
</xsl:variable>But that won't remove the entities from the result. Use a character-map to achieve that (note the changes to your XSLT): <xsl:stylesheet xmlns:xs = "http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:myxsl="http://www.srz.de/xmlns/yforkl/xslt/TransformAlias" exclude-result-prefixes="myxsl" version="2.0"> <xsl:namespace-alias stylesheet-prefix="myxsl" result-prefix="xsl"/> <xsl:output indent="yes" use-character-maps="literal-newlines" /> <xsl:character-map name="literal-newlines"> <xsl:output-character character="" string="
"/> </xsl:character-map> <xsl:template match="/">
<myxsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:variable name="children">
<xsl:variable name="a-and-b" as="xs:string*">
<xsl:text>a</xsl:text>
<xsl:for-each select="('b', 'c')">
<xsl:sequence select="."/>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="$a-and-b" separator="|" />
</xsl:variable>
<myxsl:template match="/">
<myxsl:apply-templates select="{$children}"/>
</myxsl:template>
</myxsl:stylesheet>
</xsl:template>
</xsl:stylesheet>This will produce the output the way you requested it. HTH, Cheers, -- Abel Braaksma
|

Cart



