Note that there are some explanatory texts on larger screens.

plurals
  1. POPrecise XSD validation rules
    primarykey
    data
    text
    <p>I have the following simple XSD schema:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xs:schema targetNamespace="http://test" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:tns="http://test" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt; &lt;xs:complexType name="AType"&gt; &lt;xs:sequence&gt; &lt;xs:element name="info" type="xs:string" /&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;xs:element name="A" type="tns:AType"/&gt; &lt;/xs:schema&gt; </code></pre> <p>Is the following simple XML document valid in relation to this schema?</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;X xsi:type="AType" xmlns="http://test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt; &lt;info&gt;text&lt;/info&gt; &lt;/X&gt; </code></pre> <p>I tried it in an on-line validator that uses JAXP and the default J2SE 1.7 parser, and the XML document validated successfully (<a href="http://www.utilities-online.info/xsdvalidation/" rel="nofollow">http://www.utilities-online.info/xsdvalidation/</a>). On the other hand, xmllint says that </p> <pre><code>Schemas validity error : Element '{http://test}X': No matching global declaration available for the validation root. test2.xml fails to validate </code></pre> <p>Are they using different validation modes? Is the mode used by the J2SE parser based on the XSD specification?</p> <p><strong>Amendment to the question:</strong></p> <p>Michael Kay points me (below) to particular locations in the XSD specification. I've tried to decipher what the XSD specification says. Do I understand correctly that:</p> <p><ol> <li>The three assessment approaches are said "primary", so that other (arbitrary) approaches are allowed?</li> <li>In (3), if there is no matching XSD definition for the root element, lax assessment should be used. But it seems that the spec doesn't exclude elements with namespace prefix from lax assessment. While then the J2SE online validatorn fails if the element in the above example is given a namespace prefix?</li> <li>Does lax validity assession apply to the root in my example above? The root has no "context-determined declaration", has it? The definition in the spec reads:</p> <blockquote> <p>...an element information item's schema validity may be <em>laxly assessed</em> if its "context-determined declaration" is not skip by "validating" with respect to the "ur-type definition"...</li> </ol> All in all, is any validation approach allowed by the XSD spec? And if so, what does it mean then for a XML document to be schema-valid?</p> </blockquote>
    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.
 

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