title: XSLT, Appending previous data to the next iteration of a for-each
body: <p>I'm in need of a particular solution to my XSLT and I've struggling to figure out how to get it to work. Right now my XML is structured like this</p>
  
  <pre><code>&lt;DataX&gt;
     &lt;DataY&gt;
         &lt;fieldy&gt;A&lt;/fieldy&gt;
         &lt;fieldx&gt;B&lt;/fieldx&gt;
         &lt;Data1&gt;
             &lt;field1&gt;1&lt;/field1&gt;
             &lt;field2&gt;2&lt;/field2&gt;
         &lt;/Data1&gt;
         &lt;Data2&gt;
             &lt;field3&gt;3&lt;/field3&gt;
             &lt;field4&gt;4&lt;/field4&gt;
         &lt;/Data2&gt;
         &lt;Data3&gt;
             &lt;field5&gt;5&lt;/field5&gt;
             &lt;field6&gt;6&lt;/field6&gt;
         &lt;/Data3&gt;
     &lt;/DataY&gt;
  &lt;/DataX&gt;
  </code></pre>
  
  <p>What I need to do is append the contents of <code>&lt;DataY&gt; &lt;field1&gt; &lt;field2&gt;</code> to every instance of the inner data fields. Without altering the original XML</p>
  
  <p>Like this</p>
  
  <pre>
  A B 1 2    A B 3 4    A B 5 6
  </pre>
  
  <p>Like so, I added spaces for clarity.</p>
  
  <p>I've tried some inner for-each statements and few other things. I've not to experience with XSLT but maybe I'm over thinking it. I'm just not sure how to obtain the A B data once a pass has been made using a for-each. Any Thoughts?   </p>