title: Constructing, not selecting, XSL node set variable
body: <p>I wish to construct an XSL node set variable using a contained for-each loop. It is important that the constructed node set is the original (a selected) node set, not a copy.</p>
  
  <p>Here is a much simplified version of my problem (which could of course be solved with a select, but that's not the point of the question). I've used the &lt;name&gt; node to test that the constructed node set variable is in fact in the original tree and not a copy.</p>
  
  <p>XSL version 1.0, processor is msxsl.</p>
  
  <p>Non-working XSL:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;xsl:output method="text" encoding="iso-8859-1" omit-xml-declaration="yes" /&gt;
  
  &lt;xsl:template match="/"&gt;
  
      &lt;xsl:variable name="entries"&gt;
          &lt;xsl:for-each select="//entry"&gt;
              &lt;xsl:copy-of select="."/&gt;
          &lt;/xsl:for-each&gt;
      &lt;/xsl:variable&gt;
  
      &lt;xsl:variable name="entryNodes" select="msxsl:node-set($entries)"/&gt;
  
      &lt;xsl:for-each select="$entryNodes"&gt;
          &lt;xsl:value-of select="/root/name"/&gt;
          &lt;xsl:value-of select="."/&gt;
      &lt;/xsl:for-each&gt;
  
  &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>XML input:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;root&gt;
      &lt;name&gt;X&lt;/name&gt;
      &lt;entry&gt;1&lt;/entry&gt;
      &lt;entry&gt;2&lt;/entry&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>Wanted output:</p>
  
  <pre><code>X1X2
  </code></pre>
  
  <p>Actual output:</p>
  
  <pre><code>12
  </code></pre>
  
  <p>Of course the (or a) problem is the copy-of, but I can't work out a way around this.</p>