OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] Embed an XML document in another XML document

[ Lists Home | Date Index | Thread Index ]

Derek Denny-Brown wrote:
 > Unfortunately, the CDATA sections solution breaks if the nested 
document also includes a CDATA section.

Enclosing CDATA sections within CDATA sections just requires breaking 
each enclosed CDEnd into two parts. Say the original document has:

<?xml version="1.0" encoding="UTF-8"?>
<foo><![CDATA[if (a<b)]]></foo>

The CDATA enclosed document is:

<body><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<foo><![CDATA[if (a<b)]]]>]><![CDATA[</foo>]]></body>

A bit tedious, like all escaping, but a program can (un)do it.

Bob Foster
http://xmlbuddy.com/

 >
 > -derek
 >
 >
 >>-----Original Message-----
 >>From: Bornholtz, Tim [mailto:Tim.Bornholtz@ed.gov]
 >>Sent: Wednesday, December 29, 2004 11:55 AM
 >>To: Jean-Noël Colin; xml-dev@lists.xml.org
 >>Subject: RE: [xml-dev] 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@oxys.be]
 >>Sent: Wednesday, December 29, 2004 5:23 AM
 >>To: xml-dev@lists.xml.org
 >>Subject: [xml-dev] 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






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS