Instead of organizing objects in a hierarchical fashion, objects are organized in a linear way, with signs on each object to indicate its classifications.
A natural way to use mark up to classify objects is to use a container for each new type in the classification.
This can lead to problems, if processing software needs to find all of the employees, or just the salaried employees, it needs to iterate through two different lists, the managers and the workers.
Any place where data can be organized by more than one type.
Ease-of-processing can be greatly affected by the way that elements are organized. Ease-of-Authoring can also be a problem, pick one structural organization can lead to awkward groupings of elements, and the choice of structure may seem arbitrary.
The objects to be modeled can all be grouped at the same level, and the categorization can be done with attributes on the element. This allows multiple characteristics of the objects to be modeled without enforcing a possibly artificial hiearchy on the objects.
The following model can be contrasted to the sample in the
problem section, which uses a tree structure to model employees. Each employee can have two different types, whether they are Salaried or Contractors and whether they are Workers or Managers. In the tree structure, one of the types, the Worker/Manager distinction is given more importance than the Salaried/Contractor. Extra effort would be required to extract just the Salaried employees.
The sample below uses the Marketplace pattern to organize the same data into a flatter structure. In this organization both types are given equal precedence, and both types are equally easy to process.
<Person type="salaried" level="manager">
<Person type="contractor" level="manager">
<Person type="salaried" level="worker">
<Person type="contractor" level="worker">
This pattern results in a organization that can make mapping to database tables easier. The elements in the marketplace are equivalent to rows in a table, while the attributes are the columns. A more hierarchical structure can be harder to map to databases.
The Marketplace is often contained in a
See:The Microsoft whitepaper
Serializing Graphs of Data in XML
for a discussion of representing graph structure such as RDBMS tables in XML.