RE: [xsl] How to preserve whitespace in the stylesheet?

Subject: RE: [xsl] How to preserve whitespace in the stylesheet?
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Wed, 20 Dec 2000 12:55:56 -0000
> From: Robert Nicholson [mailto:robert@xxxxxxxxxxxx]
> 
> I have the following template rule
> 
> <xsl:template name="separated-list">
> 	<xsl:param name="nodes"/>
> 	<xsl:param name="separator"/>
> 	<xsl:for-each select="$nodes">
> 		<xsl:value-of select="."/>
> 		<xsl:if test="position() != last()">
> 			<xsl:value-of select="$separator"/>
> 		</xsl:if>
> 	</xsl:for-each>
> </xsl:template>
> 
> Sometimes separator is "," and other times it's a <BR>

If the separator is a node-set containing a single <BR/> element, then
<xsl:value-of> will output nothing (the string value of an empty element).
Try using <xsl:copy-of> instead.

> also, where is it documented exactly why you cannot do
> 
> <xsl:text><BR/><xsl:text>?
> 
The fact that the <xsl:text> element can contain only #PCDATA is documented
in XSLT Appendix B. The reasons why are not documented (they never are!),
but given that the purpose of xsl:text is to output text nodes, it wouldn't
make very much sense to have anything else in there.

Mike Kay

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread