当我尝试验证此 XSD 时:
<xs:group name="ValidityDateGroup">
<xs:annotation>
<xs:documentation>Reusable element group to be used where Valid From/Until needs to be captured in xs:date format</xs:documentation>
</xs:annotation>
<xs:all>
<xs:element minOccurs="0" name="ValidFrom" type="xs:date"/>
<xs:element minOccurs="0" name="ValidUntil" type="xs:date"/>
</xs:all>
</xs:group>
<xs:complexType name="NameType">
<xs:choice maxOccurs="unbounded" minOccurs="0">
<!-- SNIP - many more choices here -->
<xs:group ref="ValidityDateGroup"/> <!-- THIS IS WHERE THE ERROR IS -->
</xs:choice>
</xs:complexType>
我收到以下错误:
一个“所有”模型组必须出现在一个粒子中,且 '{'minoccurrence'}' = '{'maxoccurrence'}' = 1,并且该粒子必须是构成 '{'content type'} 的一对' 的复杂类型定义。
我能够让它作为 1.0 XSD 工作的唯一方法是将“全部”更改为“序列”:
<xs:group name="ValidityDateGroup">
<xs:annotation>
<xs:documentation>Reusable element group to be used where Valid From/Until needs to be captured in xs:date format</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element minOccurs="0" name="ValidFrom" type="xs:date"/>
<xs:element minOccurs="0" name="ValidUntil" type="xs:date"/>
</xs:sequence>
</xs:group>
但这会强制执行特定的顺序。
有谁知道如何让这个 XSD 与 XSD 1.0 一起工作?