Note that there are some explanatory texts on larger screens.

plurals
  1. POXSD: Different maxOccurs for specific substitute
    primarykey
    data
    text
    <p>I have a simple XML structure that looks as follows</p> <pre class="lang-xml prettyprint-override"><code>... &lt;param&gt; &lt;name&gt;foo&lt;/name&gt; &lt;type1&gt; Some complex content &lt;/type1&gt; &lt;/param&gt; &lt;param&gt; &lt;name&gt;bar&lt;/name&gt; &lt;type2&gt; Some complex content &lt;/type2&gt; &lt;/param&gt; ... </code></pre> <p>The schema I use looks like this</p> <pre class="lang-xml prettyprint-override"><code>... &lt;xs:complexType name="par"&gt; &lt;xs:sequence&gt; &lt;xs:element name="name" type="xs:string"/&gt; &lt;xs:element ref="typeSpecific"/&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;xs:element name="typeSpecific" abstract="true"/&gt; &lt;xs:element name="type1" type="t1" substitutionGroup="typeSpecific"/&gt; &lt;xs:element name="type2" type="t2" substitutionGroup="typeSpecific"/&gt; ... </code></pre> <p>I want to extend this so that if I use type1 in a param, I can only have one such element, but if I use type2 I can have many, like this:</p> <pre class="lang-xml prettyprint-override"><code>... &lt;param&gt; &lt;name&gt;bar&lt;/name&gt; &lt;type2&gt; Some complex content &lt;/type2&gt; ... &lt;type2&gt; Some other complex content &lt;/type2&gt; &lt;/param&gt; </code></pre> <p>I want to avoid wrapping the <code>type2</code> elements in a container because of compatibility issues. My first impulse was to use a <code>maxOccurs="unbounded"</code> attribute <code>&lt;xs:element name="type2" type="t2" substitutionGroup="typeSpecific" maxOccurs="unbounded"/&gt;</code>, but this is not allowed.</p> <p>Is there any way to enforce this restriction with XSD using my current structure? Can I in some way use <code>&lt;xs:choice&gt;</code> instead of substitution to achieve 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.
    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