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


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: Does DTD validation work with namespaces?

[ Lists Home | Date Index | Thread Index ]
  • From: Wayne Steele <xmlmaster@hotmail.com>
  • To: tpassin@home.com, xml-dev@lists.xml.org
  • Date: Wed, 09 Aug 2000 11:36:15 -0700 (PDT)

I think you are mistaken.
The kind of mixing of DTDs that you're discussing is perfectly legal and 
acceptable with XML 1.0.

If I declare
   <!ELEMENT foo (#PCDATA)* >
   <!ELEMENT FooList ( foo )+ >

   There is _NO_ constraint that foo elements only appear inside FooList 

   I could quite legally have <!DOCTYPE foo ... > in my document.
   I could also have an internal subset, that declares
      <!ELEMENT FooBarList ( foo | bar )* >
   and then mix foo elements side-by-side with bar elements.

This is not just theoretical - this is how large complex vocabularies are 
constructed with DTDs. I could have several different DTDs from several 
different sources, and write my own DTD to slurp them in like this:

   <!ENTITY % dtd1 SYSTEM "dtd1" >
   <!ENTITY % dtd2 SYSTEM "dtd2" >

As long as names don't clash, there should be no problem.
If something in dtd1 had a content model on "ANY", I can now take any 
element I choose from dtd1 or dtd2, and stick it in there.

DTD Validation is intended to allow documents to specify the model and 
constraints they adhere to, not to force documents to conform to some 
outside spec.

   1. Validation only works top-down, starting with the declared DOCTYPE.
   2. XML Documents can always override or add their DTDs with an internal 
   3. A DTD cannot specify what the "root" or Document Element, or "DOCTYPE" 
should be. An XML document can declare itself to be any element that is 
defined in the DTD.

-Wayne Steele

>From: tpassin@home.com
>To: Amy Lewis <amyzing@talsever.com>, xml-dev@lists.xml.org
>Subject: Re: Does DTD validation work with namespaces?
>Date: Wed, 09 Aug 2000 09:19:03 -0400
>Yes, what would it mean for the included elements to be "valid'?  For
>instance, suppose I use an xxx:p element from my namespace
>xmlns:xxx='urn:tp:my_own_bookformat'.  If I simply insert the xxx:p element
>in some foreign document, it wouldn't have been valid in the
>my_own_bookformat system because a <p> has to be in a <section> that has to
>be in a <chapter>.
>To have a valid chunck of foreign xml, then, I would have to import
>Even then it wouldn't really validate against the original DTD - even if 
>DTD used the prefix 'xxx' - because there is no top-level element <book> as
>called for in the DTD.
>So what would it mean for the included stuff to be valid?
>Presumably, it would mean "If this fragment had been embedded in a valid
>structure according to its own DTD, this fragment would not cause the whole
>structure to be invalid."
>This sounds like a tall order for a processor to understand, and also a 
>order to describe in a DTD.  It's funny, though, isn't it? All us humans
>know pretty well what it would mean:  e.g., if we put in an <html:h2>
>element, we want a processor to display an h2 heading at that point **as
>if** it were an html document.  It's the formal aspect that's tough.
>Maybe this is what should happen when a foreign xml structure is included,
>if you are validating.  The processor locates the DTD of the inclusion, but
>builds its syntax starting, not at the start of the DTD, but at the 
>elements(s).  Thus, larger contexts would be thrown away, and only those
>declarations in-scope for the elements of interest would be retained in the
>final syntax.  While we're doing this, we might as well have the DTD
>processor implicitly add on the new prefix(s).
>This approach would not have to change the specification for DTD syntax.  
>would change the specification of DTD processing.  However, you still
>wouldn't be able to mix and match at will, since an xxx:p element wouldn't
>necessarily be able to contain an svg element, for example (because this
>woudn't have been allowed under the original xxx DTD).
>Tom Passin
>Amy Lewis wrote -
> > On Wed, Aug 09, 2000 at 07:41:05AM -0400, Norman Walsh wrote:
> > >/ James Robertson <jamesr@steptwo.com.au> was heard to say:
> > >| Isn't the issue that namespaces allow you
> > >| to mix information from a number of sources,
> > >| however you see fit? Every document can have
> > >| different elements, and yet still be considered
> > >| OK according to well-formed and namespace rules ...
> > >|
> > >| How do we handle _this_ behaviour, and still
> > >| make some use of DTDs?
> > >
> > >The only way that I'd consider such a document valid is if the (set of)
> > >DTDs in question all referred to each other. I would expect the content
> > >models of each DTD to specifically allow the mixtures. For example,
> > >a DocBook+MathML DTD might allow:
> > >
> > >  <!ELEMENT equation (alt?, (graphic+|mediaobject+|mml:math+))>
> > >
> > >But to say that you can mix them "willy nilly" violates the principals
> > >of validity at their core.
> >
> > Oh, yuck!  (to use the technical term)
> >
> > A treatise combining elements of mathematics, chemistry, with
> > illustrations and bibliographic information can't be written?
> >
> > SVG, at least, is intended for inclusions, rather than for the creation
> > of standalone documents; is this inclusion only via XInclude/XLink?
> >

Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com


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

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