I am not sure what would be a good XML structure for the following...
Assume that a field type, say <person>, can have different "flavors", e.g. either the person is a local reference defined only by some ID, or it is a global reference with various address elements associated. What would be a good XML structure for this so that it becomes easy to describe in a schema (an xsd file)?
I see two strategies - bot both with some major drawbacks:
Either the person type is defied as a separate element, say <type>, but then I guess a schema cannot tell which of the type specific fields that are mandatory:
<person>
<type>local</type>
<id>12345</id>
</person>
<person>
<type>global</type>
<name>Some Name</name>
<address>Some Street 42</address>
<city>Some City</some>
</person>
In this case <id> should only be mandatory for "local" person types, and similarly with the fields for "global" person types.
The other strategy is to define a new node type for each person sub-type, but then we cannot tell that each sub-type is in fact just a flavor of <person>:
<personLocal>
<id>12345</id>
</personLocal>
<personGlobal>
<name>Some Name</name>
<address>Some Street 42</address>
<city>Some City</some>
</personGlobal>
What is a good strategy for modeling structures like this?