Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有以下 XML:
<root> <element source="source1" target="target1" /> <element source="source2" target="target2" /> <root>
是否可以编写一个 XSD 来检查每个元素的源和目标是否不同?两个不同的元素可以指定相同的源或相同的目标,但特定元素的源和目标不能相同。
我需要使用 XSD 1.0,所以我不能使用断言。
我会xs:unique在 XSD 1.0 和 XSD 1.1 中使用它。就像是:
xs:unique
<xs:unique name="uniqueSourceAndTarget"> <xs:selector xpath="tns:element"/> <xs:field xpath="@source"/> <xs:field xpath="@target"/> </xs:unique>
未经测试。