Re: [xsl] Grouping / unique list with just XPath

Subject: Re: [xsl] Grouping / unique list with just XPath
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 17 Nov 2005 23:05:34 GMT
> The problem is that I don't know the schema of the incoming files but
> they're channeled through a recursive single template, so fiddling
> around with keys to capture something that I currently trap in
> <xsl:choose /> contraptions seem a bit tricky,

I don't really understand why you can't use keys. You indicated you
could use the another suggested method

> select="$variable/member[@ref-id!=preceding-sibling::member/@ref-id]"
> This will catch the first ref-id of each value.

You need to know exactly the same information to use this method, the
element names member and the attribute name ref-id, and one form can be
mechanically converted to the other:

<xsl:key name="m" name="match" use="@ref-id"/>
...
<xsl:for-each select="$variable/member[generate-id()=generate-id(key('m',@ref-id))]">

well that selects the first member with each id, rather than just
testing for first sibling, you can add the idof the parent if you need
that.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread