This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: How to preserve whitespace in the stylesheet?


> From: Robert Nicholson [mailto:robert@elastica.com]
> 
> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]