use of com.helger.schematron.pure.errorhandler.IPSErrorHandler in project ph-schematron by phax.
the class PSXPathQueryBinding method bind.
@Nonnull
public IPSBoundSchema bind(@Nonnull final PSSchema aSchema, @Nullable final String sPhase, @Nullable final IPSErrorHandler aCustomErrorListener, @Nullable final XPathVariableResolver aVariableResolver, @Nullable final XPathFunctionResolver aFunctionResolver) throws SchematronException {
ValueEnforcer.notNull(aSchema, "Schema");
final IPSErrorHandler aErrorHandler = aCustomErrorListener != null ? aCustomErrorListener : new CollectingPSErrorHandler();
if (!aSchema.isValid(aErrorHandler))
throw new SchematronBindException("The passed schema is not valid and can therefore not be bound" + (aErrorHandler == aCustomErrorListener ? ". Errors are in the provided error handler." : ": " + ((CollectingPSErrorHandler) aErrorHandler).getErrorList().toString()));
PSSchema aSchemaToUse = aSchema;
if (!aSchemaToUse.isPreprocessed()) {
// Required for parameter resolution
final PSPreprocessor aPreprocessor = PSPreprocessor.createPreprocessorWithoutInformationLoss(this);
// Apply preprocessing
aSchemaToUse = aPreprocessor.getForcedPreprocessedSchema(aSchema);
}
final PSXPathBoundSchema ret = new PSXPathBoundSchema(this, aSchemaToUse, sPhase, aCustomErrorListener, aVariableResolver, aFunctionResolver);
ret.bind();
return ret;
}
Aggregations