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

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Encapsulating an XML document within an XML element

[ Lists Home | Date Index | Thread Index ]

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.




 

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

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