You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Thomas Zehetbauer <th...@hostmaster.org> on 2004/03/09 23:26:53 UTC

How to output white space from xslt?

I thought that xsl:text as well as CDATA elements should preserve white
space contained within, however I had to find that only white space from
xsl:value-of makes it to the output.

<p><xsl:value-of select="'A'"/><![CDATA[ ]]><xsl:value-of select="'B'"/>
<xsl:value-of select="'C'"/><xsl:text> </xsl:text><xsl:value-of select="'D'"/>
<xsl:value-of select="'E'"/><xsl:value-of select="' '"/><xsl:value-of select="'F'"/>
<xsl:value-of select="'G'"/> <xsl:value-of select="'H'"/></p>

<p>ABCDE FGH</p>

Is this the expected and intended behaviour?

Regards
Tom



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: How to output white space from xslt?

Posted by Joerg Heinicke <jo...@gmx.de>.
On 09.03.2004 23:26, Thomas Zehetbauer wrote:

> I thought that xsl:text as well as CDATA elements should preserve white
> space contained within, however I had to find that only white space from
> xsl:value-of makes it to the output.
> 
> <p><xsl:value-of select="'A'"/><![CDATA[ ]]><xsl:value-of select="'B'"/>
> <xsl:value-of select="'C'"/><xsl:text> </xsl:text><xsl:value-of select="'D'"/>
> <xsl:value-of select="'E'"/><xsl:value-of select="' '"/><xsl:value-of select="'F'"/>
> <xsl:value-of select="'G'"/> <xsl:value-of select="'H'"/></p>
> 
> <p>ABCDE FGH</p>
> 
> Is this the expected and intended behaviour?

Indeed in stylesheets whitespace characters are reduced as much as 
possible - but only for whitespace-only text nodes, so for 'AB' and 'GH' 
  the behaviour is expected. 'EF' is working for you, so remains 'CD' - 
this I can not explain, it should work. I would expect 'C D' out of the 
above. And as I very often use this <xsl:text> </xsl:text> when I need 
whitespaces I can only say that it works in general.

For more information see http://www.w3.org/TR/xslt#strip.

Joerg

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org