<!ELEMENT myxml (first,second,third)>
<!ELEMENT first (#PCDATA)>
<!ELEMENT second (#PCDATA)>
<!ELEMENT third (#PCDATA)>
The DTD above restricts the child element (first, second and third) to be in the same order in the XML. Is there any way that this DTD can validate to the XML in which the elements are compulsory but can appear in any order?
This is tricky when you need exactly one of each child elements. This is the only way I can think of and it’s not very pretty. It works though…
Basically I’m specifying every possible combination of exactly one
first,second, andthirdelements.Here’s an example instance.
first,second, andthirdcan be in any order, but they each must occur exactly one time.