Validation 检查同级元素中的重复属性数据-Schematron
我正在尝试在Schematron中编写一个检查,以确保没有元素包含重复的属性数据。这些元素位于XML文档中的特定位置,我有XPATH来定位它们 例如: 应该失败,因为它具有重复的foo和bar属性值Validation 检查同级元素中的重复属性数据-Schematron,validation,xpath,schematron,Validation,Xpath,Schematron,我正在尝试在Schematron中编写一个检查,以确保没有元素包含重复的属性数据。这些元素位于XML文档中的特定位置,我有XPATH来定位它们 例如: 应该失败,因为它具有重复的foo和bar属性值 <id foo="test1" bar="abc" /> <id foo="test1" bar="abc" /> 这应该通过,因为foo属性不相同 <id foo="test1" bar="abc" /> <id foo="test2" bar="a
<id foo="test1" bar="abc" />
<id foo="test1" bar="abc" />
这应该通过,因为foo属性不相同
<id foo="test1" bar="abc" />
<id foo="test2" bar="abc" />
我不确定这对Schematron来说是否太复杂了
有什么想法吗?我不知道Schematron,但如果您能够使用XPath 2.0(这是可能的),它将派上用场
not(deep-equal(<id foo="test1" bar="abc" />, <id foo="test1" bar="abc" />)) (: false :)
not(deep-equal(<id foo="test1" bar="abc" />, <id foo="test2" bar="abc" />)) (: true :)
如果没有,应该有一个使用XSLT 1.0的解决方案,但您必须自己构造递归比较,我对XSLT的了解还不够,无法做到这一点。我会在Schematron中使用XML ValidatorBuddy进行检查:
<iso:pattern id="unique name attributes">
<iso:rule context="id">
<iso:assert test="count(id) = count(id[not(@foo=preceding-sibling::person/@foo)])">
Not all foo attributes of the id elements are unique
</iso:assert>
</iso:rule>
</iso:pattern>
您还可以在此处添加对条形图属性的检查