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

Re: Checking for unique mail adresses

Subject: Re: Checking for unique mail adresses
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Thu, 18 Jan 2001 13:16:17 +0000
unique email
Hi Heiner,

> Actually, it looks a bit better already - I've managed to clean the
> "spam text" from the mails now. All I need to know, still, is to how 
> find out only the unique adresses.

Pretend that you're jumping from 'mail' element to 'mail' element. At
each 'mail' element, you look back across the document. If you can't
see another 'mail' element before this one that has the same value as
the one you're on, then you know you've found a new mail address and
you can write it down.  If you *can* see another 'mail' element with
the same value as this one, then you know you've already written it
down, so you can just ignore it.

Turning this into an XPath.  Jump from mail element to mail element:

  //mail

look back across the document: is there another mail element that has
the same value as this one?

  . = preceding::mail

If there isn't, then write it down:

  //mail[not(. = preceding::mail)]

So, to cycle over all the unique 'mail' elements, you can use:

<xsl:for-each select="//mail[not(. = preceding::mail)]">
   ...
</xsl:for-each>

You can also use keys to do this.  Set up a key that, given a mail
address, gives you the 'mail' elements that have that address:

<xsl:key name="addresses" match="mail" use="." />

Now, if the 'mail' element that you're on is the first in the list
returned by the key, then you can write it down: if it isn't, you can
ignore it:

  //mail[generate-id() = generate-id(key('addresses', .)[1])]

or:

  //mail[count(.|key('addresses', .)[1]) = 1]

I hope that helps,

Jeni

---
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.