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

Re: XPath to get unique nodes based on child node att

Subject: Re: XPath to get unique nodes based on child node attribute
From: "Joris Gillis" <roac@xxxxxxxxxx>
Date: Sat, 19 Feb 2005 22:50:34 +0100
xpath select unique nodes
Tempore 16:52:30, die 02/19/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit david <david@xxxxxxxxxx>:

I am trying to get a node set where a child element of each node should have a unique value. I think I can do this with XPath, but can't figure out what how to filter it.
Hi,

The most common way to filter out unique nodes is with keys.
Try something like this:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>


<xsl:key name="description" match="*[@QText='Analysis Description:']" use="."/>

<xsl:template match="/">
<xsl:copy-of select="//*[generate-id(key('description',.))=generate-id()]/.."/>
</xsl:template>


</xsl:stylesheet>

outputs:

<SS_Analysis>
<Q_2676_2_Analysis_Descri QText="Analysis Description:">2,3,7,8-TCDD</Q_2676_2_Analysis_Descri>
</SS_Analysis>
<SS_Analysis>
<Q_2676_2_Analysis_Descri QText="Analysis Description:">601/602 Volatiles</Q_2676_2_Analysis_Descri>
</SS_Analysis>
<GW_Analysis>
<Q_3692_2_Analysis_Descri QText="Analysis Description:">2(2-Butoxyethoxy)ethanol</Q_3692_2_Analysis_Descri>
</GW_Analysis>
<DW_Analysis>
<Q_5066_2_Analysis_Descri QText="Analysis Description:">507 Pesticides</Q_5066_2_Analysis_Descri>
</DW_Analysis>



regards, -- Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041) Ceterum censeo XML omnibus esse utendum

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.