I’ve recently started using schematron to validate xml documents. I’m pretty impressed by it so far, but I’ve stumbled upon a rule that I can’t get to work properly.
I’ve made a simple example below.
<iso:assert test="ns1:some-element/text() = 'false' and /ns1:same-other-element">Error message</iso:assert>
Basically I want to validate two things, if ns1:some-element/text() contains ‘false’, ns1:same-other-element should be present, and that validation actually works. However, when ns1:some-element/text() contains something other than false, than I don’t care weather ns1:same-other-element is there or not.
At this moment, the rule also fires when ns1:same-other-element is missing and the value of ns1:some-element/text() is not ‘false’
Any ideas how to work around this?
Your test needs to evaluate to true in order to pass validation (you are making an assertion about something). What you are currently saying with your condition is: the text node of
ns1:some-elementMUST have a value of ‘false’ ANDns1:some-other-elementMUST exist. Anything else is an error.The condition you are probably looking for is
This condition will be true whenever
ns1:some-elementhas a value that is not ‘false’, regardless of whetherns1:some-other-elementis present.