|
Subject: Re: [xsl] Putting a line feed into XML output (XSLT 2.0) From: Abel Braaksma <abel.online@xxxxxxxxx> Date: Mon, 16 Apr 2007 16:09:57 +0200 |
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.
This proved to be not as trivial as I thought it would be, due to the fact that the line feed characters are meant to increase the readability of a complex pattern which makes up the value of an XSLT attribute. (Additionally, the pattern is composed using a for-each loop and is held in a variable.)
My real stylesheet is rather complex, but I managed to derive from it a simplified minimal stylesheet that illustrates the problem I face:
<snip />
Now my question is:
How can I manage to create a real line feed in the given situation, i.e. when the select attribute's value is taken from a variable, whose value results from walking through a sequence of strings?
I know about the separator attribute of xsl:value-of, but unfortunately, at this place I can not do without the xsl:for loop as it also cares for other things in my real stylesheet. For some reason, the variable must be declared before the myxsl:template starts, too.
<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> <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>Cheers, -- Abel Braaksma
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Putting a line feed into XML , Yves Forkl | Thread | [xsl] XSLT Dead?, Karl Stubsjoen |
| Re: [xsl] check the type of the $pa, bryan rasmussen | Date | Re: [xsl] check the type of the $pa, Abel Braaksma |
| Month |