xsl-list
[Top] [All Lists]

RE: string-length of all label attributes

2004-07-08 02:58:35
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 Sucker Down (Builds Like A Skyscraper Mix)


<Prev in Thread] Current Thread [Next in Thread>