Published 2012-08-31
Based on customer feedback I want to post some solutions for two very common Schematron checks. The first rule is an assertion to report if all values of an attribute are unique for all elements (within the same parent). Simply open XML ValidatorBuddy, create a new Schematron schema and add the following rule in the editor:
<iso:pattern id="unique name attributes"> <iso:rule context="people"> <iso:assert test="count(person) = count(person[not(@name=preceding-sibling::person/@name)])"> Not all name attributes of the person elements are unique </iso:assert> </iso:rule> </iso:pattern>
The second one is a check to see if all element values of a certain element (within the same parent) are unique. Add the following rule and apply it using the built-in Schematron XML validator in XML ValidatorBuddy:
<iso:pattern id="unique drawers"> <iso:rule context="shelf"> <iso:report test="count(drawer) != count(distinct-values(drawer))"> Content of drawers not distinct <iso:value-of select="." /> </iso:report> </iso:rule> </iso:pattern>
XML ValidatorBuddy is more than just an XML editor. Learn more on clicking the images and links below.
View and edit large XML data - not limited to well-formed input
Learn moreXML editor for Windows ® with syntax-coloring, code folding and many more...
Learn more