Re: sort | uniq via keys
At 03:30 PM 2/14/02, you wrote:
I am curious then as to the difference b/t the descendant, following, and following-sibling axes.
This is something that a good book can help with: no need for me to explain here. Or consult the XPath Recommendation: it's quite clear. (Find it at w3.org.)
In addition, consider the following problem. Instead of sorting and uniqing the
There are (at least) two ways to approach this. One would be to declare different keys for different levels, such as
<xsl:key name="features1" match="/*/*" use="name()"/>
which would only get you back elements directly under the document element (in your case, a and b elements) since those are the only ones it matches.
Another way is by ordering the way you traverse the tree, and using keys as you are now doing only to control the uniqueness.
(Of course, it's still going to test uniqueness relative to the entire document, not just to the level you're on; if you want the latter, you have to use different keys as above.)
The much maligned and abused <xsl:for-each> can be applied to this. From the root, for-each select="*" will get you only one level deep, select="*/*" will get you only two levels deep, and so on. (In these XPaths, the child:: axis is implicit, so e.g. */* is short for child::*/child::*, that is grandchildren.)
Again, the secret is in XPath. Check out the spec: it's not that hard.
Good luck, Wendell
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format