[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Relative path


Subject: Re: [xsl] Relative path
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Fri, 08 Sep 2006 14:35:31 +0200

Hi Giancarlo,

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.

Cheers,
Abel



Giancarlo Rossi wrote:
HI Abel ,
Sorry for the clock.

The right url is: http://www.lastminutesud.it/TEST/test_rt.xml

I test your advice <xsl:value-of select="ReturnList/Return/Id"/>

But it doesnt display any value...


Current Thread
Keywords
xml