可以创建一个XML模式来对属性/元素对实施同时出现的限制吗?
<primitive-list>
<primitive name="P1">
<definition><!-- primitive specification --></definition>
</primitive>
<primitive name="P2">
<definition><!-- primitive specification --></definition>
</primitive>
<!-- other common primitives are specified here-->
<primitive-list>
<composite-list>
<composite name="C1">
<primitive ref="P1" />
<primitive ref="P2" />
<primitive>
<definition><!-- inline primitive specification --></definition>
</primitive>
</composite>
<!-- Other compisites are specified here-->
</composite-list>
模式应该暗示着:
- If a primitive element is specified inside a primitive-list element, then it should contain the name attribute and the embedded definition element, but not the ref attribute.
- If a primitive element is specified in the composite element, then it should contain either the ref attribute or the definition element. The name is allowed in neither cases.
我非常确定这是可能的,因为XML Schema中的元素元素本身的行为就像这样。因此,任何拥有这种神圣知识的人都请分享 :-)
提前感谢你。