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 Summary
Modifier and TypeMethodDescriptiondefault IPSValidationHandlerand(IPSValidationHandler rhs) Create a new validation handler that first invokes all methods from this handler, and than later on from the passed validation handler.static IPSValidationHandlerand(IPSValidationHandler lhs, IPSValidationHandler rhs) Create a new validation handler that first invokes all methods from the first handler and second from the second handler.default voidThis is the last method called.default com.helger.commons.state.EContinueonFailedAssert(PSAssertReport aAssertReport, String sTestExpression, Node aRuleMatchingNode, int nNodeIndex, Object aContext) This method is called for every failed assert.default voidonFiredRule(PSRule aRule, String sContext, int nNodeIndex, int nNodeCount) This method is called for every rule inside the current pattern.default voidThis method is called for every pattern inside the schema.default voidonRuleStart(PSRule aRule, NodeList aContextList) Called once for each rule, even if the context list is empty.default voidThis is the first method called.default com.helger.commons.state.EContinueonSuccessfulReport(PSAssertReport aAssertReport, String sTestExpression, Node aRuleMatchingNode, int nNodeIndex, Object aContext) This method is called for every failed assert.
-
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. Nevernull.aActivePhase- The selected phase, if any special phase was selected. May benull.sBaseURI- The Base URI of the XML to be validated. May benull.- Throws:
SchematronValidationException- In case of validation errors- See Also:
-
onPattern
This method is called for every pattern inside the schema.- Parameters:
aPattern- The current pattern. Nevernull.- 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. Nevernullbut 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. Nevernull.sContext- The real context to be used in validation. May differ from the result ofPSRule.getContext()because of replaced variables from <let> elements.nNodeIndex- 0-based node index currently firednNodeCount- 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. Nevernull.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. Nevernull.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. anPSXPathBoundAssertReportobject.- Returns:
EContinue.BREAKto 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. Nevernull.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. Nevernull.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. anPSXPathBoundAssertReportobject.- Returns:
EContinue.BREAKto 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. Nevernull.aActivePhase- The selected phase, if any special phase was selected. May benull.- 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 benull.- Returns:
- The new validation handler that invokes this and the passed on
-
and
@Nonnull static IPSValidationHandler and(@Nullable IPSValidationHandler lhs, @Nullable IPSValidationHandler rhs) 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 benull.rhs- The second validation handler to be invoked. May benull.- Returns:
- The new validation handler that invokes both handlers. May be
nullif both are null.
-