我有这个xml(在右下方):标签<property>
可以包含任意顺序的任意混合的<action>
,<validation>
,<lov>
元素>
<!-- ... -->
<property>
<action>foo</action>
<validation>bar</validation>
<lov>baz</lov>
</property>
<property>
<action>foo1</action>
<validation>bar</validation>
<action>foo2</action>
</property>
<property>
<action>foo1</action>
<action>foo2</action>
<action>foo3</action>
</property>
现在,我正在构建一个xsd(在Eclipse中)以验证此xml,然后我想到了这一点(使用<xsd:all>
):
<!-- ... -->
<complexType name="propertyType">
<all minOccurs="0" maxOccurs="unbounded">
<element name="validation" type="tns:validationType" minOccurs="0" maxOccurs="unbounded"></element>
<element name="lov" type="tns:lovType" minOccurs="0" maxOccurs="unbounded"></element>
<element name="action" type="tns:actionType" maxOccurs="unbounded" minOccurs="0"></element>
</all>
</complexType>
BUT验证失败
<!-- ... -->
<property>
<action>foo</action>
<validation>bar</validation>
<lov>baz</lov>
</property>
<property>
<action>foo1</action>
<validation>bar</validation>
<action>foo2</action> <!-- ERROR !? -->
</property>
<property>
<action>foo1</action>
<action>foo2</action> <!-- ERROR !? -->
<action>foo3</action>
</property>
出现此错误
cvc-complex-type.2.4.a:发现无效的内容(从元素“ action”开始)。之一 '{“ http://www.example.org/dm”:验证,“ http://www.example.org/dm”:lov}'。
我在这里缺少什么?