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

Must ID attributes be unique in XML?

我正在为某个项目设计 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 must not 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