异常 - 元素类型“xs:element”必须后面跟有属性规范,“>”或“/>”

问题描述:

<xs:schema attributeFormDefault="unqualified" 
     elementFormDefault="qualified" 
xmlns:xs="http://www.w3.org/2001/XMLSchema"> 

<xs:element name="company"> 
<xs:complexType> 
<xs:sequence> 
<xs:element type="xs:string" name="companyname"/> 
<xs:element type="xs:string" name="address"/> 



<xs:element name="department"maxOccurs="unbounded" minOccurs="1"> 
<xs:complexType> 
<xs:sequence> 
<xs:element type="xs:string" name="dname"/> 
<xs:element type="xs:long" name="deptphoneno"/> 
<xs:element type="xs:long" name="deptfaxno"/> 
<xs:element type="xs:string" name="deptemail"/> 


<xs:element name="employee"maxOcurrs="unbounded" minOccurs="1"> 
<xs:complexType> 
<xs:sequence> 
<xs:element type="xs:string" name="empid"/> 
<xs:element type="xs:string" name="ename"/> 
<xs:element type="xs:string" name="emailid"/> 
<xs:element type="xs:long" name="phoneno"/> 
</xs:sequence> 
</xs:complexType> 
</xs:element> 
<xs:element name="contractemployee"maxOccurs="unbounded" minOccurs="0"> 
<xs:complexType> 
<xs:sequence> 
<xs:element type="xs:string" name="name"/> 
<xs:element type="xs:long" name="phoneno"/> 
</xs:sequence> 
</xs:complexType> 
</xs:element> 
</xs:sequence> 
</xs:complexType> 
</xs:element> 
</xs:sequence> 
</xs:complexType> 
</xs:element> 
</xs:schema> 

/*它抛出一个异常 - 元素类型“xs:element”属性规范“>”或“/>”异常 - 元素类型“xs:element”必须后面跟有属性规范,“>”或“/>”

我,找不到什么是错的代码 PLZ如果有人可以重写代码没有任何错误*/

两种类型的问题存在于您的XSD:

  1. 眼前的错误是由于忽略了 属性之间添加空格:

    <xs:element name="department"maxOccurs="unbounded" minOccurs="1"> 
    

    你的XSD有两个以上这样的错误。

  2. maxOcurs拼写错误。

修复这些问题,您的XSD将在语法上正确。