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

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [xml-dev] How to avoid the sequens of child elements in DTD, yet keep the cardinality?



Actually we have the technology - we can build this:

<!ELEMENT Header  ((Identification,((Weight,((Category+,Keywords+) |
(Keywords+,
               Category+))) | (Category+,((Weight,Keywords+) |
(Keywords+,Weight?))) | (
               Keywords+,((Category+,Weight?) | (Weight,Category+))))) |
(Weight,((
               Identification,((Category+,Keywords+) |
(Keywords+,Category+))) | (
               Category+,((Identification,Keywords+) |
(Keywords+,Identification))) | (
               Keywords+,((Category+,Identification) |
(Identification,Category+))))) | (
               Category+,((Weight,((Identification,Keywords+) | (Keywords+,
               Identification))) | (Identification,((Weight,Keywords+) |
(Keywords+,
               Weight?))) | (Keywords+,((Identification,Weight?) | (Weight,
               Identification))))) |
(Keywords+,((Identification,((Category+,Weight?) | (
               Weight,Category+))) | (Category+,((Identification,Weight?) |
(Weight,
               Identification))) | (Weight,((Category+,Identification) | (
               Identification,Category+)))))) >

Which looks pretty intimidating as far as a model goes.

However, it is really pretty simple. You basically enumerate all the
possible ways you could enter the data.  Given a choice of 4 objects you get
4! ways = 24 pathways.

From an authors point of view though,  this is pretty simple - having chosen
one of the  4 objects - then you must decide on one of the remaining 3
objects to enter - having chosen that one - you then get to choose one the
remaining two - and having chosen that one - the last one is given.  The
authoring interface is really quite slick.

This is one time you don't want to concentrate on "optimization" of DTD
code - you want to make the authoring straight forward.

Generating this turned out to be pretty simple since I was using Near & Far
Designer to build the model using a graphical interface. The biggest problem
I had was avoiding ambiguities.

Cheers...Hugh
CyberSpace Industries 2000 Inc.
XML Consulting and Training

-----Original Message-----
From: Dharmesh Shah [mailto:dharmesh@telocity.com]
Sent: Thursday, November 22, 2001 10:45 PM
To: Albena Georgieva; Xml-Dev (E-mail)
Subject: RE: [xml-dev] How to avoid the sequens of child elements in
DTD, yet keep the cardinality?


Albena,

When the order is not important you can do like this
<!ELEMENT header (Identification | Weight | Category | Keyword )* >

or
<!ELEMENT header Identification, ( Weight | Category | Keyword )* >

but in your case, since there restrictions on the no of occurrences you the
order has to be specified. I don't think there is any other way out.
<!ELEMENT header (Identification, Weight?, Category+, Keyword* )>

Regards,

Dharmesh

-----Original Message-----
From: Albena Georgieva [mailto:albena@info.nl]
Sent: Wednesday, November 14, 2001 5:15 AM
To: Xml-Dev (E-mail)
Subject: [xml-dev] How to avoid the sequens of child elements in DTD,
yet keep the cardinality?


Hi there,

I am creating a DTD document and I have difficulty to express
that the element type Header:

1. must have one and only one child element of type Indentification
2. Can have [0 ... 1] Weight children elements
3. Must have at least one Category child element
4. Can have [0 ... n] Keywords
5. The order of the different children is not important
6. If there are several children of the same type, then they should be
following each other

Good example:
<Header>
   <Keyword>Navratilova</Keyword>
   <Keyword>Tennis</Keyword>
   <Identification id="1111"/>
   <Category>Sports</Category>
</Header>
Another good example:
<Header>
   <Category>Sports</Category>
   <Keyword>Navratilova</Keyword>
   <Keyword>Tennis</Keyword>
   <Identification id="1111"/>
   <Weight priority="3"/>

</Header>

Not accepted example
<Header>
   <Category>Sports</Category>
   <Keyword>Navratilova</Keyword>
   <Identification id="1111"/>
   <Keyword>Tennis</Keyword>
   <Weight priority="3"/>
</Header>

I tried as follows:

<!ELEMENT header (Identification| Weight? | Category+ | Keyword* )+>
But then also this example becomes valid which is not what I am aiming to:

<Header>
   <Category>Sports</Category>
   <Keyword>Navratilova</Keyword>
   <Keyword>Tennis</Keyword>
   <Identification id="1111"/>
   <Weight priority="3"/>
   <Category>Sports</Category>
   <Identification id="2222"/>

</Header>

And if I say so:
<!ELEMENT header (Identification, Weight?, Category+, Keyword* )>

It is better, but then we have to comply to the sequence of the children,
which is what I want to avoid ...
Any ideas, help please?

I wish you all a very nice day!
Greeting,
Albena Georgieva


-----------------------------------------------------------------
The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
initiative of OASIS <http://www.oasis-open.org>

The list archives are at http://lists.xml.org/archives/xml-dev/

To subscribe or unsubscribe from this list use the subscription
manager: <http://lists.xml.org/ob/adm.pl>



-----------------------------------------------------------------
The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
initiative of OASIS <http://www.oasis-open.org>

The list archives are at http://lists.xml.org/archives/xml-dev/

To subscribe or unsubscribe from this list use the subscription
manager: <http://lists.xml.org/ob/adm.pl>