Note that there are some explanatory texts on larger screens.

plurals
  1. POXML Schema Children With the Same Element
    primarykey
    data
    text
    <p>I am trying to write an XML schema for a server that accepts images. The images should either all have a mask or none should. </p> <p>I would like to produce an XML like this:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;FIVR&gt; &lt;meal&gt; &lt;media&gt; &lt;image2D filename="filename1"&gt; &lt;mask filename="filename1" /&gt; &lt;/image2D&gt; &lt;image2D filename="filename2"&gt; &lt;mask filename="filename1" /&gt; &lt;/image2D&gt; &lt;image2D filename="filename3"&gt; &lt;mask filename="filename1" /&gt; &lt;/image2D&gt; &lt;image2D filename="filename4"&gt; &lt;mask filename="filename1" /&gt; &lt;/image2D&gt; &lt;image2D filename="filename5"&gt; &lt;mask filename="filename1" /&gt; &lt;/image2D&gt; &lt;/media&gt; &lt;/meal&gt; &lt;/FIVR&gt; </code></pre> <p>or </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;FIVR&gt; &lt;meal&gt; &lt;media&gt; &lt;image2D filename="filename1"&gt; &lt;/image2D&gt; &lt;image2D filename="filename2"&gt; &lt;/image2D&gt; &lt;image2D filename="filename3"&gt; &lt;/image2D&gt; &lt;image2D filename="filename4"&gt; &lt;/image2D&gt; &lt;image2D filename="filename5"&gt; &lt;/image2D&gt; &lt;/media&gt; &lt;/meal&gt; &lt;/FIVR&gt; </code></pre> <p>But if some image2D elements have a mask child element but others dont, validation should fail. E.g the following should be rejected:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;FIVR&gt; &lt;meal&gt; &lt;media&gt; &lt;image2D filename="filename1"&gt; &lt;/image2D&gt; &lt;image2D filename="filename2"&gt; &lt;mask filename="filename1" /&gt; &lt;/image2D&gt; &lt;image2D filename="filename3"&gt; &lt;mask filename="filename1" /&gt; &lt;/image2D&gt; &lt;image2D filename="filename4"&gt; &lt;/image2D&gt; &lt;image2D filename="filename5"&gt; &lt;/image2D&gt; &lt;/media&gt; &lt;/meal&gt; &lt;/FIVR&gt; </code></pre> <p>Can I express this using an XSD schema?</p> <p>The schema I have right now looks like this:</p> <pre><code>&lt;xs:element name="FIVR"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="meal" minOccurs="1" maxOccurs="1"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="media" minOccurs="1" maxOccurs="1"&gt; &lt;xs:complexType&gt; &lt;xs:choice&gt; &lt;xs:element name="image2D" minOccurs="5" maxOccurs="5" &gt; &lt;xs:complexType&gt; &lt;xs:all minOccurs="0"&gt; &lt;xs:element name="mask"&gt; &lt;xs:complexType&gt; &lt;xs:attribute name="filename" type="xs:string" use="required"/&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:all&gt; &lt;xs:attribute name="filename" type="xs:string" use="required"/&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:choice&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; </code></pre> <p></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