这是一个定义文档的 XML 模式,其中包含包含和元素的params根元素。两种类型的元素都有一个属性。atomicParamcomplexParamname
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://companyname.org/"
xmlns:tns="http://companyname.org/"
>
<element name="params" type="tns:ParamsType"/>
<complexType name="ParamsType">
<sequence>
<element name="atomicParam" type="tns:AtomicParamType" minOccurs="0" maxOccurs="unbounded"/>
<element name="complexParam" type="tns:ComplexParamType" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>
<complexType name="ComplexParamType">
<simpleContent>
<extension base="string">
<attribute name="name" type="string" use="required"/>
</extension>
</simpleContent>
</complexType>
<complexType name="AtomicParamType">
<simpleContent>
<extension base="string">
<attribute name="name" type="string" use="required"/>
</extension>
</simpleContent>
</complexType>
</schema>
我的目标是将以下约束应用于name属性:
- 如果任何元素具有该属性的
atomicParam某个值(例如foo),则任何complexParam元素都不应具有该属性的相同值。同时,另一个atomicParam可能具有foo的name属性。 - 如果任何元素具有该属性的
complexParam某个值(例如bar),则任何atomicParam元素都不应具有该属性的相同值。同时,另一个complexParam可能具有bar的name属性。
这可能吗?