phax / ph-schematron

Java Schematron library that supports XSLT and native application
Apache License 2.0
115 stars 36 forks source link

Rich attributes fpi, see, and possibly others are not returned in svrl report #101

Closed Michiel-s closed 3 years ago

Michiel-s commented 4 years ago

Hi @phax,

First of all, thanks for this great schematron validation implementation.

I'm using version 5.6.0.

When I have e.g. the following rule set

<sch:pattern id="1000101">
   <sch:title>Rule title</sch:title>
   <sch:rule id="1000101" fpi="BR-123" context="some xpath here">
      <sch:assert fpi="BR123-1" flag="error" see="#/rules/1000101" test="some test here">Some error message here</sch:assert>
    </sch:rule>
</sch:pattern>

The attribute fpi (both for rule and assert) and see are not returned in the svrl output:

<ns2:schematron-output title="" schemaVersion="">
    <ns2:active-pattern id="1000101" name="Rule title" document=""/>
    <ns2:fired-rule id="1000101" context="some xpath here"/>
    <ns2:fired-rule id="1000101" context="some xpath here"/>
    <ns2:failed-assert location="xpath location" test="the test again" flag="error">
        <ns2:text>Some error message here</ns2:text>
    </ns2:failed-assert>
</ns2:schematron-output>

As you can see, the id and flag attributes are there, but not the fpi and see. They are part of the schematron and svrl specs and I also see some references to those attributes in your code.

Is this a bug, feature or am I missing some config that I need to use.

Michiel

phax commented 4 years ago

Hi Michiel, thanks for your question. May I ask what version of the Schematron engine you are using? Pure, SCH or XSLT? Because that has an impact on the outcome :) Thanks, Philip

Michiel-s commented 4 years ago

I’m not using the Pure engine, but not sure what you mean by SCH vs XSLT. I’m creating a new schematron resource with SchematronResourceSCH class. So I think the SCH engine then. But as far as I understood and see in the logs, this translates to xslt for the actual validation process.

phax commented 4 years ago

Yes exactly - the SCH is converted to an XSLT and than applied onto the main XML to created SVRL. In that case I cannot help you, as this is basically the "default XSLT" from schematron.com (see https://github.com/Schematron/schematron ) I scanned the issues but couldn't find something.... Please open an issue there - okay?

phax commented 4 years ago

Closing this, as there is unfortunately not much I can do here :(

flowrider3000 commented 3 years ago

@Michiel-s check my pr #111 for an example how to add allow-foreign elements.

Michiel-s commented 3 years ago

Thx. I'll look into it probably Monday. Thanks for mentioning me.

phax commented 3 years ago

My SVRL output is currently this:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<schematron-output xmlns="http://purl.oclc.org/dsdl/svrl" schemaVersion="" title="">
<!--   
           
           
         -->
  <active-pattern document="C:\dev\git\ph-schematron\ph-schematron\src\test\resources\issues\github101\test.xml" id="p1000101" name="Rule title" />
  <fired-rule context="/doc/h1" fpi="BR-123" id="r1000101" />
  <failed-assert flag="error" fpi="BR123-1" location="/doc[1]/h1[1]" see="#/rules/1000101" test="@a='b'">
    <text>Some error message here</text>
  </failed-assert>
  <fired-rule context="/doc/h1" fpi="BR-123" id="r1000101" />
  <fired-rule context="/doc/h1" fpi="BR-123" id="r1000101" />
  <failed-assert flag="error" fpi="BR123-1" location="/doc[1]/h1[3]" see="#/rules/1000101" test="@a='b'">
    <text>Some error message here</text>
  </failed-assert>
</schematron-output>

it fails because attribute fpi is not allowed in svrl:fired-rule

phax commented 3 years ago

It should be working in the 6.0.0 version

flowrider3000 commented 3 years ago

@phax many thanks. Do you have any eta when 6.0.0 will be available?

phax commented 3 years ago

No not really. I am splitting things into more modules and want to add schxslt as well - if this is done, v6 is free to be published

phax commented 3 years ago

Version 6.0.0 is on it's way to Maven Central. Please see https://github.com/phax/ph-schematron/wiki/Migrations for details