Search in sources :

Example 1 with WrappedCollectingTransformErrorListener

use of com.helger.xml.transform.WrappedCollectingTransformErrorListener in project phive by phax.

the class ValidationExecutorSchematron method _createSchematronResource.

@Nonnull
private AbstractSchematronResource _createSchematronResource(@Nullable final Locale aLocale, @Nonnull final ErrorList aErrorList, @Nonnull final Consumer<ESchematronOutput> aSpecialOutputHdl) {
    final IValidationArtefact aArtefact = getValidationArtefact();
    // get the Schematron resource to be used for this validation artefact
    final IReadableResource aSCHRes = aArtefact.getRuleResource();
    final IValidationType aVT = aArtefact.getValidationArtefactType();
    if (aVT == EValidationType.SCHEMATRON_PURE) {
        final SchematronResourcePure aPureSCH = new SchematronResourcePure(aSCHRes);
        aPureSCH.setErrorHandler(new WrappedCollectingPSErrorHandler(aErrorList));
        // consecutive calls!
        return aPureSCH;
    }
    if (aVT == EValidationType.SCHEMATRON_SCH) {
        final SchematronResourceSCH aSCHSCH = new SchematronResourceSCH(aSCHRes);
        aSCHSCH.setErrorListener(new WrappedCollectingTransformErrorListener(aErrorList));
        if (aLocale != null && StringHelper.hasText(aLocale.getLanguage()))
            aSCHSCH.setLanguageCode(aLocale.getLanguage());
        return aSCHSCH;
    }
    if (aVT == EValidationType.SCHEMATRON_SCHXSLT) {
        final SchematronResourceSchXslt_XSLT2 aSCHSCH = new SchematronResourceSchXslt_XSLT2(aSCHRes);
        aSCHSCH.setErrorListener(new WrappedCollectingTransformErrorListener(aErrorList));
        if (aLocale != null && StringHelper.hasText(aLocale.getLanguage()))
            aSCHSCH.setLanguageCode(aLocale.getLanguage());
        return aSCHSCH;
    }
    if (aVT == EValidationType.SCHEMATRON_XSLT) {
        final SchematronResourceXSLT aSCHXSLT = new SchematronResourceXSLT(aSCHRes);
        aSCHXSLT.setErrorListener(new WrappedCollectingTransformErrorListener(aErrorList));
        return aSCHXSLT;
    }
    if (aVT == EValidationType.SCHEMATRON_OIOUBL) {
        final SchematronResourceXSLT aSCHXSLT = new SchematronResourceXSLT(aSCHRes);
        aSCHXSLT.setErrorListener(new WrappedCollectingTransformErrorListener(aErrorList));
        // Special output layout
        aSpecialOutputHdl.accept(ESchematronOutput.OIOUBL);
        return aSCHXSLT;
    }
    throw new IllegalStateException("Unsupported Schematron validation type: " + aVT);
}
Also used : IValidationType(com.helger.phive.api.IValidationType) SchematronResourceXSLT(com.helger.schematron.xslt.SchematronResourceXSLT) SchematronResourceSCH(com.helger.schematron.sch.SchematronResourceSCH) IValidationArtefact(com.helger.phive.api.artefact.IValidationArtefact) SchematronResourceSchXslt_XSLT2(com.helger.schematron.schxslt.xslt2.SchematronResourceSchXslt_XSLT2) IReadableResource(com.helger.commons.io.resource.IReadableResource) WrappedCollectingTransformErrorListener(com.helger.xml.transform.WrappedCollectingTransformErrorListener) WrappedCollectingPSErrorHandler(com.helger.schematron.pure.errorhandler.WrappedCollectingPSErrorHandler) SchematronResourcePure(com.helger.schematron.pure.SchematronResourcePure) Nonnull(javax.annotation.Nonnull)

Aggregations

IReadableResource (com.helger.commons.io.resource.IReadableResource)1 IValidationType (com.helger.phive.api.IValidationType)1 IValidationArtefact (com.helger.phive.api.artefact.IValidationArtefact)1 SchematronResourcePure (com.helger.schematron.pure.SchematronResourcePure)1 WrappedCollectingPSErrorHandler (com.helger.schematron.pure.errorhandler.WrappedCollectingPSErrorHandler)1 SchematronResourceSCH (com.helger.schematron.sch.SchematronResourceSCH)1 SchematronResourceSchXslt_XSLT2 (com.helger.schematron.schxslt.xslt2.SchematronResourceSchXslt_XSLT2)1 SchematronResourceXSLT (com.helger.schematron.xslt.SchematronResourceXSLT)1 WrappedCollectingTransformErrorListener (com.helger.xml.transform.WrappedCollectingTransformErrorListener)1 Nonnull (javax.annotation.Nonnull)1