我的问题是定义一个xml模式,该模式将验证以下示例xml:
<rules>
<other>...</other>
<bool>...</bool>
<other>...</other>
<string>...</string>
<other>...</other>
</rules>
子节点的顺序无关紧要。子节点的基数为0..unbounded。
的所有子元素
rules
节点有一个公共的基类型,
rule
,像这样:
<xs:complexType name="booleanRule">
<xs:complexContent>
<xs:extension base="rule">
...
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="stringFilterRule">
<xs:complexContent>
<xs:extension base="filterRule">
...
</xs:extension>
</xs:complexContent>
</xs:complexType>
我当前试图为
规则
节点在下面。然而,
-
我可以筑巢吗?
xs:choice
在内部
xs:sequence
?如果,我在哪里指定
maxOccurs="unbounded"
属性?
-
有没有更好的方法,比如
序列:
哪个只指定其子元素的基类型?
<xs:element name="rules">
<xs:complexType>
<xs:sequence>
<xs:choice>
<xs:element name="bool" type="booleanRule" />
<xs:element name="string" type="stringRule" />
<xs:element name="other" type="someOtherRule" />
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>