title: Get element values in xsl:variable
body: <p>Please forgive my ignorance of XSLT I'm fairly new to it.</p>
  
  <p>Using saxon xslt 2.0: I'm trying to get a single element from an xsl:variable that looks like this when applying <code>&lt;xsl:copy-of select="$type"&gt;</code>:</p>
  
  <pre><code>  &lt;type&gt;
       &lt;label&gt;Book&lt;/label&gt;
       &lt;id&gt;book&lt;/id&gt;
    &lt;/type&gt;
  </code></pre>
  
  <p>Trying to access the id element only - I've attempted:</p>
  
  <pre><code>&lt;xsl:copy-of select="$type/id"&gt;
  &lt;xsl:copy-of select="$type[2]"&gt;
  &lt;xsl:value-of select="$type/id"&gt;
  &lt;xsl:value-of select="$type[2]"&gt;
  </code></pre>
  
  <p>Also tried this and a few variants as well </p>
  
  <pre><code>&lt;xsl:value-of select="$type[name()='id']"/&gt;
  </code></pre>
  
  <p>And tried changing the data type </p>
  
  <pre><code>&lt;xsl:variable name="type" as="element"&gt; 
  </code></pre>
  
  <p>With XSLT 2.0 node-set() manipulations don't seem to apply.</p>
  
  <p>I seek a detailed description of how to properly access xsl:variable elements and would also be happy to find I'm using this all wrong there's a better way. Thank you for your insights and efforts. </p>
  
  <p>@martin-honnen
  When adding:</p>
  
  <pre><code>&lt;xsl:variable name="test1"&gt;
    &lt;type&gt;
       &lt;label&gt;Book&lt;/label&gt;
       &lt;id&gt;book&lt;/id&gt;
    &lt;/type&gt;
  &lt;/xsl:variable&gt;
  
  &lt;TEST1&gt;&lt;xsl:copy-of select="$test1/type/id"/&gt;&lt;/TEST1&gt;
  
  &lt;xsl:variable name="test2" as="element()"&gt;
    &lt;type&gt;
       &lt;label&gt;Book&lt;/label&gt;
       &lt;id&gt;book&lt;/id&gt;
    &lt;/type&gt;
  &lt;/xsl:variable&gt;
  
  &lt;TEST2&gt;&lt;xsl:copy-of select="$test2/id"/&gt;&lt;/TEST2&gt;
  </code></pre>
  
  <p>I get the result:</p>
  
  <pre><code>   &lt;TEST1/&gt;
     &lt;TEST2/&gt;
  </code></pre>