Re: [xsl] Identifying unique attribute values in nested sibling elements

Subject: Re: [xsl] Identifying unique attribute values in nested sibling elements
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Thu, 29 Sep 2011 11:43:42 +0100
The answer to your question (and any other question involving elimination of duplicates) will depend greatly on whether you are using XSLT 1.0 or XSLT 2.0.

Michael Kay
Saxonica

On 29/09/2011 11:31, Mark wrote:
In processing XML similar to the fragment below, I have identified that within its <Set> element, five <Stamp> elements are of interest (because they all contain <Formats se-tenant="1">). The other possible <Stamp> elements that do not have this feature are of no interest. My problem occurs in <xsl:template match="Stamp">:

While I am in the context of the *unique* <Stamp> element that has identical values for the pofis-number and se-tenent attributes -- in this instance, the fragment's first <Stamp> element -- how can I gather all of the <Value> elements from the subsequent <Stamp> elements of interest while ignoring:
(1) <Value> elements identical to those already found, and
(2) <Value> elements in <Stamp> elements of no interest?


For the given XML fragment, I want to find these four <Value> elements and ignore the duplicated <Value> element:
Unique:
kc-value="14"
kc-value="18"
kc-value="18" h-value="50"
kc-value="0" l-value="A"


Duplicate:
kc-value="14"

Thanks,
Mark
-----------------------------
<Set>
<!--possibly other unrelated <Stamp> elements here-->
<Stamp>
<CatNumbers  pofis-number="1"/>
<Value kc-value="14"/>
<Formats se-tenant="1"/>
</Stamp>
<!--possibly other unrelated <Stamp> elements here-->
<Stamp>
<CatNumbers pofis-number="2"/>
<Value kc-value="18"/>
<Formats se-tenant="1"/>
</Stamp>
..... <!--possibly other unrelated stamp elements-->
<Stamp>
<CatNumbers pofis-number="3"/>
<Value kc-value="18" h-value="50"/>
<Formats se-tenant="1"/>
</Stamp>
<!--possibly other unrelated <Stamp> elements here-->
<Stamp>
<CatNumbers pofis-number="4"/>
<Value kc-value="14" />
<Formats se-tenant="1"/>
</Stamp>
<!--possibly other unrelated <Stamp> elements here-->
<Stamp>
<CatNumbers pofis-number="5"/>
<Value kc-value="0" l-value="A" />
<Formats se-tenant="1"/>
</Stamp>
</Set>

Current Thread