xsl-list
[Top] [All Lists]

Re: [xsl] isn´t this expression right pls help

2007-06-27 03:28:48
Andreas Peter wrote:

  Hi

<xsl:variable name="count_p_s" select="string-length(//section/p)"/>

My problem is that I just get the value of the first <p>-element
and  not an addition of the rest.

  If you are using XSLT 1.0 that's the way it is supposed to work.  To
get the total of all p, use a recursive template instead:

    <xsl:template match="/">
      <xsl:apply-templates select="<path to the *first* p>">
    </xsl:template>

    <xsl:template match="p" mode="count-chars">
      <xsl:param name="count" select="0"/>
      <xsl:apply-templates select="<path to the next p>">
        <xsl:with-param name="count" select="
            $count + string-length(.)"/>
      </xsl:apply-templates>
    </xsl:template>

  Regards,

--drkm





















      
_____________________________________________________________________________ 
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail 

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