Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The global declaration of the <code>title</code> attribute puts that attribute in the target namespace <code>urn:test</code>. That also means that you must qualify the reference to the attribute, both in the schema and in the instance document. By default, unqualified attributes have no namespace.</p> <pre><code>&lt;xs:schema targetNamespace="urn:test" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns="urn:test" xmlns:test="urn:test" &gt; .... &lt;xs:complexType name="ContentType"&gt; &lt;xs:simpleContent&gt; &lt;xs:extension base="xs:string"&gt; &lt;xs:attribute ref="test:title" use="required" /&gt; &lt;/xs:extension&gt; &lt;/xs:simpleContent&gt; &lt;/xs:complexType&gt; &lt;xs:attribute name="title" type="xs:string" /&gt; </code></pre> <p>and</p> <pre><code>&lt;root xmlns="urn:test" xmlns:test="urn:test" &gt; &lt;content test:title="Title"&gt; Content comes here... &lt;/content&gt; &lt;/root&gt; </code></pre> <p>This whole thing is quite subtle and when I try to validate the original instance document in ecplise I get two very confusing errors:</p> <ol> <li>The <code>title</code> attribute <em>cannot</em> appear on the content element. This refers to the unqualified use of the attribute, and</li> <li>The <code>title</code> element <em>must</em> appear on the content element. This refers to the missing qualified <code>test:title</code> attribute.</li> </ol> <p>Granted, the error message could use a bit more context information.</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