Reputation: 3514
I want to validate following XML. Where a branch can have no or multiple managers and/or accountants. Their order is random. What I have tried is as follows:
<!ELEMENT branch (office, manager*, accountant*)>
But I am getting error, and I know above statement is making order strict. How can I avoid the order of manager and accountant.
The XML:
<branch name = "south">
<office>
<addr>St. 32, Downtown</addr>
</office>
<manager>
<username>
knitemorgan
</username>
</manager>
<accountant>
<username>
johnsmith
</username>
</accountant>
<manager>
<username>
jenifer
</username>
</manager>
<accountant>
<username>
fclark
</username>
</accountant>
<branch>
<branch name = "north">
<office>
<addr>St. 328, Downtown</addr>
</office>
<accountant>
<username>
rogerbentley
</username>
</accountant>
<manager>
<username>
wendymaria
</username>
</manager>
<branch>
Upvotes: 1
Views: 583
Reputation: 2554
You may not be aware that content models can have models nested within them. So something like this should work
<!ELEMENT branch (office, (manager | accountant )*) >
However, as a rule, it's poor design not to group repeating elements into a distinct container element: you will find the processing easier to manage if you do so.
<!ELEMENT branch (office, staff) >
<!ELEMENT staff (manager|accountant)*>
Upvotes: 0
Reputation: 52888
Try something like this:
<!ELEMENT branch (office,(manager|accountant)*)>
This means exactly one office
followed by zero or more manager
or accountant
.
Order doesn't matter with the manager
or accountant
because of the |
.
Upvotes: 1