cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Klaus Malorny <Klaus.Malo...@knipp.de>
Subject Whitespace, was: Number of last child
Date Thu, 01 Mar 2001 13:27:36 GMT
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>

Mime
View raw message