我想知道是否可以区分 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 对我来说更有吸引力。