Note that there are some explanatory texts on larger screens.

plurals
  1. POHow would you describe this in XML/XSD?
    primarykey
    data
    text
    <p>I am not sure what would be a good XML structure for the following...</p> <p>Assume that a field type, say &lt;person&gt;, 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)?</p> <p>I see two strategies - bot both with some major drawbacks:</p> <p>Either the person type is defied as a separate element, say &lt;type&gt;, but then I guess a schema cannot tell which of the type specific fields that are mandatory:</p> <pre><code>&lt;person&gt; &lt;type&gt;local&lt;/type&gt; &lt;id&gt;12345&lt;/id&gt; &lt;/person&gt; &lt;person&gt; &lt;type&gt;global&lt;/type&gt; &lt;name&gt;Some Name&lt;/name&gt; &lt;address&gt;Some Street 42&lt;/address&gt; &lt;city&gt;Some City&lt;/some&gt; &lt;/person&gt; </code></pre> <p>In this case &lt;id&gt; should only be mandatory for "local" person types, and similarly with the fields for "global" person types.</p> <p>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 &lt;person&gt;:</p> <pre><code>&lt;personLocal&gt; &lt;id&gt;12345&lt;/id&gt; &lt;/personLocal&gt; &lt;personGlobal&gt; &lt;name&gt;Some Name&lt;/name&gt; &lt;address&gt;Some Street 42&lt;/address&gt; &lt;city&gt;Some City&lt;/some&gt; &lt;/personGlobal&gt; </code></pre> <p>What is a good strategy for modeling structures like this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload