title: Apply template on all elements and return them, XSLT
body: <p>How can I transform an XML document with XSLT such, that I read the input, apply a transformation (e.g. trim the leading and trailing whitespaces) to all elements in the document and return the XML document with its complete structure as it was?
  (see also <a href="https://stackoverflow.com/questions/13974247/how-can-i-trim-space-in-xslt-without-replacing-repating-whitespaces-by-single-on">How can I trim space in XSLT without replacing repating whitespaces by single ones?</a> for the trim-problem)</p>
  
  <p>I started with the following code for copying all elements:</p>
  
  <pre><code>&lt;xsl:template match="@* | node()"&gt;
      &lt;xsl:copy&gt;
        &lt;xsl:apply-templates select="@* | node()"/&gt;
      &lt;/xsl:copy&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>which works fine. Now I wanted to apply the transformation by adding some lines:</p>
  
  <pre><code>&lt;xsl:template match="@* | node()"&gt;
      &lt;xsl:copy&gt;
  
        &lt;xsl:apply-templates select="@* | node()"&gt;
          &lt;xsl:call-template name="string-trim"&gt;
            &lt;xsl:with-param name="string" select="@* | node()" /&gt;
          &lt;/xsl:call-template&gt;
        &lt;/xsl:apply-templates&gt;
  
      &lt;/xsl:copy&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>But it seems that it is not allowed to add a "call-template"-Tag inside a "apply-templates"-Tag.</p>
  
  <p>How can I copy the complete structure from the source-document into the target-document while applying the transformation to each element?</p>