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

Re: DTD design

  • From: "Rick Jelliffe" <ricko@a...>
  • To: <xml-dev@i...>
  • Date: Thu, 23 Dec 1999 14:33:32 +0800

variant gi schema

From: heiko.grussbach@c... <heiko.grussbach@c...>

>I have the following problem, I want to define an element E that may
>contain elements A,B,C. Order should be insignificant and A,B and C are
all
>optional. Furthermore, A,B and C may each be replaced by X.

This may be a kind of "variant GI" issue.  Most schema languages do not
support it well.  Grammar-based schema languages that do not
provide some explicit support may have their content models explode,
as you mention.

XML Schemas allows "&" at the top level, rather like SGML. But that does
not help your problem. You may find that your problem is actually one
of subclassing, in which case XML Schemas may help when they are
implemented.

In general, when you have complex problems like this, you may find
the "architecture" approach useful.  In this approach, you make up
a DTD for exactly what you want to validate:
   ( (A, (B | C) ?) | ( B, (C | A)?) | ( C, (A | B)? ))
Then you define a transformation (e.g. using XSL) to create a version
of you document which uses these structures.  One document may
have multiple architectures like this.  This is a very powerful method
of validating many structures that are unavailable to normal
validation or modeling.

If you are more interested in validation rather than modeling, then
try Schematron
http://www.ascc.net/xml/resource/schematron/schematron.html
An error browser is available free.

The appropriate pattern for your model is this:

<pattern name="Heiko's Problem">
    <rule context="E">
        <assert test="count(*) = count(A | B | C | X)"
        >The only subelements of E are A, B, C, or X.</assert>
        <assert test="count(*) = 2"
        >The element E must have 2 subelements.</assert>
        <assert test="count(A) &lt; 2"
        >The element E can only have zero or one of subelement
A</assert>
        <assert test="count(B) &lt; 2"
        >The element E can only have zero or one of subelement
B</assert>
        <assert test="count(C) &lt; 2
        >The element E can only have zero or one of subelement
C</assert>
        <assert test="count(X) &lt;= 2"
        >The element E can only have zero, one or two of subelement
X</assert>
    </rule>
</pattern>

To add a new element takes only an extra assert statement (and an update
of
the counts).  Compare this to a content model, where each new element
may double the size of the content model (depending on what constraints
you have).  Note that this is not at all a grammatical view of what you
are doing in your document: for some types of documents, the grammatical
abstraction is not helpful or appropriate.

Rick Jelliffe


xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo@i... the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo@i... the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@i...)



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-2011 All Rights Reserved.