title: Choose When & For Each
body: <p>New to the site and xsl so be patient.   Not sure how this post will come out and I'll probably need to upload the actual XML/XSL.   </p>
  
  <p>I have an XML with two basic groups.  1 for Gas, 1 for Electric.   Its setup like:</p>
  
  <pre><code>   &lt;TS_810&gt;
        &lt;Group_6&gt;
          &lt;IT1&gt;
            &lt;IT107&gt;ELECTRIC&lt;/IT107&gt;
          &lt;/IT1&gt;
          &lt;GROUP_9&gt;
             +&lt;SLN&gt;
              &lt;SAC&gt;
                &lt;SAC01&gt;DETAILS&lt;/SAC01&gt;
                &lt;SAC02&gt;DETAILS2&lt;/SAC02&gt;
              &lt;/SAC&gt;
           &lt;/GROUP_9&gt;
           &lt;GROUP_9&gt;
             +&lt;SLN&gt;
              &lt;SAC&gt;
                &lt;SAC01&gt;DETAILS&lt;/SAC01&gt;
                &lt;SAC02&gt;DETAILS2&lt;/SAC02&gt;
              &lt;/SAC&gt;
           &lt;/GROUP_9&gt;
         &lt;/GROUP_6&gt;
         &lt;Group_6&gt;
          &lt;IT1&gt;
            &lt;IT107&gt;GAS&lt;/IT107&gt;
          &lt;/IT1&gt;
          &lt;GROUP_9&gt;
             +&lt;SLN&gt;
              &lt;SAC&gt;
                &lt;SAC01&gt;DETAILS&lt;/SAC01&gt;
                &lt;SAC02&gt;DETAILS2&lt;/SAC02&gt;
              &lt;/SAC&gt;
           &lt;/GROUP_9&gt;
           &lt;GROUP_9&gt;
             +&lt;SLN&gt;
              &lt;SAC&gt;
                &lt;SAC01&gt;DETAILS&lt;/SAC01&gt;
                &lt;SAC02&gt;DETAILS2&lt;/SAC02&gt;
              &lt;/SAC&gt;
           &lt;/GROUP_9&gt;
         &lt;/GROUP_6&gt;
  </code></pre>
  
  <p>I am trying to identify the IT107 section for Electric in GROUP_6, then select each GROUP_9 detail line for it.   Once done, then I want to select the IT107 section for Gas in the next GROUP_6 and then select all the detail lines in its related GROUP_9 sections.</p>
  
  <p>The xsl code I have is doing the following.  Note it is not all the code, just the choose/when/for each section.</p>
  
  <pre><code>    &lt;xsl: choose&gt;
         &lt;xsl:when tes="GROUP_6/IT1/IT107 = 'ELECTRIC'"&gt;
            &lt;xsl:for-each select="GROUP_6/GROUP_9/SAC"&gt;
  
           &lt;fo:table-row&gt;
             &lt;xsl:value-of select="SAC01"/&gt;
           &lt;/fo:table-row&gt;
  </code></pre>
  
  <p>What is happening is that I get the detail lines for Electric but I also get the gas section Group_6/Group_9 detail lines.  The Choose group loop doesnt seem to select just the GROUP_6 electric section.   </p>
  
  <p>Is there a way to select Group_6/Group_9 lines for ELECTRIC only?  Then I'll create another Choose to select the Group_6/Group_9 lines for GAS.</p>
  
  <p>Or is there a way to look back to value of the IT107 section before selecting the SAC01 details?</p>
  
  <p>Any thoughts?   make any sense?</p>