xpath uniq,find uniq elements from list,sorting from uniq c, xml%%%xpath uniq - Re: sort

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

Re: sort | uniq via keys

Subject: Re: sort | uniq via keys
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 14 Feb 2002 19:03:48 -0500
xpath uniq
Hi Saverio,

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
element names of `all' nodes in the input tree, I'd like to extract
the names of elements residing at the same `level' in the input tree, assuming a
balanced input tree.

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


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================


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.