This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Saxon Quirk
- To: "Devlin, Kurt" <Kurt dot Devlin at westgroup dot com>
- Subject: Re: [xsl] Saxon Quirk
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Wed, 14 Feb 2001 16:27:48 +0000
- CC: "Xsl-List (E-mail)" <xsl-list at lists dot mulberrytech dot com>
- Organization: Jeni Tennison Consulting Ltd
- References: <B15A0DE524B8D111A26900805F0D6FFE058C1B9A@conesus.roc.westgroup.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi Kurt,
> I posted this on the Saxon list yesterday, but then I started to
> think that there might be a better way to generate the list that I
> wanted. Any thoughts would be greatly appreciated.
This looks like a perfect opportunity for the Muenchian Method of
finding nodes with unique properties. First, define a key that groups
the nodes that you're interested in according to the property that
groups them. In your case, the nodes are pubtag elements that have a
list attribute equal to 'yes' and the property is the value of the pub
attribute:
<xsl:key name="pubs"
match="pubtag[@list = 'yes']"
use="@pub" />
You can then use the following to get the list of all the unique pubs,
i.e. those that occur first in the list when you retrieve all the pubs
with the same name:
/publist/pubtag[@list = 'yes']
[count(.|key('pubs', @pub)[1]) = 1]
or, if you find it clearer:
/publist/pubtag[@list = 'yes']
[generate-id() = generate-id(key('pubs', @pub)[1])]
Rather than go through all that malarky, and as you're using Saxon,
you could alternatively use the saxon:distinct() extension function:
saxon:distinct(/publist/pubtag[@list = 'yes'],
saxon:expression('@pub'))
I hope that helps,
Jeni
P.S. Very disappointed to see 'pubs' meaning publications rather than
the kind I could have a drink in.
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list