Re: [xsl] XPath to get unique nodes based on child node attribute

Subject: Re: [xsl] XPath to get unique nodes based on child node attribute
From: "Joris Gillis" <roac@xxxxxxxxxx>
Date: Sat, 19 Feb 2005 22:50:34 +0100
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.

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

<xsl:stylesheet version="1.0" xmlns:xsl="";>
<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()]/.."/>



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

regards, -- Joris Gillis ( Ceterum censeo XML omnibus esse utendum

Current Thread