Note that there are some explanatory texts on larger screens.

plurals
  1. POxs:choice unbounded list
    primarykey
    data
    text
    <p>I want to define an XSD schema for an XML document, example below:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;view xmlns="http://localhost/model_data" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://localhost/model_data XMLSchemaView.xsd" path="wibble" id="wibble"&gt; &lt;text name="PageTitle"&gt;Homepage&lt;/text&gt; &lt;text name="Keywords"&gt;home foo bar&lt;/text&gt; &lt;image name="MainImage"&gt; &lt;description&gt;lolem ipsum&lt;/description&gt; &lt;title&gt;i haz it&lt;/title&gt; &lt;url&gt;/images/main-image.jpg&lt;/url&gt; &lt;type&gt;image/jpeg&lt;/type&gt; &lt;alt&gt;alt text for image&lt;/alt&gt; &lt;width&gt;400&lt;/width&gt; &lt;height&gt;300&lt;/height&gt; &lt;/image&gt; &lt;link name="TermsAndConditionsLink"&gt; &lt;url&gt;/tnc.html&lt;/url&gt; &lt;title&gt;Terms and Conditions&lt;/title&gt; &lt;target&gt;_blank&lt;/target&gt; &lt;/link&gt; &lt;/view&gt; </code></pre> <p>There's a view root element and then an unknown number of field elements (of various types). I'm using the following XSD schema:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://localhost/model_data" targetNamespace="http://localhost/model_data" id="XMLSchema1"&gt; &lt;xs:element name="view" type="model_data"/&gt; &lt;xs:complexType name="model_data"&gt; &lt;xs:choice maxOccurs="unbounded"&gt; &lt;xs:element name="text" type="text_field"/&gt; &lt;xs:element name="image" type="image_field"/&gt; &lt;xs:element name="link" type="link_field"/&gt; &lt;/xs:choice&gt; &lt;xs:attribute name="path" type="xs:string"/&gt; &lt;xs:attribute name="id" type="xs:string"/&gt; &lt;/xs:complexType&gt; &lt;xs:complexType name="image_field"&gt; &lt;xs:all&gt; &lt;xs:element name="description" type="xs:string"/&gt; &lt;xs:element name="title" type="xs:string"/&gt; &lt;xs:element name="type" type="xs:string"/&gt; &lt;xs:element name="url" type="xs:string"/&gt; &lt;xs:element name="alt" type="xs:string"/&gt; &lt;xs:element name="height" type="xs:int"/&gt; &lt;xs:element name="width" type="xs:int"/&gt; &lt;/xs:all&gt; &lt;xs:attribute name="name" type="xs:string"/&gt; &lt;/xs:complexType&gt; &lt;xs:complexType name="text_field"&gt; &lt;xs:simpleContent&gt; &lt;xs:extension base="xs:string"&gt; &lt;xs:attribute name="name" type="xs:string"/&gt; &lt;/xs:extension&gt; &lt;/xs:simpleContent&gt; &lt;/xs:complexType&gt; &lt;xs:complexType name="link_field"&gt; &lt;xs:all&gt; &lt;xs:element name="target" type="xs:string"/&gt; &lt;xs:element name="title" type="xs:string"/&gt; &lt;xs:element name="url" type="xs:string"/&gt; &lt;/xs:all&gt; &lt;xs:attribute name="name" type="xs:string"/&gt; &lt;/xs:complexType&gt; &lt;/xs:schema&gt; </code></pre> <p>This looks like it should work to me, but it doesn't and I always get the following error:</p> <pre><code>Element &lt;text&gt; is not allowed under element &lt;view&gt;. Reason: The following elements are expected at this location (see below) &lt;text&gt; &lt;image&gt; &lt;link&gt; Error location: view / text Details cvc-model-group: Element &lt;text&gt; unexpected by type 'model_data' of element &lt;view&gt;. cvc-elt.5.2.1: The element &lt;view&gt; is not valid with respect to the actual type definition 'model_data'. </code></pre> <p>I've never really used XSD schemas before, so I'd really appreciate it if someone could point out where I'm going wrong.</p>
    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.
    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