xsl-list
[Top] [All Lists]

Re: [xsl] counting element characters

2008-08-11 00:43:29
Dimitre Novatchev wrote:

  Hi

<xsl:template match="a">
   <xsl:variable name="c" as="text()*">
           <xsl:for-each select="descendant::p">
              <xsl:value-of  select="string-length(.)"/>
           </xsl:for-each>
   </xsl:variable>
   <xsl:value-of select="sum($c)"/>
</xsl:template>

  Which can be spelled as following, in order to prevent creating
useless text nodes:

    <xsl:template match="a">
       <xsl:value-of select="sum(.//p/string-length(.))"/>
    </xsl:template>

  Regards,

--drkm



















      
_____________________________________________________________________________ 
Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>