Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The schema....</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"&gt; &lt;xsd:element name="Segment"&gt; &lt;xsd:complexType&gt; &lt;xsd:sequence&gt; &lt;xsd:element name="Subsegment" minOccurs="1" maxOccurs="unbounded" type="SubsegmentType"/&gt; &lt;/xsd:sequence&gt; &lt;/xsd:complexType&gt; &lt;/xsd:element&gt; &lt;xsd:complexType name="SubsegmentType"&gt; &lt;xsd:simpleContent&gt; &lt;xsd:extension base="xsd:string"&gt; &lt;xsd:attribute name="target" type="xsd:string"/&gt; &lt;/xsd:extension&gt; &lt;/xsd:simpleContent&gt; &lt;/xsd:complexType&gt; &lt;/xsd:schema&gt; </code></pre> <p>And the results using xmllint....</p> <pre><code>xmllint testfile.xml --schema Subsegment.xsd &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;Segment&gt; &lt;Subsegment target="all"&gt;This is test 1&lt;/Subsegment&gt; &lt;Subsegment target="some"&gt;This is test 2&lt;/Subsegment&gt; &lt;/Segment&gt; testfile.xml validates </code></pre> <p>Let's add some errors to verify...</p> <p><strong>Using an unspecified element</strong></p> <pre><code>xmllint badtestfile.xml --schema Subsegment.xsd &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;Segment&gt; &lt;Something-Else/&gt; &lt;Subsegment target="all"&gt;This is test 1&lt;/Subsegment&gt; &lt;Subsegment target="some"&gt;This is test 2&lt;/Subsegment&gt; &lt;/Segment&gt; badtestfile.xml:3: element Something-Else: Schemas validity error : Element 'Something-Else': This element is not expected. Expected is ( Subsegment ). badtestfile.xml fails to validate </code></pre> <p><strong>Using an invalid attribute</strong></p> <pre><code>xmllint badtestfile.xml --schema Subsegment.xsd &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;Segment&gt; &lt;Subsegment mytarget="all"&gt;This is test 1&lt;/Subsegment&gt; &lt;Subsegment target="some"&gt;This is test 2&lt;/Subsegment&gt; &lt;/Segment&gt; badtestfile.xml:3: element Subsegment: Schemas validity error : Element 'Subsegment', attribute 'mytarget': The attribute 'mytarget' is not allowed. badtestfile.xml fails to validate </code></pre>
 

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