Search code examples
xmldtd

Occurence indicator in DTD at the start or for each element?


for a DTD is there a difference between doing this

<!DOCTYPE Book [
 <!ELEMENT Book (Author+, a, b, c)>
...
>

and

<!DOCTYPE Book [
 <!ELEMENT Book (Author, a, b, c)
 <!ELEMENT Author (#PCDATA)+>
...
>

Is there a difference? If no, Should one be used over the other? Thanks in advance


Solution

  • The most obvious difference is that the first construct is allowed by the XML syntax rules, and the second one isn't. A content model that includes #PCDATA can't include an occurrence indicator.

    If it were allowed, it would (logically) mean that one Author element can contain a sequence of text values, which would be indistinguishable from an Author element that contains a single text value. Whereas your first example allows a Book to contain multiple Author elements, which isn't the same thing at all.