Note that there are some explanatory texts on larger screens.

plurals
  1. POXsd recursion of complexTypes
    primarykey
    data
    text
    <p>I am just learning XML/XSD and am struggling with the implementation of an XML-schema which models a folder structure. What I had in mind was defining a complexType for the folder which can have additional folder instances that represent subfolders. Using the xsd schema validator <a href="http://www.validome.org/grammar/validate/" rel="nofollow noreferrer">here</a> always returns that the schema is invalid.</p> <p>I tried defining the complexType up front and then using the <em>ref</em> keyword for subfolders:</p> <pre><code>&lt;xs:complexType name="tFolder"&gt; &lt;xs:sequence&gt; &lt;xs:element name="Path" type="tFolderType" msdata:Ordinal="0" /&gt; &lt;xs:element ref="Folder" minOccurs="0" maxOccurs="unbounded" /&gt; &lt;xs:element name="File" nillable="true" minOccurs="0" maxOccurs="unbounded"&gt; &lt;xs:complexType&gt; &lt;xs:simpleContent msdata:ColumnName="File_Text" msdata:Ordinal="0"&gt; &lt;xs:extension base="xs:string"&gt; &lt;/xs:extension&gt; &lt;/xs:simpleContent&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:sequence&gt; &lt;xs:attribute name="Type" type="tFolderType" /&gt; </code></pre> <p></p> <p>As for the element itself:</p> <pre><code>&lt;xs:element name="Folder" type="tFolder" /&gt; </code></pre> <p>The error returned by the validator is: </p> <p><strong>"Cannot resolve the name 'Folder' to a(n) 'element declaration' component."</strong></p> <p>and the error occurs at the line </p> <pre><code>&lt;xs:element ref="Folder" minOccurs="0" maxOccurs="unbounded" /&gt; </code></pre> <p>Defining the complexType within the element itself yields the exact same error: </p> <pre><code>&lt;xs:element name="Folder"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="Path" type="tFolderType" msdata:Ordinal="0" /&gt; &lt;xs:element ref="Folder" minOccurs="0" maxOccurs="unbounded" /&gt; &lt;xs:element name="File" nillable="true" minOccurs="0" maxOccurs="unbounded"&gt; &lt;xs:complexType&gt; &lt;xs:simpleContent msdata:ColumnName="File_Text" msdata:Ordinal="0"&gt; &lt;xs:extension base="xs:string"&gt; &lt;/xs:extension&gt; &lt;/xs:simpleContent&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:sequence&gt; &lt;xs:attribute name="Type" type="tFolderType" /&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; </code></pre> <p>What I've read, this kind of recursion should work using <em>ref</em>.</p> <p>Can anyone tell me what I've done wrong? Maybe the xsd validator is just faulty? If so, does anyone know a better alternative? I've tried using the one from w3.org as well, but it seems to be taken offline...</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