[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: counting elements with values that match other el
I'd do this using muenchian grouping: <xsl:key name="c" match="cSet/c" use="."/> ... <xsl:copy-of select="/root/t/cSet/c[generate-id(key('c',.)[2])=generate-id(.)]"/> .... which returns <c>3</c> <c>5</c> <c>8</c> <c>7</c> which seems to be the right answer as all those ar used twice I think. > mostly I'm asking for how the parser is reading the expression I > wrote, which is //root/ccc/c[ count( //root/t[ h =1 and . = cSet/c ] ) > 0 ] starting at the left //root means search the entire document to arbitrary depth looking for root elements which is quite expensive (I'd say especially as you do it twice, but I think saxon will only do it once anyway) you mean /root there. that selects all the c's under ccc but the predicate inside the following [] does not use any relative paths so it's value does not depend on the particular c element (as they are all in the same document) so this expression is a constant in the loop and may be pulled out so it's equivalent to <xsl:variable name="x" select="boolean(count( //root/t[ h =1 and . = cSet/c ] ) > 0 )]"/> select=" //root/ccc/c[$x]" which is either //root/ccc/c or eth empty node set depending on whether $x is true(). boolean(count( //root/t[ h =1 and . = cSet/c ] ) > 0 ) is true just if //root/t[ h =1 and . = cSet/c ] is non-empty in this case h is always 1 (and root is at teh top) so we can simplify to /root/t[ . = cSet/c ] which selects all t elements whose string value is equal to the string value of one of its c grandchildren. This can only be possible if that c element is the only descendent of t that has any character data, as the string value of t is all the character data from all descendents. so this will select no nodes. David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
|
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
|