[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Saxon Quirk

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.