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


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: DTD declaration

[ Lists Home | Date Index | Thread Index ]
  • From: Rick JELLIFFE <ricko@geotempo.com>
  • To: ",'xml-dev@lists.xml.org'" <xml-dev@lists.xml.org>
  • Date: Thu, 20 Jul 2000 13:42:50 +0800

"Raheja, Dhruv (TRANS)" wrote:
> hi,
> My question has to do with DTD syntax . I'm hoping somebody will be able to
> help me out. i have defined an element as follows:
> <!ELEMENT index (para*,num_list*,image*)>
> The above code allows me to define child elements (para,num_list,image)
> within the element "index" but only in the order in which they appear in the
> DTD syntax. 

> What should i do if i need to alter the order in some parts of
> my document e.g. i add a <num_list> after an <image> at a certain place in
> my document instead of <para>. 

At the moment, you cannot have a para after an image, so your question
is not quite right.

There are three approaches:
 1) Loose content model 
    ( para | num_list | image )*
  and that way any future funnies are also catered for. You can write in
 documentation that ( para*, num_list*, image*) is the preferred order.

 2) Tight content model, e.g.
   ( para*, (num_list, para?)*, (image, (num_list, para?)*)*)
 which traces through every possible combination (actually, you will
notice that the example above is in fact the same effect as the content
model in 1)--you would have to remove the bits you don't need.  The
trouble with this is that you get a combinatorial explosion with large
content models, and it can be difficult to read through the

 The other problem is that one is using groups (i.e., parentheses) to
model occurence constraints that perhaps are better expressed in other
ways. For example, the content model
   ( (num_list | para)*, image, (num_list |para)*)
uses groups on other elements to impose a constraint on image: that
there must be one image.

 3) Have a fairly loose content model or none, but model the other
constraints in a more appropriate schema language.
 For example, to model the same constraints in Schematron schema
   <rule context="index">
     <assert test="para | num_list | image"
     >"index" can only contain elements "para", "num_list" or
     <assert test="count(image)=1"
     >"index" must have (only) one "image" element</assert>
see http://www.ascc.net/xml/resource/schematron/schematron.html

The new XML Schemas opens up a few new possibilities too, as the next
step beyond DTDs: it reintroduces a limited form of the "&" operator
from SGML (which meant "must occur somewhere, in any order") in the
<any/> element.

Rick Jelliffe

  • References:
    • DTD declaration
      • From: "Raheja, Dhruv (TRANS)" <Dhruv.Raheja@Trans.ge.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