[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: isn´t this expression right pls help

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

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




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!

Andreas

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.