[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Embed an XML document in another XML document

  • To: "Bornholtz, Tim" <Tim.Bornholtz@e...>,Jean-Noël Colin <jean-noel.colin@o...>,<xml-dev@l...>
  • Subject: RE: Embed an XML document in another XML document
  • From: "Derek Denny-Brown" <derekdb@m...>
  • Date: Wed, 29 Dec 2004 12:09:00 -0800
  • Thread-index: AcTtkKbL0hUHiI9cRamRjG4YHif4PwATsmmgAACFmdA=
  • Thread-topic: Embed an XML document in another XML document

xml cdata embed
Unfortunately, the CDATA sections solution breaks if the nested document also includes a CDATA section.  The only complete solution is to encode the nested document, either as bas64, or just escape dangerous constructs.  I prefer just representing it inline, and 'escaping' the xml-decl to be something like "<?x-xml ...".  If there is a potential for a doctype decl, you are better off just using base64, as trying to escape a DTD is quite tricky.

-derek

> -----Original Message-----
> From: Bornholtz, Tim [mailto:Tim.Bornholtz@e...]
> Sent: Wednesday, December 29, 2004 11:55 AM
> To: Jean-Noël Colin; xml-dev@l...
> Subject: RE:  Embed an XML document in another XML document
> 
> If you really need to have any sort of content within your body then you
> can define the body tag to contain a CDATA section.  Then your document
> will look like this:
> 
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <message ... >
>     <messageid>123456</messageid>
>     <body><![CDATA[
>     <?xml version="1.0" encoding="UTF-8"?>
> <filter ... >
>     <and>
>     <comp><op>eq</op><field>1.3</field><value>value1</value></comp>
>     <comp><op>eq</op><field>1.2</field><value>value2</value></comp>
>     </and>
> </filter>
>     ]]></body>
> </message>
> 
> I'm sure there are a lot of other complicated ways to do this, but this is
> simple and it works.
> 
> Hope this helps,
> Tim Bornholtz
> 
> 
> -----Original Message-----
> From: Jean-Noël Colin [mailto:jean-noel.colin@o...]
> Sent: Wednesday, December 29, 2004 5:23 AM
> To: xml-dev@l...
> Subject:  Embed an XML document in another XML document
> 
> 
> Hi
> 
> I would like to create a XML Schema that would define the structure of an
> XML document that contains XML document
> 
> Typically, something like
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <message ... >
>     <messageid>123456</messageid>
>     <body>
>     <?xml version="1.0" encoding="UTF-8"?>
> <filter ... >
>     <and>
>     <comp><op>eq</op><field>1.3</field><value>value1</value></comp>
>     <comp><op>eq</op><field>1.2</field><value>value2</value></comp>
>     </and>
> </filter>
>     </body>
> </message>
> 
> I tried defining the schema like this, using different definitions for the
> body element, but I can't validate it.
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>     targetNamespace="http://voyager.oxys.be/xml/ns/MyTest-0_1"
>     xmlns="http://voyager.oxys.be/xml/ns/MyTest-0_1"
> elementFormDefault="qualified" attributeFormDefault="unqualified">
>     <xs:element name="message" type="MessageType"/>
>     <xs:complexType name="MessageType">
>         <xs:sequence>
>             <xs:element type="xs:NMTOKEN" name="messageid"/>
>             <xs:element type="xs:anyType" name="body"/>
>         </xs:sequence>
>     </xs:complexType>
> </xs:schema>
> 
> 
> The reason I need this is because I have to define a structure of a
> message
> that is able any type of body. So I can't define the type of the body
> (using
> a choice, for instance).
> 
> Any suggestion welcome,
> 
> Happy New Year
> 
> Jean-Noel Colin
> 
> 
> 
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
> 
> The list archives are at http://lists.xml.org/archives/xml-dev/
> 
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://www.oasis-open.org/mlmanage/index.php>
> 
> 
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
> 
> The list archives are at http://lists.xml.org/archives/xml-dev/
> 
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://www.oasis-open.org/mlmanage/index.php>


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.