Re: Relative path
Here's a summary of your XML, and some comments:
<CommandList> <CheckRouting millis="78"> <RouterList> <Router> <GroupList> <Group> <Id>NKI56H6IKP0G1K27</Id> <OutwardList> <Outward> >>>> Outward ID needed <<<<< <Id>OSJS0EYYLYIA8CW7</Id> <Price> >>>> Price you want to sort <<<<< <Amount>93.68</Amount> </Price> </Outward> <Outward> <Id>FB9ZW0FDS0RJ0RXI</Id> <Price> <Amount>103.68</Amount> </Price> </Outward> </OutwardList> <ReturnList> <Return> >>>> Return ID needed <<<<< <Id>6BD4GM0RZ7EFPAON</Id> </Return> <Return> <Id>ZLTLT42PPT20VMM1</Id> </Return> </ReturnList> </Group> </GroupList> </Router> </RouterList> </CheckRouting> </CommandList>
This means that you were almost correct with your statement. The node <ReturnList> is outside your <OutwardList>, the latter being the scope of the for-each.You always request the first <Id> in the <ReturnList>, because you do not specify any limiting requirements. I have to make a guess that the element you want in the <ReturnList> node actually should have the same position as the element in the <OutwardList> node, counting from the List as a starting point. But that is a guess. If I remember my lessons correctly, you could do that by so:
<xsl:variable name="pos"><xsl:number /></xsl:variable> <xsl:value-of select="../../ReturnList/Return[position() = $pos]/Id" />
The number is the actual number of the traversal before sorting. In effect that stores the node position of the OutwardList items. Using that number in your ReturnList items, and comparing that against the node position of the context node (here: Return), you will retrieve the matching Return/Id values you need.
Giancarlo Rossi wrote:
HI Abel , Sorry for the clock.
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