gpt4 book ai didi

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

转载 作者:数据小太阳 更新时间:2023-10-29 02:42:17 25 4
gpt4 key购买 nike

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

最佳答案

不,我不认为这是可能的。 http://www.w3.org/TR/xmlschema-2/#IDhttp://www.w3.org/TR/xmlschema-2/#IDREF假设 ID 和 IDREF 属性类型来自 XML 标准,并且 http://www.w3.org/TR/2000/WD-xml-2e-20000814#NT-TokenizedType表示对 IDREF 的有效性约束仅匹配文档中的某些 ID。我猜 ID 和 IDREF 大部分都在 XML 模式中,以便与 DTD 向后兼容。

关于xml - 在 XML 模式 (XSD) 中引用多个 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7254933/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com