Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I hope I understand the question correctly... inside <code>&lt;details&gt;</code>, you want to allow any element from any namespace, but if the elements are in <code>http://example.org/apples</code> (SIR I HAVE TO ASK YOU, DO YOU OWN THE EXAMPLE.ORG DOMAIN? :D), then you want to validate those.</p> <p>Easy enough.</p> <ol> <li><p>In your main schema file <code>someschema.xsd</code>, do something like:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:someschema" elementFormDefault="qualified" &gt; &lt;xs:import namespace="http://example.org/apples" schemaLocation="apples.xsd" /&gt; &lt;!-- rest of your schema here --&gt; &lt;xs:complexType name="details"&gt; &lt;xs:sequence maxOccurs="unbounded"&gt; &lt;xs:any minOccurs="0" processContents="lax" /&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:schema&gt; </code></pre></li> <li><p>create an <code>apples.xsd</code>:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.org/apples" elementFormDefault="qualified" &gt; &lt;xs:element name="color"&gt; &lt;xs:simpleType&gt; &lt;xs:restriction base="xs:string"&gt; &lt;xs:enumeration value="red" /&gt; &lt;xs:enumeration value="green" /&gt; &lt;/xs:restriction&gt; &lt;/xs:simpleType&gt; &lt;/xs:element&gt; &lt;xs:element name="cultivar"&gt; &lt;xs:simpleType&gt; &lt;xs:restriction base="xs:string"&gt; &lt;xs:enumeration value="Braeburn" /&gt; &lt;xs:enumeration value="Granny Smith" /&gt; &lt;xs:enumeration value="McIntosh" /&gt; &lt;/xs:restriction&gt; &lt;/xs:simpleType&gt; &lt;/xs:element&gt; &lt;/xs:schema&gt; </code></pre></li> <li><p>???</p></li> <li>Profit!</li> </ol> <p>The important thing is that for those foreign namespaces you do want to validate inside <code>&lt;details&gt;</code>, you need to import the corresponding schema file at the top of your schema.</p> <p>This actually leverages the fact that XML Schema is utterly retarded and not even capable of defining what the root element of your document is. Theoretically, you could alternatively also omit the <code>&lt;import&gt;</code>, and instead simply validate your document against both <code>someschema.xsd</code> and <code>apples.xsd</code> (haven't tested that though).</p>
    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. This table or related slice is empty.
    1. 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