Other modelling tips

Using the context

It is generally good practice to define as few elements as possible, and use context to help refine the meaning of elements with similar purposes. A good example of this is titles. When a book, chapter, section and table can all have a title, it is not necessary to define elements such as 'bookTitle', 'chapterTitle', 'sectionTitle' and 'tableTitle'. The context is sufficient to identify each usage, and the name 'title' can be used for all these purposes:

<book>
  <title>The Book Title</title>
  <chapter>
    <title>The First Chapter</title>
    <section>
      <title>The First Section</title>
      <table>
        <title>A Table</title>
        ...
      </table>
      ...
    </section>
    ...
  </chapter>
  ...
</book>

Headings or wrappings

It would be very natural ...

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.