Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is XSD schema:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt; &lt;xs:element name="video"&gt; &lt;xs:complexType&gt; &lt;xs:choice minOccurs="1" maxOccurs="2"&gt; &lt;xs:element ref="youtube"/&gt; &lt;xs:element ref="param" minOccurs="1" maxOccurs="unbounded"/&gt; &lt;/xs:choice&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;xs:element name="youtube"&gt; &lt;xs:complexType&gt; &lt;xs:attribute name="file" type="xs:string" use="required"/&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;xs:element name="param"&gt; &lt;xs:complexType&gt; &lt;xs:attribute name="name" type="xs:string" use="required"/&gt; &lt;xs:attribute name="value" type="xs:string" use="required"/&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:schema&gt; </code></pre> <p>Example (well-formed and valid) XML:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;video&gt; &lt;youtube file="aaa"/&gt; &lt;param name="a1" value="b1"/&gt; &lt;param name="a2" value="b2"/&gt; &lt;/video&gt; </code></pre> <p>There is one issue with above solution. <strong>xs:choice allows two youtube elements</strong>. There is <strong>xs:all</strong> element, which solve that, but unfortunately it's impossible to get param's maxOccurs more than one with it (xs:all limitation).</p> <p>In other words there is no 100% solution using XML Schema 1.0. If above is not sufficient you can use another schema language such as RELAX NG or Schematron.</p> <p>edit:</p> <p>In XML Schema 1.1 (superset of XML Schema 1.0) you can write video element as:</p> <pre><code>&lt;xs:element name="video"&gt; &lt;xs:complexType&gt; &lt;xs:all&gt; &lt;xs:element ref="youtube"/&gt; &lt;xs:element ref="param" minOccurs="0" maxOccurs="unbounded"/&gt; &lt;/xs:all&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; </code></pre>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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