You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Klaus Malorny <Kl...@knipp.de> on 2001/03/01 14:27:36 UTC

Whitespace, was: Number of last child

Erwin Burgstaller wrote:
> 
> 
> BTW: Is there a possibility to write <xsl:attribute> with white spaces
> inside, without getting them into the html-code?
> 
> Erwin
> 

You should take a look at the general whitespace handling of an XSLT
processor. Once understood, it is quite easy:

By default*, text nodes containing only whitespace are removed from the XSL
stylesheet. On the other hand, text nodes containing other characters are not
modified in any way, i.e. there is no whitespace compression (multiple spaces,
tabs, returns etc. to a single space) and no removal of spaces at the
beginning or end of the text.

so
  <xsl:attribute ...>
    <xsl:value-of ...>
  </xsl:attribute>

does not produce any whitespaces in the attribute, since both text nodes
before and after the <xsl:value-of> contain only whitespace. In contrast

  <xsl:attribute ...>
     4711
  </xsl:attribute>

will produce whitespace. To keep your stylesheet neatly indented, you could
use <xsl:text>:

  <xsl:attribute ...>
    <xsl:text>4711</xsl:<text>
  </xsl:attribute>

In the worst case, you could use the normalize-space () function.

Hope that helps.

Klaus




* not text contained inside <xsl:text>