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

Encapsulating an XML document within an XML element

  • To: xml-dev@l...
  • Subject: Encapsulating an XML document within an XML element
  • From: Brian Candler <B.Candler@p...>
  • Date: Fri, 9 Jul 2004 18:24:10 +0100
  • User-agent: Mutt/1.4.1i

xml element
Hello,

Is there a _standard_ way of combining or encapsulating multiple XML
documents into a single XML document?

To give an example, let's say I'd like to wrap these two documents for
storage in a single XML instance:

-------------------------------------------------------
<?xml version="1.0"?>
<!DOCTYPE example1 [ <!ELEMENT one (#PCDATA)> ]>
<one>
..</one>
-------------------------------------------------------
<?xml version="1.0"?>
<!DOCTYPE example2 [ <!ELEMENT two (#PCDATA)> ]>
<two>
..</two>
-------------------------------------------------------

So essentially what I want is this:

<docset>
  <xml:document>
    <?xml version="1.0"?>
    <!DOCTYPE example1 [ <!ELEMENT one (#PCDATA)> ]>
    <one>
    ..</one>
  </xml:document>
  <xml:document>
    <?xml version="1.0"?>
    <!DOCTYPE example2 [ <!ELEMENT two (#PCDATA)> ]>
    <two>
    ..</two>
  </xml:document>
</docset>

Except, of course, that is not XML as we know it.

So instead, I could invent my own way of encoding XML metadata in XML. Then
a legal example might be:

<ex:docset xmlns:ex="http://example.com/">
  <ex:document>
    <ex:xmldecl version="1.0">
    <ex:doctype name="example1">
      <ex:elementdecl name="one" contentspec="(#PCDATA)"/>
    </ex:doctype>
    <one>
    ..</one>
  </ex:document>
  <ex:document>
    <ex:xmldecl version="1.0">
    <ex:doctype name="example2">
      <ex:elementdecl name="two" contentspec="(#PCDATA)"/>
    </ex:doctype>
    <two>
    ..</two>
  </ex:document>
</ex:docset>

However, I'm quite concerned that (a) I don't want to reinvent the wheel,
and (b) if there is a standard way of doing this, of being interoperable.

Having standard semantics could be quite important. For example, 'ID'
attributes are defined to be unique within a document instance - so a
validating parser which understands the boundaries of an <ex:document> could
apply the uniqueness check just to the scope of an individual encapsulated
document, not to the whole aggregate document. Equally, it could understand
the <ex:doctype> declarations for the component parts, and validate each
component document separately, if so desired.

Perhaps you'll just say "this is all obsolete, use schemas instead". That's
fair enough... but I still want to be able to store and aggregate existing
XML-1.0 compliant documents whose contents I don't have control over.

Even with schemas, the <?xml...?> declaration is still recommended, isn't
it? And if I want to preserve that, I will have to encode it some other way.

Regards,

Brian.

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.