|
Subject: RE: adding string-length values From: Kay Michael <Michael.Kay@xxxxxxx> Date: Mon, 20 Nov 2000 18:50:09 -0000 |
> <xsl:variable name="mycounter" select="0"/>
>
> <xsl:for-each select="//Para">
> <xsl:variable name="mycounter" select="$mycounter +
> string-length(.)"/>
> <p>Number Chars: <xsl:value-of select="$mycounter"/></p>
> </xsl:for-each>
You've got to stop thinking in terms of updating variables as you go along,
and thing in terms of a function.
With Saxon it's easy,
saxon:sum(preceding::text(), saxon:expression('string-length(.)');
With standard XSLT it's a bit more work: you need a recursive template that
calculates the total string-length of a node-set by finding the
strgin-length of the first node, and adding the total of the remaining
nodes, which you get by calling yourself recursively.
Mike Kay
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| adding string-length values, Zeljko Rajic | Thread | Re: adding string-length values, Zeljko Rajic |
| RE: xpath not.., Kay Michael | Date | ANN: XSLTMark 1.2.1, first comprehe, Eugene Kuznetsov |
| Month |