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

Re: adding string-length values

Subject: Re: adding string-length values
From: Zeljko Rajic <Zeljko.Rajic@xxxxxxxxxx>
Date: Tue, 21 Nov 2000 14:13:24 +0100
string length prolog
Kay Michael wrote:
> 
> > <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.

Seems to be a little bit like Lisp or Prolog...

> 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.

Well, I'm using Xalan ! But if I understand it right, it should look similar to
this:

<xsl:temaple match="Para">
    <xsl:variable name="mycounter" select="$mycounter_from_parent_node +
string-length(.)">
    <xsl:if test="mycounter &lt; 1000">
	Char count: <xsl:value-of select="$mycounter"/>
        <xsl:apply-templates select="Para"/>
    <xsl:if/>
<xsl:template/>


Unfortunately I do not know how to obtain the value of $mycounter from the
parent-node (here: $mycounter_from_parent_node)!!  There are too many
possibilities (e.g. '../$mycounter') to try them all!  :(
Maybe you (or somebody else) could give or point me to a similar example ?? 
That would be great !!


-  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.