Home > Back-end >  Occurence indicator in DTD at the start or for each element?
Occurence indicator in DTD at the start or for each element?

Time:03-11

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

CodePudding user response:

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.

  • Related