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 の方が少し魅力的です。