i have the following checks
<iso:pattern id="myChecks">
<iso:rule context="/root/outerElement/innerElement">
<iso:assert test="typeElement[@someAttribute='type1']">
No typeElement with someAttribute=type1 found
</iso:assert>
<iso:assert test=".[child::typeElement[@someAttribute='value1']]/data">
No dataElement found in an innerElement with typeElement with someAttribute=type1
</iso:assert>
<iso:assert test="count(typeElement[@someAttribute='type1'] > 1)">
There is more than 1 innerElement with typeElement 1 with someAttribute=type1
</iso:assert>
</iso:rule>
</iso:pattern>
and the Document looks like this:
<outerElement>
<!-- 1 of the dataElements is mandatory -->
<!-- and i need exact one innerElement which has a typeElement with someAttribute=type1 -->
<innerElement>
<dataElement>data</dataElement>
<dataElement>data</dataElement>
<typeElement someAttribute="type1"></typeElement>
</innerElement>
<!-- This is not allowed and check 3 should find this -->
<innerElement>
<dataElement>data</dataElement>
<dataElement>data</dataElement>
<typeElement someAttribute="type1"></typeElement>
</innerElement>
<!-- This one is valid because type2 has other restrictions -->
<innerElement>
<typeElement someAttribute="type2"></typeElement>
</innerElement>
</outerElement>
The Problem now is that check 1 and 2 take every innerElement check it and produce an error which means if i have 3 times type 2 i get 3 errors each from the first 3 checks. What i want is to ensure that exactly one innerElement has type1 and ensure that this has atleast 1 dataElement while innerElements with type2 are not forced to have a dataElement.
The third check isn't working at all it seems it just throws an error everytime there is more than one innerElement.
Can someone please help me with this?