title: XSLT: move from one context to other context nodes inside for-each
body: <p>I am writing an XSL transformation where I am not able to move to root and access other nodes inside for each.</p>
  
  <p>Suppose I am inside the one context. I have a situation where I have to go to the outer node to get a value from there and return back to the same context. </p>
  
  <p>Here is my XML file.</p>
  
  <pre><code>    &lt;xml version=1.0&gt;
  
      &lt;abc&gt;
       &lt;parts&gt;
              &lt;part pno="10506"&gt;
                &lt;pname&gt;Land Before Time I&lt;/pname&gt;
                &lt;qoh&gt;200&lt;/qoh&gt;
                &lt;price&gt;19.99&lt;/price&gt;
                &lt;level&gt;20&lt;/level&gt;
              &lt;/part&gt;
              …
        &lt;/parts&gt;
         &lt;orders&gt;
              &lt;order ono="1022" takenBy="1001" customer="2222"&gt;
                &lt;receivedDate&gt;1995-02-13&lt;/receivedDate&gt;
                &lt;shippedDate&gt;1995-02-20&lt;/shippedDate&gt;
                &lt;items&gt;
                  &lt;item&gt;
                    &lt;partNumber&gt;10601&lt;/partNumber&gt;
                    &lt;quantity&gt;1&lt;/quantity&gt;
                  &lt;/item&gt;
                  &lt;item&gt;
                    &lt;partNumber&gt;10701&lt;/partNumber&gt;
                    &lt;quantity&gt;1&lt;/quantity&gt;
                  &lt;/item&gt;
                &lt;/items&gt;
           &lt;/order&gt;
  
       .....
       &lt;/orders&gt;
      &lt;/abc&gt;
  </code></pre>
  
  <p>I am iterating inside the "item" tag  in xsl:for-each but I want to go inside the "part" tag and take a value and return back to the same context.</p>
  
  <p>To be more detailed: I am filling up a table. My table has 4 columns:</p>
  
  <ul>
  <li>partname: I have to go to <code>&lt;part&gt;</code> to get the name. (This is where I got stuck)</li>
  <li>quantity : It's not a problem for me because it's a subelement of <code>&lt;item&gt;</code>.</li>
  <li>price: I face the same problem.</li>
  <li>total: It's easy.</li>
  </ul>
  
  <p>Please help me in getting values for partname and price from the parts tag.</p>
  
  <p>The following code is not working for me.</p>
  
  <pre><code>  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
      &lt;xsl:stylesheet&gt;
  
          &lt;table&gt;
               &lt;xsl:param name="param1" /&gt;
  
               &lt;xsl:variable name="temp" select ="name(/*)"/&gt;
                 &lt;xsl:for-each select=".//order[@ono=$param1]/items/item"&gt;
                       &lt;tr&gt;
            &lt;td&gt; &lt;xsl:value-of select="$temp//part[@pno=partNumber]/pname"/&gt;  &lt;/td&gt;
            &lt;td&gt; &lt;xsl:value-of select="quantity"/&gt; &lt;/td&gt;                                                       
            &lt;td&gt; &lt;xsl:value-of select="$temp//part[@pno=partNumber]/price"/&gt;  &lt;/td&gt;
            &lt;td&gt; &lt;xsl:value-of select="quantity*$temp//part[@pno=partNumber]/price"/&gt;  &lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/xsl:for-each&gt;
             &lt;/table&gt;      
  
  
  
  
      &lt;xsl:stylesheet&gt;
  </code></pre>
  
  <p>I tried googling but I couldn't get an exact solution for my problem. The code that I wrote throws some error. I tried by changing the select value of "temp" to root(.) but it's not working.</p>
  
  <p>I just need a hint. I don't need the answer. Just a hint is enough for me. </p>
  
  <p>I got stuck in this problem for the past 5 hours. Please reply and help me.</p>