title: Processing XML inside XML text node with XSLT
body: <p>I have an XML with a text node that is also an XML. I need to transform this XML (the outer XML) with XSLT 2.0 and change a couple of things in the <em>inner</em> XML (the one in the text node). The result XML should have the same structure as the input XML (including the text node with XML), but with the changes applied on the inner XML.</p>
  
  <p>I'm using Saxon XSLT processor, so I have access to the parse() function. But I'm not sure how I can use it to process the inner XML and then convert it <em>back</em> to a text node.</p>
  
  <p>This is a sample input XML:</p>
  
  <pre><code>&lt;tag&gt;
      &lt;innerXml&gt;
           &amp;lt;node1&amp;gt;
             &amp;lt;node2&amp;gt;Value&amp;lt;/node2&amp;gt;
           &amp;lt;/node1&amp;gt;
      &lt;/innerXml&gt;
  &lt;/tag&gt;
  </code></pre>
  
  <p>And the XSLT transform would output:</p>
  
  <pre><code>&lt;tag&gt;
      &lt;innerXml&gt;
           &amp;lt;node1&amp;gt;
             &amp;lt;node2&amp;gt;Some other value&amp;lt;/node2&amp;gt;
           &amp;lt;/node1&amp;gt;
      &lt;/innerXml&gt;
  &lt;/tag&gt;
  </code></pre>
  
  <p>Note that the inner XML is much more complex than this, so a simple string replace won't work.</p>