[Home] [By Thread] [By Date] [Recent Entries]

  • To: "Xml-Dev (E-mail)" <xml-dev@l...>
  • Subject: How to avoid the sequens of child elements in DTD, yet keep the cardinality?
  • From: Albena Georgieva <albena@i...>
  • Date: Wed, 14 Nov 2001 14:15:01 +0100

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


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member