Variables not working as expected in match
I have been battling for a while now with a schematron rule that does not seem to evaluate my variable correctly leaving me with no correct match.
My example and rule should always fail the assertion, and write out the message (as a "Test") ... as I want one question for every one reference (and visa versa) ... but the count always comes up as ZERO!
Where my rule is as follows:
<pattern id="Question">
<rule id="Count" context="question/@id">
<let name="href" value="concat('#', ancestor::parent/@id, '/', .)" />
<assert test="false()">
question/@id=[<value-of select="." />] has [<value-of select="count(ancestor::parent//reference[@href eq $href)])" />] references with reference/@href=[<value-of select="$href" />])
</assert>
</rule>
</pattern>
My input XML is as follows:
<parent id="GUID-ABCDEFG">
<question>
<references>
<reference href="#GUID-ABCDEFG/GUID-12345"/>
<reference href="#GUID-ABCDEFG/GUID-67890"/>
</references>
<questions>
<question id="GUID-12345">...</question>
<question id="GUID-67890">...</question>
</questions>
</question>
</parent>
My output when rendering outputs the variables correctly:
Question::Count:[[question/@id=[GUID-12345] has [0] references with reference/@href=[#GUID-ABCDEFG/GUID-12345]
As you can see, zero, when it should find 1 match.
If I count "all" the references, then it DOES give me 2!
Now, if I hard-code the count as a string:
<value-of select="count(ancestor::parent//reference[@href eq '#GUID-ABCDEFG/GUID-12345'])" />
Then I do get the correct count/result!!
On another strange note: If I put a syntax error in my rule, the exception that is thrown shows me the "content" of the variable, not the value:
count(ancestor::question//data-about[@href eq concat('#', ancestor::question/@id, '/', .))])': syntax error, expecting ','