exception-元素类型“xs:element”必须后跟属性说明“>”或“/>”

时间:2017-08-12 21:21:14

标签: xml xsd

<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”必须后跟属性规范“&gt;”或“/&gt;”

我无法找到代码的错误 如果有人可以重写代码而没有任何错误* /

1 个答案:

答案 0 :(得分:2)

XSD中存在两类问题:

  1. 立即错误是由于忽略了在两者之间添加空格 属性:

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

    您的XSD还有两个错误。

  2. maxOcurs拼写错误。
  3. 解决这些问题,您的XSD在语法上是正确的。

相关问题