Search in sources :

Example 1 with FailedAssert

use of org.oclc.purl.dsdl.svrl.FailedAssert in project ph-schematron by phax.

the class PSXPathValidationHandlerSVRL method onFailedAssert.

@Override
@Nonnull
public EContinue onFailedAssert(@Nonnull final PSAssertReport aAssertReport, @Nonnull final String sTestExpression, @Nonnull final Node aRuleMatchingNode, final int nNodeIndex, @Nullable final Object aContext) throws SchematronValidationException {
    if (!(aContext instanceof PSXPathBoundAssertReport))
        throw new SchematronValidationException("The passed context must be an XPath object but is a " + aContext);
    final PSXPathBoundAssertReport aBoundAssertReport = (PSXPathBoundAssertReport) aContext;
    final FailedAssert aFailedAssert = new FailedAssert();
    aFailedAssert.setFlag(aAssertReport.getFlag());
    aFailedAssert.setId(aAssertReport.getID());
    aFailedAssert.setLocation(_getPathToNode(aRuleMatchingNode));
    // TODO role
    aFailedAssert.setTest(sTestExpression);
    aFailedAssert.setText(_getErrorText(aBoundAssertReport.getAllBoundContentElements(), aRuleMatchingNode));
    _handleDiagnosticReferences(aAssertReport.getAllDiagnostics(), aFailedAssert.getDiagnosticReference(), aBoundAssertReport, aRuleMatchingNode);
    m_aSchematronOutput.getActivePatternAndFiredRuleAndFailedAssert().add(aFailedAssert);
    return EContinue.CONTINUE;
}
Also used : PSXPathBoundAssertReport(com.helger.schematron.pure.bound.xpath.PSXPathBoundAssertReport) SchematronValidationException(com.helger.schematron.pure.validation.SchematronValidationException) FailedAssert(org.oclc.purl.dsdl.svrl.FailedAssert) Nonnull(javax.annotation.Nonnull)

Aggregations

PSXPathBoundAssertReport (com.helger.schematron.pure.bound.xpath.PSXPathBoundAssertReport)1 SchematronValidationException (com.helger.schematron.pure.validation.SchematronValidationException)1 Nonnull (javax.annotation.Nonnull)1 FailedAssert (org.oclc.purl.dsdl.svrl.FailedAssert)1