Compound Documents - necessary for success?

Marcus Carr mrc at
Fri Jan 29 00:15:02 GMT 1999

Roger L. Costello wrote:

> >Also, what would prevent someone from putting together a compound document
> >constructed entirely of valid fragments?
> Yes, this is exactly what is desired!

Sorry, maybe I didn't make myself clear - given the following DTD:

<!DOCTYPE doc [
<!ELEMENT doc      (a?, b?, c?)>
<!ELEMENT a        (#PCDATA)>
<!ELEMENT b        (#PCDATA)>
<!ELEMENT c        (#PCDATA)>

If a user wants to create a compound document, they might do something like:

  <c xmlns="http://MyDTD">This is c</c>
  <b xmlns="http://MyDTD">This is b</b>
  <a xmlns="http://MyDTD">This is a</a>

with the elements "c", "b" and "a" being documents in their own right and
namespace. The editing application presumably allows the elements to occur
without interfering with the content model for "doc", since they're existing in
their own namespace - is this the case? If the three elements use the same DTD as
element doc (and assuming this means that they share the same namespace), then
presumably the creation of a DTD and the normalisation of the instance would
result in something like:

<!DOCTYPE me:doc [
<!ELEMENT me:doc      ((me:a?, me:b?, me:c?) | (me:c, me:b, me:a))>
<!ELEMENT me:a        (#PCDATA)>
<!ELEMENT me:b        (#PCDATA)>
<!ELEMENT me:c        (#PCDATA)>

<me:doc xmlns:me="http://MyDTD">
  <me:c xmlns:me="http://MyDTD">This is c</me:c>
  <me:b xmlns:me="http://MyDTD">This is b</me:b>
  <me:a xmlns:me="http://MyDTD">This is a</me:a>

If the three elements were to be regarded as being part of the same document as
the doc element, the processor would generate an error. If the three elements are
regarded as being documents in their own right, it would presumably not, but the
use of namespace has initiated undesireable modification of the DTD in order to
support this instance. Is this example fundamentally flawed? Was the fact that
namespaces might overlap within a document one reason that a namespaces isn't
required to resolve to a DTD or schema?

> Is it not enough to verify that the fragments are valid and that the
> document as a whole is well-formed?

No, you also want to respect the original intention of the DTD, unless a really
good reason exists not to.

> I would like to assert that an XML parser *should* be able to validate each
> document fragment against their respective DTDs.  Perhaps all the DTDs that
> are referenced by the fragments should be listed in multiple DOCTYPEs at
> the top of the document?

In this example, the issue is that all of the fragments use the same DTD, but I
still don't know if I should be creating different namespaces that (conceptually)
resolve to the same DTD.


Marcus Carr                      email:  mrc at
Allette Systems (Australia)      www:
"Everything should be made as simple as possible, but not simpler."
       - Einstein

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at
Archived as:
To (un)subscribe, mailto:majordomo at the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at

More information about the Xml-dev mailing list