xslt, siblings

Siblings

1. matching children of siblings

1.

matching children of siblings

Mike Brown

 
 > Given the following two data structures which are both
 > siblings:
 > 
 > <APPLE>
 > <BASKET_ID>1</BASKET_ID>
 > <COLOR>red</COLOR>
 > </APPLE>
 > 
 > <ORANGE>
 > <BASKET_ID>1</BASKET_ID>
 > <COLOR>orange</COLOR>
 > </ORANGE>
 > 
 > Inside an APPLE template, how do I select the COLOR of
 > the particular ORANGE structure that has the same
 > BASKET_ID of the current APPLE?
 
 <xsl:template match="APPLE">
   <xsl:variable 
	name="AppleBasket" select="BASKET_ID"/>
   <xsl:value-of 
	select="../ORANGE[BASKET_ID=$AppleBasket]/COLOR"/>
 </xsl:template>

Read the select expression like this:

elements named COLOR that are children of elements named ORANGE that are children of nodes found in the parent axis (..). Further, the ORANGE elements are limited to the subset for which the comparison of child elements named BASKET_ID to the node-set identified by the AppleBasket variable is true. (it will be true if both node-sets have a member with the same string value) (I think).