Re: [xsl] Saxon Quirk

Subject: Re: [xsl] Saxon Quirk
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 14 Feb 2001 16:27:48 +0000
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

<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'],

I hope that helps,


P.S. Very disappointed to see 'pubs' meaning publications rather than
the kind I could have a drink in.

Jeni Tennison

 XSL-List info and archive:

Current Thread