Reputation: 965
Could someone explain the difference between the following DTD statements?
<!ELEMENT all (book+, dvd+)>
and
<!ELEMENT all (book, dvd)+>
Upvotes: 0
Views: 121
Reputation: 25034
The content model (book+, dvd+) matches a sequence of elements: first, one or more book elements (that's book+
), then (that's ,
) one or more dvd elements (that's dvd+
). So the following match this content model:
<book/><dvd/>
<book/><book/><book/><dvd/>
<book/><dvd/><dvd/><dvd/><dvd/><dvd/>
<book/><book/><book/><book/><dvd/><dvd/>
etc.
The content model (book, dvd)+ matches one or more occurrences of the sequence consisting of one book followed by one dvd. So the following match it:
<book/><dvd/>
<book/><dvd/><book/><dvd/>
<book/><dvd/><book/><dvd/><book/><dvd/>
<book/><dvd/><book/><dvd/><book/><dvd/><book/><dvd/>
etc.
The difference is that in the first expression, the two + operators apply to the individual element names book and dvd; in the second, the + applies to the sequence (book, dvd) as a whole.
Note that the first example in each list is legal under both content models, and that none of the others are.
Upvotes: 1
Reputation: 11832
With 0 knowledge of dtd's:
I'd say the first one should contain at least 1 book AND 1 dvd. But may contain many books and/or dvd's.
The second one contains should contain at least 1 book OR 1 dvd. But may contain many books and/or dvd's.
Upvotes: 0