xsl-list
[Top] [All Lists]

Re: [xsl] Embedding XML in another XML

2018-06-26 06:50:33
On 26.06.2018 13:38, Willem Van Lishout willemvanlishout(_at_)gmail(_dot_)com 
wrote:
Hi,

I’m required to produce an XML file like this using XSLT 1.0:

<?xml version=”1.0”?>

<root>

<element>

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

   .....

   </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.
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>