Schematron 验证多个元素

Schematron validating multiple elements

假设我有一个 XML 文档定义:

<people>

  <person>
    <city>London</city>
  </person>
  <person>
    <city>Paris</city>
  </person>

</people>

我想要一个 schematron 来检查每个人是否都住在伦敦。

我试过了:

<sch:rule context="people">
            <sch:assert test="person/city = 'London'">Everybody must live in London!</sch:assert>
 </sch:rule>

但是,只要有一个人住在伦敦,这就会 return 成立。有没有办法告诉 schematron 对匹配 XPathcondition person/city 的每个元素应用测试?

"no one may live outside London"怎么样:

<sch:rule context="people">
    <sch:assert test="not(person[city != 'London'])">Everybody must live in London!</sch:assert>
</sch:rule>

这有很多不同的解决方案。示例解决方案 1,如果有人不住在伦敦,请报告:

<sch:rule context="people">
  <sch:report test="person/city != 'London'">Everybody must live in London!</sch:report>
</sch:rule>

示例解决方案 2,断言每个人都必须住在伦敦,请注意,这将报告每个人都不住在伦敦作为错误,而不是仅报告节点 people.

<sch:rule context="people/person">
    <sch:assert test="city = 'London'">This person should be living in london</sch:assert>
</sch:rule>