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

Missing error report when validating #30

Closed
jkiddo opened this issue Oct 23, 2016 · 4 comments
Closed

Missing error report when validating #30

jkiddo opened this issue Oct 23, 2016 · 4 comments
Assignees
Labels
Milestone

Comments

@jkiddo
Copy link

jkiddo commented Oct 23, 2016

There seems to be a bug when validating the schematron files. The following code reproduces the bug:

@Test
public void testOfSchematronPH() throws Exception {

    final SchematronResourcePure aResPure = SchematronResourcePure.fromFile("ph-test.sch");
    final IPSErrorHandler aErrorHandler =new IPSErrorHandler() {

        @Override
        public void warn(final IReadableResource aRes, final IPSElement aSourceElement, final String sMessage) {
            // TODO Auto-generated method stub
            System.out.println(sMessage);
        }

        @Override
        public void error(final IReadableResource aRes, final IPSElement aSourceElement, final String sMessage, final Throwable t) {
            // TODO Auto-generated method stub
            System.out.println(sMessage);
        }

        @Override
        public void error(final IPSElement aSourceElement, final String sMessage) {
            // TODO Auto-generated method stub
            System.out.println(sMessage);
        }
    };


    aResPure.validateCompletely(aErrorHandler);
    Assert.assertTrue(aResPure.isValidSchematron());
}

Attached are the schematron files with an empty rule which is intentionally a bug. When running validateCompletely, none of the methods are hit in the IPSErrorHandler. However, when running isValidSchematron(), the schemas are deemed invalid

Archive.zip

@phax phax self-assigned this Oct 23, 2016
@phax phax added the bug label Oct 24, 2016
phax added a commit that referenced this issue Oct 24, 2016
phax added a commit that referenced this issue Oct 24, 2016
@phax
Copy link
Owner

phax commented Oct 24, 2016

The first problem is the missing support for the XML Entity Handler when just reading from a file. I added support for this in the current HEAD revision.

The second things was, that the errorHandler must be assigned to the SchematronResource itself.
Please see https://github.com/phax/ph-schematron/blob/master/ph-schematron/src/test/java/com/helger/schematron/supplementary/Issue30Test.java for a working test case that fixes the Entity resolution and the error handling logging.

@phax phax added this to the v4.1.1 milestone Oct 24, 2016
@phax
Copy link
Owner

phax commented Nov 2, 2016

Did the EntityHandler extension help you?
Do you need a 4.1.1 release?

@jkiddo
Copy link
Author

jkiddo commented Nov 3, 2016

Release early, release often ;) - I found a workaround, so it is not that critical. But feel free to push a release when you see fit containing the fix

@jkiddo jkiddo closed this as completed Nov 3, 2016
@phax
Copy link
Owner

phax commented Nov 3, 2016

Version 4.1.1 is on Maven central

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

No branches or pull requests

2 participants