How to read a content model

The content model describes what an XML element can contain (sometimes called the 'element content'). Sub-elements can be followed by one of the following occurrence indicators:
+ means the element must appear one or more times
? means the element can appear zero or one times
* means the element can appear zero or more times.
If none of the above follows the element name, then the element must appear once.

If the list of elements is separated by
| this means that either one of the elements on each side can appear in any order
, this means that the elements must follow each other in the order shown

Elements can be grouped together in sub-groups with parentheses ( and ), and these sub-groups can be qualified by one of the occurrence indicators or separated by one of the separators described above.

Example

(contentcode,titlegroup,edition?,namegroup?,((issn,eissn?,coden?)|(isbn))?,copyright)

This content model for contentinfo means that

Note

Unlike SGML, XML does not allow the & connector (which means that elements separated by & are mandatory and can appear in any order). This means that XML content models often have to be more loosely defined than their equivalent SGML content models.

For example, the author element in DTD 3 allows snm to be mandatory and appear in any sequence within au:

<!ELEMENT au  - - (title? & fnms? & snmprefx? & snm & degs? 
                           & ped? & roles? & linkr*)>

The equivalent name element in DTD 4 doesn't allow us to retain this, and so in order to allow any of the elements to appear in any order, this kind of rigor has been sacrificed in favour of flexibility:

<!ELEMENT name    (nametitle | forenames | surnameprefix | surname | qualifications | pedigree | 
                           roles | link | x | br)+>

This means that parsing alone is a necessary, but is no longer a sufficient part of ensuring that a DTD 4 XML file is correct. Now that the DTD 4 has been finalized, a QC tool which allows this kind of checking will be developed and made available.

Back