Re: [xsl] intersection puzzle

Subject: Re: [xsl] intersection puzzle
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 6 Apr 2005 10:50:19 +0100
Your post is unclear as to whetjer you are trying to find teh
intersection based on node identity ie find thoe nodes that are in both
node sets or to find those nodes in one node set have the same value for
some definition of value) as some other node in a different node set.

  <xsl:variable name = "intersection" select ="$polo[count(. | $marco) = 
  count($marco )] " />
  This is successful, but I don't see a good way to manipulate the 
  individual attributes (again, to add 1 to a value to find nodes with 
  neighboring values).

This is based on node identity, so you are testing if the _same_ node
appears in each set, not just whether nodes with the same values appear.


  <xsl:variable name = "intersection" select = "$polo/square[ @h 
  =$marco/square/@h and @v = $marco/square/@v ] " />

This is a completely different beast it is comparing values: you want to
count two nodes as the same if they have the same h and v attributes.
It doesn't work as you are selecting different  $marco/square elements
within the predicate.  I don't think you can do this test with a single
XPath1 expression.


  <xsl:variable name = "intersection" select = "$polo/square[@h = 
  $marco/square/@h + 1 and @v = $marco/square/@v ] " />
  that code doesn't behave anything like the example it is based on.

@h = $marco/square/@h 
is a test of node-set = node set
so is true if any node in the first set has teh same string value as any
node in the second.

@h = $marco/square/@h +1

is a test of node-set = number so is true if the string value of the
first (only in this case) node in @h, after being coerced to a number is
equal to the number.

the number in question is the numerical value of $marco/square/@h +1
which is obtained by adding 1 to the numerical value of
$marco/square/@h whenever a node-set is used in a numeric or string
context the string value of the first node in document order is used,
and the other nodes are discarded.

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
________________________________________________________________________

Current Thread