[XSL-LIST Mailing List Archive Home]
RE: [xsl] getting the text nodes from a set of attribute nodes
Subject: RE: [xsl] getting the text nodes from a set of attribute nodes|
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Thu, 4 Sep 2003 19:16:29 +0100
> <b attr="w1 w3 w6">...</b>
> <b attr="w2 w12 w3 w7">...</b>
> ... more <b>s here ...
> when processing an <a> element, i need to calculate the
> maximum number of whitespace-separated words for any
> "b/@attr" attribute. so just what you see above, the value
> would be 4, based on that second <b> child of <a>.
> AFAICT, this will involve three steps:
> 1) collect the "b/@attr" attributes (easy)
> 2) normalize space and word count each of those attribute values
> (again, easy, stealing from kay, p. 527, the "word-count"
> template :-)
> 3) finding the maximum of those values
You can count the words without recursive processing:
$x := normalize-space(@attr)
$y := translate(@attr, ' ', '')
$wc := string-length($x) - string-length($y) +1
> since, as i understand it, you can't have a node-set of just
Since numbers aren't nodes, how could you have a node-set containing
In XPath 2.0 of course you can have sequences of strings or numbers
which makes this kind of thing very much easier.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list