我有下面的示例 XML,我想针对下面的架构进行验证。我收到有关 extraImages 的错误。错误是:
错误 3033:元素“{http://www.w3.org/2001/XMLSchema}sequence”:内容无效。预期是(注释?,(元素|组|选择|序列|任何)*)。
谁能看到我做错了什么?当我在单独的模式中拥有 extraImages 复杂类型时,它可以工作,但当我将它添加到产品模式时它不起作用。
<products>
<product>
<productImageURL>imgp9241.jpg</productImageURL>
<productDescription>blah blah blah</productDescription>
<productName>Test Extra</productName>
<extraImages>
<extraImages>
<fileName>textextra.jpg</fileName>
<sequence>10</sequence>
</extraImages>
<extraImages>
<fileName>textextra.jpg</fileName>
<sequence>10</sequence>
</extraImages>
</extraImages>
</product>
</products>
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="products">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="product" minOccurs = "1" maxOccurs="1" type="productType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="productType">
<xsd:sequence>
<xsd:element name="productImageURL">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="0" />
<xsd:maxLength value="450" />
<xsd:whiteSpace value="collapse" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="productDescription">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd:whiteSpace value="collapse"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="productName">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd:maxLength value="150"/>
<xsd:whiteSpace value="collapse"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="extraImages">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="extraImage" minOccurs = "1" maxOccurs="100" type="imgType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="imgType">
<xsd:sequence>
<xsd:element name="fileName">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="25"/>
<xsd:whiteSpace value="collapse"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="sequence" type="xsd:integer" default="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>