Interface IPSValidationHandler

All Known Subinterfaces:
IPSPartialValidationHandler
All Known Implementing Classes:
LoggingPSValidationHandler, PSValidationHandlerBreakOnFirstError, PSValidationHandlerBreakOnFirstFailedAssert, PSXPathValidationHandlerSVRL

public interface IPSValidationHandler
Base interface for a Schematron validation callback handler. It is only invoked when validating an XML against a Schematron file.
Author:
Philip Helger
See Also:
  • Method Details

    • onStart

      default void onStart(@Nonnull PSSchema aSchema, @Nullable PSPhase aActivePhase, @Nullable String sBaseURI) throws SchematronValidationException
      This is the first method called.
      Parameters:
      aSchema - The Schematron to be validated. Never null.
      aActivePhase - The selected phase, if any special phase was selected. May be null.
      sBaseURI - The Base URI of the XML to be validated. May be null.
      Throws:
      SchematronValidationException - In case of validation errors
      See Also:
    • onPattern

      default void onPattern(@Nonnull PSPattern aPattern) throws SchematronValidationException
      This method is called for every pattern inside the schema.
      Parameters:
      aPattern - The current pattern. Never null.
      Throws:
      SchematronValidationException - In case of validation errors
    • onRuleStart

      default void onRuleStart(@Nonnull PSRule aRule, @Nonnull NodeList aContextList) throws SchematronValidationException
      Called once for each rule, even if the context list is empty.
      Parameters:
      aRule - The rule that is to be executed.
      aContextList - The list of context nodes. Never null but maybe empty.
      Throws:
      SchematronValidationException - In case of errors
    • onFiredRule

      default void onFiredRule(@Nonnull PSRule aRule, @Nonnull String sContext, @Nonnegative int nNodeIndex, @Nonnegative int nNodeCount) throws SchematronValidationException
      This method is called for every rule inside the current pattern. Was called "onRule" previously.
      Parameters:
      aRule - The current rule. Never null.
      sContext - The real context to be used in validation. May differ from the result of PSRule.getContext() because of replaced variables from <let> elements.
      nNodeIndex - 0-based node index currently fired
      nNodeCount - The total number of nodes for this rule. Always > 0.
      Throws:
      SchematronValidationException - In case of validation errors
    • onFailedAssert

      @Nonnull default com.helger.commons.state.EContinue onFailedAssert(@Nonnull PSAssertReport aAssertReport, @Nonnull String sTestExpression, @Nonnull Node aRuleMatchingNode, int nNodeIndex, @Nullable Object aContext) throws SchematronValidationException
      This method is called for every failed assert.
      Parameters:
      aAssertReport - The current assert element. Never null.
      sTestExpression - The source XPath expression that was evaluated for this node. It may be different from the test expression contained in the passed assert/report element because of replaced <let> elements. Never null.
      aRuleMatchingNode - The XML node of the document to be validated.
      nNodeIndex - The index of the matched node, relative to the current rule.
      aContext - A context object - implementation dependent. For the default query binding this is e.g. an PSXPathBoundAssertReport object.
      Returns:
      EContinue.BREAK to stop validating immediately.
      Throws:
      SchematronValidationException - In case of validation errors
    • onSuccessfulReport

      @Nonnull default com.helger.commons.state.EContinue onSuccessfulReport(@Nonnull PSAssertReport aAssertReport, @Nonnull String sTestExpression, @Nonnull Node aRuleMatchingNode, int nNodeIndex, @Nullable Object aContext) throws SchematronValidationException
      This method is called for every failed assert.
      Parameters:
      aAssertReport - The current assert element. Never null.
      sTestExpression - The source XPath expression that was evaluated for this node. It may be different from the test expression contained in the passed assert/report element because of replaced <let> elements. Never null.
      aRuleMatchingNode - The XML node of the document to be validated.
      nNodeIndex - The index of the matched node, relative to the current rule.
      aContext - A context object - implementation dependent. For the default query binding this is e.g. an PSXPathBoundAssertReport object.
      Returns:
      EContinue.BREAK to stop validating immediately.
      Throws:
      SchematronValidationException - In case of validation errors
    • onEnd

      default void onEnd(@Nonnull PSSchema aSchema, @Nullable PSPhase aActivePhase) throws SchematronValidationException
      This is the last method called. It indicates that the validation for the current scheme ended.
      Parameters:
      aSchema - The Schematron that was be validated. Never null.
      aActivePhase - The selected phase, if any special phase was selected. May be null.
      Throws:
      SchematronValidationException - In case of validation errors
      See Also:
    • and

      Create a new validation handler that first invokes all methods from this handler, and than later on from the passed validation handler.
      Parameters:
      rhs - The validation handler to be invoked after this one. May be null.
      Returns:
      The new validation handler that invokes this and the passed on
    • and

      Create a new validation handler that first invokes all methods from the first handler and second from the second handler.
      Parameters:
      lhs - The first validation handler to be invoked. May be null.
      rhs - The second validation handler to be invoked. May be null.
      Returns:
      The new validation handler that invokes both handlers. May be null if both are null.