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

Subject: Re: [xsl] isn´t this expression right pls help
From: Andreas Peter <info@xxxxxxxxxx>
Date: Wed, 27 Jun 2007 12:35:35 +0200
Quoting Florent Georges <darkman_spam@xxxxxxxx>:

Andreas Peter wrote:


<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 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(.)"/>



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

Thanks Florent! And what would it be if I use XSLT 2.0? Are there distinctive differences? As you can see I am not an expert in those transformations :-( although I am trying to learn XSL for over a month now. Damn!


Current Thread