xsl-list
[Top] [All Lists]

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

2007-02-27 13:08:20
Vijay wrote:

  Hi

    <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:text>#</xsl:text>
      <xsl:value-of select="translate($namevar,' ','_')"/>
      <xsl:text>_cost</xsl:text>
    </xsl:attribute>

  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.

  Regards,

--drkm



















        

        
                
___________________________________________________________________________ 
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! 
Profitez des connaissances, des opinions et des expériences des internautes sur 
Yahoo! Questions/Réponses 
http://fr.answers.yahoo.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--