我有一个XML文档,它有以下标记:
<step id="navigation">
...
</step id="background">
<step id="content">
...
</step>
如何确保内容,背景,导航等内容的步骤仅出现在我的文档中一次?
现在我有
<xs:element name="step" maxOccurs="1">
<xs:complexType>
.....
</xs:complexType>
</xs:element>
由于
答案 0 :(得分:1)
您应该为id属性定义唯一键。像这样:
<xsd:unique name="my_id">
<xsd:selector xpath="//step"/>
<xsd:field xpath="id"/>
</xsd:unique>