sylvain.loiseau said:
Yes it helped. Thanks !
Sylvain
Another way to do this is by using the Tree Visitor pattern:
<xsl:stylesheet version="1.0"
xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"> <xsl

utput omit-xml-declaration="yes"/> <xsl:strip-space elements="*"/>
<xsl:template match="@* | node" name="treeVisitor">
<xsl

aram name="ptxtLength" select="0"/>
<xsl:variable name="vsubtreeLength">
<xsl:choose>
<xsl:when test="not(node)">0</xsl:when>
<xsl

therwise>
<xsl:apply-templates select="node[1]">
<xsl:with-param name="ptxtLength"
select="$ptxtLength"/>
</xsl:apply-templates>
</xsl

therwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="following-sibling::node">
<xsl:apply-templates select="following-sibling::node[1]"> <xsl:with-param name="ptxtLength" select="$ptxtLength + $vsubtreeLength * (number(.) = number(.))"/> </xsl:apply-templates> </xsl:when> <xsl

therwise> <xsl:value-of select="$vsubtreeLength"/> </xsl

therwise> </xsl:choose> </xsl:template>
<xsl:template match="node[not(node) and not(following-sibling::node)]"> <xsl

aram name="ptxtLength" select="0"/> <xsl:value-of select="$ptxtLength"/> </xsl:template>
<xsl:template match="person">
<xsl

aram name="ptxtLength" select="0"/>
<xsl:call-template name="treeVisitor">
<xsl:with-param name="ptxtLength"
select="$ptxtLength + string-length(.)"/>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>
When this transformation is applied on this source.xml:
<persons>
<person name="pt" public="false">
<password>asdf</password>
</person>
<person name="ab" public="true">xx</person>
</persons>
the wanted result is obtained:
6
Cheers,
Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,
http://fxsl.sourceforge.net/ -- the home of FXSL
Resume:
http://fxsl.sf.net/DNovatchev/Resume/Res.html