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

Re: Re: generalized unique element

Subject: Re: Re: generalized unique element
From: scruss@xxxxxxxxxxxx
Date: Wed, 11 Sep 2002 10:58:41 -0400
Re: Re:  generalized unique element
Laura Jenkins wrote:
> 
> <xsl:key match="*" use="name(.)" name="all-nodes"/>
> ...
> <xsl:if test="count(.| key('all-nodes', name(.))[1]) = 1">
> 
> It works fine, i however do not understand what goes on 
> in the above line..
> I would be thankful if u can please explain me the
> 1.use of count in the above statement.
> 2.especially the use of key('',xx)[1] above ..

It looks like we're building up a table of occurrences for node names in the first statement, then testing to see if this is the first time we've seen that name. The sort of thing that other languages might use a hash table for, somewhere inside a loop:

$node{$name}++;
if ($node{$name} == 1) {
  # do the thing ...
}

Apologies for the potentially unclear explanation, XSLT is only just beginning to get itself around my head (definitely not the other way around).

 Stewart



 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.