Search in sources :

Example 1 with PSXPathBoundAssertReport

use of com.helger.schematron.pure.bound.xpath.PSXPathBoundAssertReport in project ph-schematron by phax.

the class PSXPathValidationHandlerSVRL method onSuccessfulReport.

@Override
@Nonnull
public EContinue onSuccessfulReport(@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 SuccessfulReport aSuccessfulReport = new SuccessfulReport();
    aSuccessfulReport.setFlag(aAssertReport.getFlag());
    aSuccessfulReport.setId(aAssertReport.getID());
    aSuccessfulReport.setLocation(_getPathToNode(aRuleMatchingNode));
    // TODO role
    aSuccessfulReport.setTest(sTestExpression);
    aSuccessfulReport.setText(_getErrorText(aBoundAssertReport.getAllBoundContentElements(), aRuleMatchingNode));
    _handleDiagnosticReferences(aAssertReport.getAllDiagnostics(), aSuccessfulReport.getDiagnosticReference(), aBoundAssertReport, aRuleMatchingNode);
    m_aSchematronOutput.getActivePatternAndFiredRuleAndFailedAssert().add(aSuccessfulReport);
    return EContinue.CONTINUE;
}
Also used : PSXPathBoundAssertReport(com.helger.schematron.pure.bound.xpath.PSXPathBoundAssertReport) SchematronValidationException(com.helger.schematron.pure.validation.SchematronValidationException) SuccessfulReport(org.oclc.purl.dsdl.svrl.SuccessfulReport) Nonnull(javax.annotation.Nonnull)

Example 2 with PSXPathBoundAssertReport

use of com.helger.schematron.pure.bound.xpath.PSXPathBoundAssertReport 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)2 SchematronValidationException (com.helger.schematron.pure.validation.SchematronValidationException)2 Nonnull (javax.annotation.Nonnull)2 FailedAssert (org.oclc.purl.dsdl.svrl.FailedAssert)1 SuccessfulReport (org.oclc.purl.dsdl.svrl.SuccessfulReport)1