tags:

views:

18

answers:

1

I want to have list of required elements in any order defined in dtd, but have no idea how I could do this.

For example, I have following definition:

<!ELEMENT parent (child1, child2, child3)>

This dtd declaration will successfully validate following piece of xml:

<parent>
   <child1></child1>
   <child2></child2>
   <child3></child3>
</parent>

But in following case xml will not pass validation:

<parent>
   <child2></child2>
   <child1></child1>
   <child3></child3>
</parent>

One of the possible solution is to declare

<!ELEMENT parent (child1 | child2 | child3)>

But in this case one of the childs might be missing though validation will be successful.

I need correct dtd element declaration for the case when list of required elements can be present in any order.

+2  A: 

Reading the spec is would appear you can't.

When children are declared in a sequence separated by commas, the children must appear in the same sequence in the document. In a full declaration, the children must also be declared, and the children can also have children.

I think it's because you are declaring a sequence (or ordered list if you like) rather than a collection (or unordered list).

ChrisF