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

RE: string-length of all label attributes

Subject: RE: string-length of all label attributes
From: <Jarno.Elovirta@xxxxxxxxx>
Date: Thu, 8 Jul 2004 12:58:35 +0300
xsl string length
Hi,

> I am trying to calculate the string length of all @label attributes in
> any element.
>
> When I apply string-length(//@label) in the root I only get the length
> of the first attribute. But count(//@label) works fine.

Because string-length expects a string argument and count a node-set. See the
casting rules <http://www.w3.org/TR/xpath#function-string>.

You need to write a recursive template that goes throught the nodes in the
node-set and sums the string-lengths, or if you're using XPath 2.0, then
something in the lines of sum(for $i in //@label return string-length($i)).

Cheers,

Jarno - O.T. Quartet: Hold That [expletive deleted] Down (Builds Like A Skyscraper Mix)

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.