title: Schematron validation and uniqueness
body: <p>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:</p>
  
  <pre><code>&lt;abc&gt;
    &lt;elem id="qw0"&gt;
      &lt;a&gt;1&lt;/a&gt;
      &lt;a&gt;2&lt;/a&gt;
      &lt;a&gt;3&lt;/a&gt;
    &lt;/elem&gt;
    &lt;elem id="qw1"&gt;
      &lt;a&gt;1&lt;/a&gt;
      &lt;a&gt;2&lt;/a&gt;
      &lt;a&gt;3&lt;/a&gt;
      &lt;a&gt;3&lt;/a&gt;
    &lt;/elem&gt;
  &lt;/abc&gt;
  </code></pre>
  
  <p>My rule should check if each of the element's "a" elements is unique. In this specific example, for <em>elem</em> with <em>id="qw1"</em>  there are two elements "a" with value "3". This should not be allowed.</p>
  
  <p>So far I've come to this kind of rule:</p>
  
  <pre><code>&lt;iso:pattern id="doc.abc"&gt;
    &lt;iso:title&gt;checking ABC&lt;/iso:title&gt;
    &lt;iso:rule context="elem"&gt;
      &lt;iso:assert test="count(a[. = current()]) = 1"&gt;TACs should be unique.&lt;/iso:assert&gt;
    &lt;/iso:rule&gt;
  &lt;/iso:pattern&gt;
  </code></pre>
  
  <p>But this does not work, as it kind of looks through the whole document, not just the direct children of <em>elem</em>.</p>