|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] adding string-length values
Hi out there,
I'm currently trying to develop a stylesheet which does some special
transformation depending on the length of single elements and the accumulated
legth of all (prior) elements. The source XML documents looks something like
this:
<?xml version="1.0" encoding="UTF-8"?>
<Article>
<Title>This is the title</Title>
<Para>This is the first paragraph.</Para>
<Para>This is the second paragraph.</Para>
<Para>And this is the last parahraph.</Para>
</Article>
In my stylesheet I'd like to do something like this:
<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>
Unfortunately this does not result in what I want to do. XSL does not allow to
change the value of 'mycounter' thus giving me the length of each <Para>
element:
Number Chars: 28
Number Chars: 29
Number Chars: 31
instead of the accumulated length of all <Para> elements:
Number Chars: 28
Number Chars: 57
Number Chars: 89
I guess the solution for the problem is quite easy, but at the moment I do not
see how I could achieve the wanted result. So I hope that somebody can give me a
hint how to add up the length of certain elements (here: <Para>) !
Many thanks for any help in advance!
- Zeljko
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








