Re: [xsl] xsl:attribute introducing a lot of whitespace

Subject: Re: [xsl] xsl:attribute introducing a lot of whitespace
From: Florent Georges <darkman_spam@xxxxxxxx>
Date: Tue, 27 Feb 2007 20:55:13 +0100 (CET)
Vijay wrote:


>     <xsl:attribute name="href">
>      #<xsl:value-of select="translate($namevar,' ','_')"/>_cost      
>     </xsl:attribute>

  When the stylesheet is compiled, the only-whitespace-nodes
(and only them) are ignored.  In your above example, the
xsl:attribute has three children: 1/ one text node starting
with a newline then spaces then a '#', 2/ the xsl:value-of
element and 3/ a text node starting with '_cost' then a
newline then spaces.

  Because they are not only-whitespaces-text-nodes, the text
nodes are not ignored by the XSLT processor.  You have to
solutions: 1/ correct the text nodes in your stylesheet or
2/ use xsl:text:

    <xsl:attribute name="href">#<xsl:value-of
select="translate($namevar,' ','_')"/>_cost</xsl:attribute>

    <xsl:attribute name="href">
      <xsl:value-of select="translate($namevar,' ','_')"/>

  The use of xsl:text let you keep a correctly indented
code.  Personnally, I *always* use xsl:text when I want to
generate a text node (except maybe in literal elements).
That helps to avoid such errors.




Dicouvrez une nouvelle fagon d'obtenir des riponses ` toutes vos questions ! 
Profitez des connaissances, des opinions et des expiriences des internautes sur Yahoo! Questions/Riponses

Current Thread