Search in sources :

Example 6 with IPSErrorHandler

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;
}
Also used : SchematronBindException(com.helger.schematron.pure.binding.SchematronBindException) IPSErrorHandler(com.helger.schematron.pure.errorhandler.IPSErrorHandler) PSXPathBoundSchema(com.helger.schematron.pure.bound.xpath.PSXPathBoundSchema) PSPreprocessor(com.helger.schematron.pure.preprocess.PSPreprocessor) PSSchema(com.helger.schematron.pure.model.PSSchema) CollectingPSErrorHandler(com.helger.schematron.pure.errorhandler.CollectingPSErrorHandler) Nonnull(javax.annotation.Nonnull)

Aggregations

IPSErrorHandler (com.helger.schematron.pure.errorhandler.IPSErrorHandler)6 IReadableResource (com.helger.commons.io.resource.IReadableResource)4 PSSchema (com.helger.schematron.pure.model.PSSchema)3 Test (org.junit.Test)3 IPSBoundSchema (com.helger.schematron.pure.bound.IPSBoundSchema)2 CollectingPSErrorHandler (com.helger.schematron.pure.errorhandler.CollectingPSErrorHandler)2 PSReader (com.helger.schematron.pure.exchange.PSReader)2 Nonnull (javax.annotation.Nonnull)2 ClassPathResource (com.helger.commons.io.resource.ClassPathResource)1 AbstractMemoryReadableResource (com.helger.commons.io.resource.inmemory.AbstractMemoryReadableResource)1 SchematronException (com.helger.schematron.SchematronException)1 SchematronResourcePure (com.helger.schematron.pure.SchematronResourcePure)1 SchematronBindException (com.helger.schematron.pure.binding.SchematronBindException)1 PSBoundSchemaCacheKey (com.helger.schematron.pure.bound.PSBoundSchemaCacheKey)1 PSXPathBoundSchema (com.helger.schematron.pure.bound.xpath.PSXPathBoundSchema)1 DoNothingPSErrorHandler (com.helger.schematron.pure.errorhandler.DoNothingPSErrorHandler)1 IPSElement (com.helger.schematron.pure.model.IPSElement)1 PSPreprocessor (com.helger.schematron.pure.preprocess.PSPreprocessor)1 SVRLMarshaller (com.helger.schematron.svrl.SVRLMarshaller)1 IMicroDocument (com.helger.xml.microdom.IMicroDocument)1