I am attempting to use NMatrix's Schematron to validate XML in C#. If I leave the "f" namespace out of the namespace-manager (nsManager), I get the exception: Undeclared namespace prefix - f when this code is executed.
CompiledXPathExpression _expr;
...
_expr.SetContext(nsManager);
For Schematron Line:
<sch:rule context="/f:Patient/f:identifier/f:period">
After adding the "f" namespace, the "rule" line completes, but I get the exception: Unrecognized extension function namespace: prefix='', namespace URI='' when the same code is executed.
CompiledXPathExpression _expr;
...
_expr.SetContext(nsManager);
For the next Schematron line:
<sch:assert test="not(exists(f:start)) or not(exists(f:end)) or (f:start/@value <= f:end/@value)">Inv-1: If present, start SHALL have a lower value than end</sch:assert>
After some experimentation, I find this works:
<sch:rule context="/f:Patient/f:identifier/f:period">
<sch:assert test="f:start">Inv-1: If present, start SHALL have a lower value than end</sch:assert>
</sch:rule>
But this fails:
<sch:rule context="/f:Patient/f:identifier/f:period">
<sch:assert test="not(exists(f:start)) or not(exists(f:end)) or (f:start/@value <= f:end/@value)">Inv-1: If present, start SHALL have a lower value than end</sch:assert>
end</sch:assert>
</sch:rule>
I thought I had some kind of namespace problem at first, but now I am starting to wonder if this syntax is even valid with XPathExpression