When specifying XML formats that contain a list of items, there is often a choice of at least two distinct styles. One uses a container element for the list, the other doesn't. As an example: if specifying a document with multiple pages, one could do this:
<document>
<title>...</title>
<pages>
<page>...</page>
<page>...</page>
</pages>
</document>
Or just this:
<document>
<title>...</title>
<page>...</page>
<page>...</page>
</document>
What are the pros and cons of each approach?
Some I can think of are:
- the former allows expressing an explicit empty list (useful if the list itself is a conceptual entity)
- the former is probably slightly better for error recovery (although that shouldn't matter if XSD validation is used)
- the latter is more concise
- the latter doesn't require a distinction between adding the first element or any successive (no management of the container element)
EDIT
To clarify: I am assuming there is no meaning attached to the pages
element. There are no other elements inside, no attributes attached and it is hard to find any other name than 'pages', 'pageList' or similar for it.
EDIT 2
I found another entry about the same question. While the answer are all for the container/parent element, it seems to come down to treating the container as actual object or the assumption that it is easier to model a schema by having that extra container element (which I tend to disagree with).