[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Checking for unique mail adresses
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|