Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>@Dave is adding some dumb attribute to ChildB okay? Since your requirement on childB is 0-1 we can achieve the desired solution by adding a fixed attribute to childB and enforcing unique constraint on the attribute.</p> <pre><code>&lt;complexType name="childAType"&gt; &lt;simpleContent&gt; &lt;extension base="string"&gt;&lt;/extension&gt; &lt;/simpleContent&gt; &lt;/complexType&gt; &lt;complexType name="childBType"&gt; &lt;simpleContent&gt; &lt;extension base="string"&gt; &lt;attribute name="value" type="string" fixed="123"&gt;&lt;/attribute&gt; &lt;/extension&gt; &lt;/simpleContent&gt; &lt;/complexType&gt; &lt;element name="root"&gt; &lt;complexType&gt; &lt;choice minOccurs="0" maxOccurs="unbounded"&gt; &lt;element name="childA" type="tns:childAType" minOccurs="0" maxOccurs="unbounded"&gt;&lt;/element&gt; &lt;element name="childB" type="tns:childBType" minOccurs="0" maxOccurs="unbounded"&gt;&lt;/element&gt; &lt;/choice&gt; &lt;/complexType&gt; &lt;unique name="childB.max.once"&gt; &lt;selector xpath="./tns:childB"&gt;&lt;/selector&gt; &lt;field xpath="@value"&gt;&lt;/field&gt; &lt;/unique&gt; &lt;/element&gt; </code></pre> <p>Below is one of valid XML (order of B doesn't matter or B can be excluded)</p> <pre><code>&lt;tns:root xmlns:tns=" "&gt; &lt;tns:childA&gt;&lt;/tns:childA&gt; &lt;tns:childB&gt;&lt;/tns:childB&gt; &lt;tns:childA&gt;&lt;/tns:childA&gt; &lt;tns:childA&gt;&lt;/tns:childA&gt; &lt;/tns:root&gt; </code></pre> <p>However the below one is invalid</p> <pre><code>&lt;tns:root xmlns:tns=" "&gt; &lt;tns:childB&gt;&lt;/tns:childB&gt; &lt;tns:childA&gt;&lt;/tns:childA&gt; &lt;tns:childB&gt;&lt;/tns:childB&gt; &lt;tns:childA&gt;&lt;/tns:childA&gt; &lt;tns:childA&gt;&lt;/tns:childA&gt; &lt;/tns:root&gt; </code></pre>
    singulars
    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.
    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