0
votes

I'm new to xml schemas and doing an assignment, and I've run into a problem. I am using th tutorial from w3schools.com and a validator located at http://www.validome.org/grammar/validate/ Below is the begining of my schema, which won't validate:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <xs:element name="products">
     <xs:complexType>
       <xs:element name="product" minOccurs="1" maxOccurs="unbounded">
         <xs:complexType>
           <xs:sequence>
             <xs:element name="fname" type="xs:string"/>
             <xs:element name="manufacturer" type="xs:string"/>
           </xs:sequence>
         </xs:complexType>
       </xs:element>
    </xs:complexType>
   </xs:element>
 </xs:schema>

Validator says that there are a number of problems with line 5: 1. It says that the minOccurs and maxOccurs attributes are not allowed 2. Invalid content found starting with element 'xs:element'.

As far as i can tell, i am following the w3schools tutorial. NB: If i remove lines 3 and 4 and their corresponding end tags, and the minOccurs and maxOccurs attributes, the document validates.

Can anyone help? Thanks in advance

1

1 Answers

2
votes

xs:element cannot appear directly as a child of xs:complexType; you need to interpose an xs:sequence element. This is the message from Saxon:

Error at xs:element on line 4 column 71 of test.xsd: Element xs:element cannot appear here: expected one of {choice, sequence, assert, openContent, annotation, attributeGroup, anyAttribute, simpleContent, all, attribute, group, complexContent} or nothing