0
votes

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 &lt;= 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 &lt;= 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

1
Are you using XPath 1.0 or 2.0?Nico Kutscherauer

1 Answers

0
votes

This was a learning experience! NMatrix-Schematron is completely obsolete. It is no longer being worked and only supports Schematron 1.5 - very old.

I had a very difficult time locating a complete demonstration. I have included a link to a complete demonstration solution using Saxon-HE.

sample code