Re: [xsl] Embedding XML in another XML

Subject: Re: [xsl] Embedding XML in another XML
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 26 Jun 2018 11:50:29 -0000
On 26.06.2018 13:38, Willem Van Lishout willemvanlishout@xxxxxxxxx wrote:
Hi,

Ibm required to produce an XML file like this using XSLT 1.0:

<?xml version=b1.0b?>

<root>

<element>

 B B B  &lt;?xml version="1.0" encoding="utf-16"?&gt;
 B B B B B  &lt;AXFRoot&gt;
 B B B B B B B  &lt;MAObject type="default" mdclass="EPISODE"&gt;
 B B B  B B B B B B  &lt;GUID dmname=""&gt;595233000&lt;/GUID&gt;

B .....

B </element>

</root>


So basically I have to put a string-encoded XML structure inside another XML. While I'm sure this is theoretically possible by just using <xsl:text>, this does not seem like a sustainable way of working with long and deep structures.



Is this possible without resorting to 'heavier' programming solutions?

Evan Lenz has a quite sophisticated XSLT 1.0 stylesheet to "serialize" XML to a string http://lenzconsulting.com/xml-to-string/



If XSLT 2.0 or 3.0 can offer a solution I'd also like to hear.

In XPath 2.0 you can use


  <element>
     <xsl:value-of select="unparsed-text('foo.xml')"/>
  </element>


or in XPath 3 the serialize function that Mike has already posted.


Current Thread