Writing a DTD: How to achieve this children setup
Posted
by Boldewyn
on Stack Overflow
See other posts from Stack Overflow
or by Boldewyn
Published on 2010-03-03T13:13:09Z
Indexed on
2010/05/19
6:50 UTC
Read the original article
Hit count: 275
The element tasklist
may contain at most one title
and at most one description
, additionally any number (incl. 0) task
elements in any order.
The naive approach is not applicable, since the order should not matter:
<!ELEMENT tasklist (title?, description?, task*) >
Alternatively, I could explicitly name all possible options:
(title, description?, task*) |
(title, task+, description?, task*) |
(task+, title, task*, description?, task*) |
(description, title?, task*) |
(description, task+, title?, task*) |
(task+, description, task*, title?, task*) |
(task*)
but then it's quite easy to write a non-deterministic rule, and furthermore it looks like the direct path to darkest madness. Any ideas, how this could be done more elegantly?
And no, an XSD or RelaxNG is no option. I need a plain, old DTD.
© Stack Overflow or respective owner