【发布时间】:2019-03-26 07:19:07
【问题描述】:
我正在尝试编写 schematron 规则来比较循环中当前子元素的属性(End @value)与下一个子元素的属性(Origin @value)。我不确定我是否做对了,所以这是我的尝试
这是我的尝试:
<sch:rule context="test">
<sch:assert test="End/@value = following-sibling::test/Origin/@value " >Both the value are not Equal. </sch:assert>
</sch:rule>
这条规则在最后一个元素之前工作正常,最后一个元素期待另一个不存在的元素。问题可能出在“following-sibling”。
这是 XML 文件:
<tests>
<test x="-276.724" xEnd="-276.193">
<Origin value="36.599"/>
<End value="36.6"/>
</test>
<test x="-276.193" xEnd="-260.29">
<Origin value="36.6"/>
<End value="36.603"/>
</test>
<test x="-260.29" xEnd="-240.194">
<Origin value="36.603"/>
<End value="36.601"/>
</test>
<test x="-240.194" xEnd="-220.046">
<Origin value="36.601"/>
<End value="36.601"/>
</test>
<test x="-220.046" xEnd="-200.09">
<Origin value="36.601"/>
<End value="36.602"/>
</test>
预期结果: 由于当前子元素(End @value)=下一个子元素属性(Origin @value),输出应该是成功的。
实际结果。
<test x="-220.046" xEnd="-200.09">
<Origin value="36.601"/>
<End value="36.602"/>
</test>
这个元素我得到了断言失败
【问题讨论】:
标签: xml xpath schematron