Hi, I'm trying to write some Schematron rules and one of them is supposed to check, if elements are unique in the scope of parent element. So I have an example xml structure:
<abc>
<elem id="qw0">
<a>1</a>
<a>2</a>
<a>3</a>
</elem>
<elem id="qw1">
<a>1</a>
<a>2</a>
<a>3</a>
<a>3</a>
</elem>
</abc>
My rule should check if each of the element's "a" elements is unique. In this specific example, for elem with id="qw1" there are two elements "a" with value "3". This should not be allowed.
So far I've come to this kind of rule:
<iso:pattern id="doc.abc">
<iso:title>checking ABC</iso:title>
<iso:rule context="elem">
<iso:assert test="count(a[. = current()]) = 1">TACs should be unique.</iso:assert>
</iso:rule>
</iso:pattern>
But this does not work, as it kind of looks through the whole document, not just the direct children of elem.