Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sch:diagnostics leads to errors with schematron engine #85

Closed
nkutsche opened this issue Aug 7, 2019 · 1 comment
Closed

sch:diagnostics leads to errors with schematron engine #85

nkutsche opened this issue Aug 7, 2019 · 1 comment
Assignees

Comments

@nkutsche
Copy link
Contributor

nkutsche commented Aug 7, 2019

Hi,

I tried to validate with this Schematron:

<sch:pattern>
        <sch:rule context="/">
            <sch:report test="true()" diagnostics="d1"/>
        </sch:rule>
    </sch:pattern>
    <sch:diagnostics>
        <sch:diagnostic id="d1" xml:lang="de">Foobar</sch:diagnostic>
    </sch:diagnostics>

using this Ant script (using ph-Schematron 5.2.0):

<taskdef name="schematron" classname="com.helger.schematron.ant.Schematron"/>

<target name="db.common.validation.schematron">
    <schematron schematronFile="test.sch" expectSuccess="true" failonerror="true"
        schematronProcessingEngine="schematron" svrlDirectory=".">
        <file file="test.xml"/>
    </schematron>
</target>

Instead of the expected error message I always get:

Invalid content was found starting with element 'svrl:diagnostic-reference'. No child element is expected at this point.

The problem seems to come from this SVRL-schema. There is already a note, which points to this issues:

<!-- Note: XSLT based version may emit the diagnostic-reference here :( -->

After a bit researching this seems to be a known gap between the ISO Schematron implementation and the ISO Schematron SVRL Schema. As I just found out you can avoid this error by setting the Skeleton parameter $diagnose=false. This turns off the diagnostic support but it doesn't work anyway.

I think the ph-schematron engine should force the $diagnose parameter value to false until the Skeleton is fixed, shouldn't it?

@phax phax self-assigned this Aug 7, 2019
@phax phax added the pinned label Nov 4, 2019
phax added a commit that referenced this issue Dec 4, 2020
@phax
Copy link
Owner

phax commented Dec 4, 2020

It was quite tedious to find a matching XSD for this mess.
But basically

      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="svrl:diagnostic-reference"/>
        <xs:element ref="svrl:property-reference"/>
        <xs:element ref="svrl:text"/>
        <!-- Note: XSLT based version may emit the diagnostic-reference here :( -->
      </xs:choice>

does the trick.
There is more broken with the diagnostic references.
Instead of using the <text> element, the ISO Schematron throws the text directly into the <diagnostic-reference> element. sigh

This will be part of the 6.0.2 release. In the meantime adding the custom XSLT parameter $diagnose=false should do the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants