在XML模式(XSD)中引用多个ID

在XML模式(XSD)中引用多个ID,xml,namespaces,xsd,schema,validating,Xml,Namespaces,Xsd,Schema,Validating,我想知道是否有可能区分XML模式中的ID字段。我有以下模式: <element name="define_apple"> <complexType> <attribute name="colour" type="ID"/> </complexType> </element> <element name="define_orange"> <complexType>

我想知道是否有可能区分XML模式中的ID字段。我有以下模式:

<element name="define_apple">
    <complexType>
        <attribute name="colour" type="ID"/>
    </complexType>
</element>

<element name="define_orange">
    <complexType>
        <attribute name="colour" type="ID"/>
    </complexType>
</element>

<element name="reference_apple">
    <complexType>
        <attribute name="colour" type="IDREF"/>
    </complexType>
</element>

<element name="reference_orange">
    <complexType>
        <attribute name="colour" type="IDREF"/>
    </complexType>
</element>

然而,参考文献与各自的定义之间并不是唯一的联系。我仍然可以编写以下无意义但有效的XML:

<define_apple colour="green"/>
<define_orange colour="orange"/>

<reference_apple colour="orange"/>
<reference_orange colour="green"/>


是否有一种方法可以使用ID和IDREF(例如使用名称空间)正确链接字段?我知道我可以只使用key和keyref,但是ID对我来说更有吸引力。

不,我认为这是不可能的。假设ID和IDREF属性类型来自XML标准,并且IDREF上的有效性约束只匹配文档中的某个ID。我猜ID和IDREF主要是在XML模式中,以便与dtd向后兼容