gpt4 book ai didi

xml - ID 属性在 XML 中必须是唯一的吗?

转载 作者:行者123 更新时间:2023-12-04 02:16:15 26 4
gpt4 key购买 nike

我正在为某个项目设计 XML 模式, 由于我是 XML 的新手,所以我想确定这一点。

查看此 XML 文档:

<Fathers>
<Father ID="1">
<Name>Homer</Name>
<Sons>
<Son ID="1">
<Name>Bart</Name>
</Son>
</Sons>
</Father>
</Fathers>

在嵌套标签中可以使用相同的属性名称(例如 ID )吗?此外,ID 值之间是否存在冲突?

我知道这在关系数据库中是可行的,但我不确定在 XML 中是否如此。

最佳答案

ID 属性在 XML 文档中必须是唯一的:

Validity constraint: ID

Values of type ID must match the Name production. A name mustnot appear more than once in an XML document as a value of this type;i.e., ID values must uniquely identify the elements which bear them.

关于您的另一个问题,是的,在嵌套元素中可以具有相同的属性 names,甚至是 ID

关于xml - ID 属性在 XML 中必须是唯一的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33534308/

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