title: Convert copy-of output to string and escape XML special characters (like less than (<) and greater than (>) symbols)
body: <p>I am trying this in an XQuery (assume that doc('input:instance') does indeed return a valid XML document) which is generated using XSLT</p>
  
  <pre><code>let $a:= &lt;xsl:text&gt;"&lt;xsl:copy-of select="doc('input:instance')//A" /&gt;"&lt;/xsl:text&gt;
  let $p := &lt;xsl:text&gt;"&lt;xsl:copy-of select="doc('input:instance')//P" /&gt;"&lt;/xsl:text&gt;
  let $r := &lt;xsl:text&gt;"&lt;xsl:copy-of select="doc('input:instance')//R" /&gt;"&lt;/xsl:text&gt;
  </code></pre>
  
  <p>But I get the error: </p>
  
  <pre><code>xsl:text must not contain child elements
  </code></pre>
  
  <p>How do I retrieve XML results using the XPath in xsl:copy-of and then encode the special characters received in the result while formatting the result as string?  I would be happy to use CDATA section if that's possible (if I do that instead of xsl:text above, xsl:copy-of is not evaluated since it becomes part of CDATA section).</p>
  
  <p>Obviously I am a newcomer to XSL...</p>