TimLuq / schematron-runner

2 stars 3 forks source link

Does not validate if schematron file have no phases #5

Open paulish opened 3 years ago

paulish commented 3 years ago

We have external schematron files for various CDA validation and it is desirable not to change them ourself. Is there an option to treat all patterns in the schematron file as errors?

An example of what we have:

<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
  <pattern>
    <rule context="//addr">
      <assert test="state[last()=1] and matches(state, '^\d{1,2}$') or @nullFlavor">All //addr elements MUST have element state.</assert>
      <assert test="streetAddressLine or @nullFlavor">All //addr elements MUST have element streetAddressLine</assert>
    </rule>
  </pattern>
</schema>

This is how we need to modify each file to make it work:

<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
  <phase id="errors">
    <active pattern="errors" />
  </phase>
  <pattern id="errors">
    <rule context="//addr">
      <assert test="state[last()=1] and matches(state, '^\d{1,2}$') or @nullFlavor">All //addr elements MUST have element state.</assert>
      <assert test="streetAddressLine or @nullFlavor">All //addr elements MUST have element streetAddressLine</assert>
    </rule>
  </pattern>
</schema>
paulish commented 3 years ago

After more research I see that the reason is that pattern does not have id attribute specified. And I also see that this is fixed in the master but not published to npm?