Lists

Lists are just complex enough to raise a few specific issues regarding their design.

List structure

It is almost always a good idea to surround a set of elements that define list items with another element that defines the scope of the entire list:

<!ELEMENT list  (item+) >
<!ELEMENT item  (#PCDATA) >

   <list>
     <item>Item One</item>
     <item>Item Two</item>
     <item>Item Three</item>
   </list>

This approach is particularly important when using the same item elements in both numbered and non-numbered (also known as 'random', 'bulleted' or 'unnumbered') lists, as the enclosing element then specifies how the items are to be formatted:

<!ELEMENT numList    (item+) >
<!ELEMENT nonNumList (item+) >
<!ELEMENT item       (#PCDATA) >

At least two items

Some 'purists' ...

Get XML Companion, The, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.