Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As you show in your example above it is not allowed to have an <code>&lt;xsd:element /&gt;</code> as a direct child of <code>&lt;xsd:complexType /&gt;</code> (see <a href="http://w3schools.com/schema/el_complextype.asp" rel="nofollow noreferrer">reference at w3schools.com</a>). Considering the example from your <a href="https://stackoverflow.com/questions/12814752/how-to-write-rootless-list-in-xml">previous question</a> I think what you want to do can be achieved with a schema like this:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; &lt;xsd:element name="root"&gt; &lt;xsd:complexType&gt; &lt;xsd:sequence&gt; &lt;xsd:element name="date" type="xsd:string" /&gt; &lt;xsd:element name="responseTime" type="xsd:decimal" /&gt; &lt;xsd:element name="employee" minOccurs="0" maxOccurs="unbounded"&gt; &lt;xsd:complexType&gt; &lt;xsd:sequence&gt; &lt;xsd:element name="name" type="xsd:string" /&gt; &lt;/xsd:sequence&gt; &lt;/xsd:complexType&gt; &lt;/xsd:element&gt; &lt;/xsd:sequence&gt; &lt;/xsd:complexType&gt; &lt;/xsd:element&gt; &lt;/xsd:schema&gt; </code></pre> <p>This validates for your example code:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;root&gt; &lt;date&gt; 9:51 AM 10/10/2012 &lt;/date&gt; &lt;responseTime&gt; 1.20&lt;/responseTime&gt; &lt;employee&gt; &lt;name&gt; Mohammad&lt;/name&gt; &lt;/employee&gt; &lt;employee&gt; &lt;name&gt; Ali&lt;/name&gt; &lt;/employee&gt; &lt;employee&gt; &lt;name&gt; Mostafa&lt;/name&gt; &lt;/employee&gt; &lt;employee&gt; &lt;name&gt; Mahmoud&lt;/name&gt; &lt;/employee&gt; &lt;/root&gt; </code></pre> <p>You might want to change the type of <code>&lt;date /&gt;</code> to <code>xsd:date</code> though.</p>
 

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