Hi All!
I'm relatively new to XML and was busy writing a schema.
When I try to validate this, however, I get a problem, namely:
Error: Invalid content found starting with element 'xs:element'. One of '{" " " " " " " " " " is expected.
Attribute 'ref' is not permitted to appear in element 'xs:element'.
Attribute 'minOccurs' is not permitted to appear in element 'xs:element'.
Attribute 'maxOccurs' is not permitted to appear in element 'xs:element'.
Attribute 'name' must appear on element 'xs:element'.
Error Position:
<xs:element ref="author" minOccurs="1" maxOccurs="unbounded"/>
I don't understand what is wrong with my xml, since an example I found on the web ( DOES work, with practically the same code... Also, I don't understand this errormessage, why are 'ref', 'minOccurs' and 'maxOccurs' not permitted?
Thanks a lot for your help!
M
XML-code:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="
<!-- definition of simple type elements -->
<xs:element name="title" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="year" type="xs:integer"/>
<xs:element name="volume" type="xs:integer"/>
<xs:element name="number" type="xs:integer"/>
<xs:element name="part" type="xs:integer"/>
<!-- definition of attributes -->
<xs:attribute name="from" type="xs:integer"/>
<xs:attribute name="to" type="xs:integer"/>
<xs:attribute name="name" type="xs:string"/>
<!-- definition of complex type elements -->
<xs:element name="author">
<xs:complexType>
<xs:attribute ref="name"/>
</xs:complexType>
</xs:element>
<xs:element name="editor">
<xs:complexType>
<xs:attribute ref="name"/>
</xs:complexType>
</xs:element>
<xs:element name="page">
<xs:complexType>
<xs:attribute ref="name"/>
<xs:attribute ref="to"/>
</xs:complexType>
</xs:element>
<xs:element name="authors">
<xs:complexType>
<xs:element ref="author" minOccurs="1" maxOccurs="unbounded"/>
</xs:complexType>
</xs:element>
<xs:element name="editors">
<xs:complexType>
<xs:element ref="editor" minOccurs="1" maxOccurs="unbounded"/>
</xs:complexType>
</xs:element>
<xs:element name="publisher">
<xs:complexType>
<xs:sequence>
<xs:element ref="city" minOccurs="1" maxOccurs="1"/>
<xs:element ref="name" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="book">
<xs:complexType>
<xs:sequence>
<xs:element ref="authors" minOccurs="1" maxOccurs="unbounded"/>
<xs:element ref="year" minOccurs="0" maxOccurs="1"/>
<xs:element ref="title" minOccurs="1" maxOccurs="1"/>
<xs:element ref="publisher" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="journal">
<xs:complexType>
<xs:sequence>
<xs:element ref="title" minOccurs="1" maxOccurs="1"/>
<xs:element ref="volume" minOccurs="1" maxOccurs="1"/>
<xs:element ref="number" minOccurs="0" maxOccurs="1"/>
<xs:element ref="part" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="journalentry">
<xs:complexType>
<xs:sequence>
<xs:element ref="authors" minOccurs="1" maxOccurs="unbounded"/>
<xs:element ref="year" minOccurs="1" maxOccurs="1"/>
<xs:element ref="title" minOccurs="1" maxOccurs="1"/>
<xs:element ref="editors" minOccurs="0" maxOccurs="1"/>
<xs:element ref="journal" minOccurs="1" maxOccurs="1"/>
<xs:element ref="page" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="proceeding">
<xs:complexType>
<xs:sequence>
<xs:element ref="authors" minOccurs="1" maxOccurs="unbounded"/>
<xs:element ref="year" minOccurs="1" maxOccurs="1"/>
<xs:element ref="title" minOccurs="1" maxOccurs="1"/>
<xs:element ref="editors" minOccurs="0" maxOccurs="1"/>
<xs:element ref="journal" minOccurs="1" maxOccurs="1"/>
<xs:element ref="page" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="chapter">
<xs:complexType>
<xs:sequence>
<xs:element ref="authors" minOccurs="1" maxOccurs="unbounded"/>
<xs:element ref="year" minOccurs="1" maxOccurs="1"/>
<xs:element ref="title" minOccurs="1" maxOccurs="1"/>
<xs:element ref="book" minOccurs="1" maxOccurs="1"/>
<xs:element ref="page" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="books">
<xs:complexType>
<xs:element ref="book" minOccurs="0" maxOccurs="unbounded"/>
</xs:complexType>
</xs:element>
<xs:element name="journals">
<xs:complexType>
<xs:element ref="journalentry" minOccurs="0" maxOccurs="unbounded"/>
</xs:complexType>
</xs:element>
<xs:element name="chaptersAndProceedings">
<xs:complexType>
<xs:element ref="proceeding" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="chapter" minOccurs="0" maxOccurs="unbounded"/>
</xs:complexType>
</xs:element>
<xs:element name="references">
<xs:complexType>
<xs:sequence>
<xs:element ref="books"/>
<xs:element ref="journals" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="chaptersAndProceedings"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
I'm relatively new to XML and was busy writing a schema.
When I try to validate this, however, I get a problem, namely:
Error: Invalid content found starting with element 'xs:element'. One of '{" " " " " " " " " " is expected.
Attribute 'ref' is not permitted to appear in element 'xs:element'.
Attribute 'minOccurs' is not permitted to appear in element 'xs:element'.
Attribute 'maxOccurs' is not permitted to appear in element 'xs:element'.
Attribute 'name' must appear on element 'xs:element'.
Error Position:
<xs:element ref="author" minOccurs="1" maxOccurs="unbounded"/>
I don't understand what is wrong with my xml, since an example I found on the web ( DOES work, with practically the same code... Also, I don't understand this errormessage, why are 'ref', 'minOccurs' and 'maxOccurs' not permitted?
Thanks a lot for your help!
M
XML-code:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="
<!-- definition of simple type elements -->
<xs:element name="title" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="year" type="xs:integer"/>
<xs:element name="volume" type="xs:integer"/>
<xs:element name="number" type="xs:integer"/>
<xs:element name="part" type="xs:integer"/>
<!-- definition of attributes -->
<xs:attribute name="from" type="xs:integer"/>
<xs:attribute name="to" type="xs:integer"/>
<xs:attribute name="name" type="xs:string"/>
<!-- definition of complex type elements -->
<xs:element name="author">
<xs:complexType>
<xs:attribute ref="name"/>
</xs:complexType>
</xs:element>
<xs:element name="editor">
<xs:complexType>
<xs:attribute ref="name"/>
</xs:complexType>
</xs:element>
<xs:element name="page">
<xs:complexType>
<xs:attribute ref="name"/>
<xs:attribute ref="to"/>
</xs:complexType>
</xs:element>
<xs:element name="authors">
<xs:complexType>
<xs:element ref="author" minOccurs="1" maxOccurs="unbounded"/>
</xs:complexType>
</xs:element>
<xs:element name="editors">
<xs:complexType>
<xs:element ref="editor" minOccurs="1" maxOccurs="unbounded"/>
</xs:complexType>
</xs:element>
<xs:element name="publisher">
<xs:complexType>
<xs:sequence>
<xs:element ref="city" minOccurs="1" maxOccurs="1"/>
<xs:element ref="name" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="book">
<xs:complexType>
<xs:sequence>
<xs:element ref="authors" minOccurs="1" maxOccurs="unbounded"/>
<xs:element ref="year" minOccurs="0" maxOccurs="1"/>
<xs:element ref="title" minOccurs="1" maxOccurs="1"/>
<xs:element ref="publisher" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="journal">
<xs:complexType>
<xs:sequence>
<xs:element ref="title" minOccurs="1" maxOccurs="1"/>
<xs:element ref="volume" minOccurs="1" maxOccurs="1"/>
<xs:element ref="number" minOccurs="0" maxOccurs="1"/>
<xs:element ref="part" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="journalentry">
<xs:complexType>
<xs:sequence>
<xs:element ref="authors" minOccurs="1" maxOccurs="unbounded"/>
<xs:element ref="year" minOccurs="1" maxOccurs="1"/>
<xs:element ref="title" minOccurs="1" maxOccurs="1"/>
<xs:element ref="editors" minOccurs="0" maxOccurs="1"/>
<xs:element ref="journal" minOccurs="1" maxOccurs="1"/>
<xs:element ref="page" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="proceeding">
<xs:complexType>
<xs:sequence>
<xs:element ref="authors" minOccurs="1" maxOccurs="unbounded"/>
<xs:element ref="year" minOccurs="1" maxOccurs="1"/>
<xs:element ref="title" minOccurs="1" maxOccurs="1"/>
<xs:element ref="editors" minOccurs="0" maxOccurs="1"/>
<xs:element ref="journal" minOccurs="1" maxOccurs="1"/>
<xs:element ref="page" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="chapter">
<xs:complexType>
<xs:sequence>
<xs:element ref="authors" minOccurs="1" maxOccurs="unbounded"/>
<xs:element ref="year" minOccurs="1" maxOccurs="1"/>
<xs:element ref="title" minOccurs="1" maxOccurs="1"/>
<xs:element ref="book" minOccurs="1" maxOccurs="1"/>
<xs:element ref="page" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="books">
<xs:complexType>
<xs:element ref="book" minOccurs="0" maxOccurs="unbounded"/>
</xs:complexType>
</xs:element>
<xs:element name="journals">
<xs:complexType>
<xs:element ref="journalentry" minOccurs="0" maxOccurs="unbounded"/>
</xs:complexType>
</xs:element>
<xs:element name="chaptersAndProceedings">
<xs:complexType>
<xs:element ref="proceeding" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="chapter" minOccurs="0" maxOccurs="unbounded"/>
</xs:complexType>
</xs:element>
<xs:element name="references">
<xs:complexType>
<xs:sequence>
<xs:element ref="books"/>
<xs:element ref="journals" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="chaptersAndProceedings"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>