title: Output escaped xml in an attribute in an xslt
body: <p>Input xml:</p>
  
  <pre><code>&lt;Parent&gt;
      &lt;Child attr="thing"&gt;stuff&lt;/Child&gt;
  &lt;/Parent&gt;
  </code></pre>
  
  <p>xslt:</p>
  
  <pre><code>&lt;xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
      &lt;xsl:template match="Child"&gt;
          &lt;newChild chars="{..}" /&gt;
      &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Desired otuput:</p>
  
  <pre><code>&lt;newChild chars="&amp;lt;Child attr=&amp;quot;thing&amp;quot;&amp;gt;stuff&amp;lt;/Child&amp;gt;" /&gt;
  </code></pre>
  
  <p>Note that the value of the 'chars' attribute is just the escaped version of the 'Child' tag.</p>
  
  <p>Problem: how do I get the currently matched element in to the attribute? I though that <code>..</code> would normally do it, but seems not to when talking about attributes, I just get some random xml entities followed by the value of the Child tag e.g. <code>&lt;newChild chars="&amp;#xA;    stuff&amp;#xA;"/&gt;</code>. I'm expecting there might need to be some escaping stuff to make it valid.</p>
  
  <p>Any suggestions appreciated.</p>
  
  <p>(and before everyone asks why I'd want to do something like this, I'm constrained by the api of the application I'm connecting to)</p>