title: XSLT: apply templates inside copy of the element
body: <p>I need to output copy of element with all its attributes and apply-templates on children inside.
  main problem is that attributes are unknown.</p>
  
  <p>XML:</p>
  
  <pre><code>&lt;elem attrA="a" attrB="b" ... attrN="n"&gt;
    &lt;child&gt;&lt;child&gt;
    &lt;child&gt;&lt;child&gt;
  &lt;/elem&gt;
  </code></pre>
  
  <p>I have attempted to loop over all attributes but, can't get it working.</p>
  
  <pre><code>&lt;xsl:template match="elem"&gt;
    &lt;xsl:element name="name(.)"&gt;
      &lt;xsl:for-each select="@*"&gt;
        &lt;xsl:attribute name="name()"&gt;
          &lt;xsl:value-of select="."/&gt;
        &lt;/xsl:attribute&gt;
      &lt;/xsl:for-each&gt;
      &lt;xsl:apply-templates /&gt;
    &lt;/xsl:element&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>Required output:</p>
  
  <pre><code>&lt;elem attrA="a" attrB="b" ...="" attrN="n"&gt;
    &lt;processed-child&gt;&lt;/processed-child&gt;
    &lt;processed-child&gt;&lt;/processed-child&gt;
  &lt;/elem&gt;
  </code></pre>
  
  <p>Given child template:</p>
  
  <pre><code>&lt;xsl:template match="child"&gt;
    &lt;processed-child&gt;&lt;xsl:value-of select="."/&gt;&lt;/processed-child&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>Edit:</p>
  
  <p>XSLT 1.0</p>