Subject: Re: [xsl] Getting a distinct list of node names From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 15 Dec 2003 20:14:52 -0500 |
In fact, it's the first step in the oft-recommended Muenchian grouping technique. (De-duplicate nodes by grouping criterion, then group by the set of de-duplicated "flag-bearer" nodes.)
A common way to do this is simply to compare a node's value to other nodes (here it's the value of the node's name that you care about):
node:definition/*[not(name() = name(preceding-sibling::*))]
....which will have poor performance on a large set of nodes (but you get the idea).
You could also do
<xsl:key name="nodes-by-name" match="*" use="name()"/>
and then call for
node:definition/*[count(.|key('nodes-by-name',name())[1] = 1]
which should work better on large sets of input.
Ah, it looks like Ken has another solution....
-- North America (Washington, DC): 3-day XSLT/2-day XSL-FO 2004-02-09 Instructor-led on-site corporate, government & user group training for XSLT and XSL-FO world-wide: please contact us for the details
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) ISBN 0-13-065196-6 Definitive XSLT and XPath ISBN 0-13-140374-5 Definitive XSL-FO ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath ISBN 1-894049-11-X Practical Formatting Using XSL-FO Member of the XML Guild of Practitioners: http://XMLGuild.info Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: Getting a distinct list o, Dimitre Novatchev | Thread | [xsl] Formatting XSL-FO Based on XM, Kyle Partridge |
Re: [xsl] Getting a distinct list o, David Tolpin | Date | AW: [xsl] switching designs in xsl, Kloeck, Erwin |
Month |