<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.com/venue-listing">
<xs:attribute name="lang" default="en">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="en|zh" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:element name="site">
<xs:complexType>
<xs:sequence>
<xs:element name="venue">
<xs:complexType>
<xs:sequence>
<xs:element name="url" type="xs:string" />
<xs:element name="venue_nm" type="xs:string" />
<xs:element name="address" type="xs:string"/>
<xs:element name="tags">
<xs:complexType>
<xs:sequence>
开发者_运维技巧 <xs:element name="tag" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="source" type="xs:integer" use="required" />
</xs:complexType>
</xs:element>
</xs:schema>
Now the validation just saying cvc-complex-type.2.4.a: Invalid content was found starting with element 'venue'. One of '{venue}' is expected. venues.xml
<site source="21" xmlns="http://example.com/venue-listing">
<venue id="333048">
....
</venue>
<venue id="323">
....
</venue>
</site>
Per this schema, element venue must occur exactly once, hence
[Not more than] One of '{venue}' is expected.
For allowing multiple venues, use
<xs:element name="venue" maxOccurs="unbounded">
The default of maxOccurs
is 1 (see XML Schema spec).
精彩评论