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

Re: DTD declaration

  • From: Rick JELLIFFE <ricko@g...>
  • To: ",'xml-dev@l...'" <xml-dev@l...>
  • Date: Thu, 20 Jul 2000 13:42:50 +0800

dtd declaration example
"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
your
 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
implications.  

 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
language
   <rule context="index">
     <assert test="para | num_list | image"
     >"index" can only contain elements "para", "num_list" or
"image"</assert>
     <assert test="count(image)=1"
     >"index" must have (only) one "image" element</assert>
   </rule>
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:

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.