More Schematron Features - More on assertions
(Page 2 of 5 )
At the assertion level of Schematron, basic assertion functionality is provided by the assert element. An assertion made using this element can either be met or unmet, and if unmet, then validation fails. That's not all that can be done on the assertion level, though.
Going back to the assert element, a message is given if the assertion test evaluates to false. So, if something is not found, then the message goes out. There is a similar element that works differently, though. The report element also features an assertion test, but, in this case, if the assertion test evaluates to true (in other words, if something is found), then the message is given. The report element, then, can be seen as the opposite of the assert element.
For example, consider an XML document that deals with animals. Inside of the document is a snake element. Other animals may have legs that are represented using a leg element, but snakes, obviously, do not have legs. We can ensure that this is the case using the report element. If a snake element is found to contain a leg element, then a message needs to be displayed:
<report test="leg">The snake has a leg.</report>
The following XML would cause the above report to give its message:
<animals>
<snake>
<leg/>
</snake>
</animals>
Removing the leg element would fix the problem.
Next: Declaring variables with the let element >>
More XML Articles
More By Peyton McCullough