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

adding string-length values

Subject: adding string-length values
From: Zeljko Rajic <Zeljko.Rajic@xxxxxxxxxx>
Date: Mon, 20 Nov 2000 19:13:04 +0100
adding string
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


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.