title: xslt - refer to a document in xsl:element
body: <p>i want to refer to an external xml in xls in an element</p>
  
  <pre><code>&lt;xsl:element name="{document('mapping.xml', /)/mappings/column/[@id=name()]}" &gt;
  </code></pre>
  
  <p>Is this possible?</p>
  
  <p><strong>Update</strong></p>
  
  <p>mapping.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;mappings&gt;
        &lt;columns&gt;
          &lt;column id="path"&gt;path&lt;/column&gt;
        &lt;/columns&gt;
  &lt;/mappings&gt;
  </code></pre>
  
  <p>Stylesheet:  </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:dms="http://www.news.at/dms"&gt;
      &lt;xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/&gt;
  
      &lt;xsl:variable name="Mapping" select="document('mapping.xml', /)" /&gt;
  
      &lt;xsl:template match="/"&gt;
          &lt;xsl:element name="document"&gt;
              &lt;xsl:for-each select="document/*"&gt;
  
              &lt;xsl:element name=
    "{$Mapping/mappings/columns/column[@id = name(current())]}" /&gt;
  
  
                  &lt;xsl:element name="item" &gt;
  
                  &lt;xsl:attribute name="id"&gt;
                  &lt;xsl:if test="not($Mapping/mappings/columns/column[@id= name(current())])"&gt;
                      &lt;xsl:message&gt;Markup Error: no id attribute in &lt;xsl:value-of select="name(current())" /&gt;&lt;/xsl:message&gt;
                 &lt;/xsl:if&gt;        
                          &lt;xsl:value-of select="$Mapping/mappings/columns/column[@id= name(current())]" /&gt;&lt;/xsl:attribute&gt;
                      &lt;xsl:value-of select="text()" /&gt;
                  &lt;/xsl:element&gt;
              &lt;/xsl:for-each&gt;     
          &lt;/xsl:element&gt;
      &lt;/xsl:template&gt;
  
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>input.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;document&gt;
     &lt;path&gt;sdfsdfsdf&lt;/path&gt;
  &lt;/document&gt;
  </code></pre>
  
  <p>Thank you!</p>