Search in sources :

Example 1 with SchematronResourceSCH

use of com.helger.schematron.sch.SchematronResourceSCH in project ph-schematron by phax.

the class SchematronValidationMojo method execute.

public void execute() throws MojoExecutionException, MojoFailureException {
    StaticLoggerBinder.getSingleton().setMavenLog(getLog());
    if (m_aSchematronFile == null)
        throw new MojoExecutionException("No Schematron file specified!");
    if (m_aSchematronFile.exists() && !m_aSchematronFile.isFile())
        throw new MojoExecutionException("The specified Schematron file " + m_aSchematronFile + " is not a file!");
    if (m_sSchematronProcessingEngine == null)
        throw new MojoExecutionException("An invalid Schematron processing instance is specified! Only one of the following values is allowed: " + StringHelper.getImplodedMapped(", ", ESchematronMode.values(), x -> "'" + x.getID() + "'"));
    if (m_aXmlDirectory == null && m_aXmlErrorDirectory == null)
        throw new MojoExecutionException("No XML directory specified - positive or negative directory must be present!");
    if (m_aXmlDirectory != null) {
        if (m_aXmlDirectory.exists() && !m_aXmlDirectory.isDirectory())
            throw new MojoExecutionException("The specified XML directory " + m_aXmlDirectory + " is not a directory!");
        if (ArrayHelper.isEmpty(m_aXmlIncludes))
            throw new MojoExecutionException("No XML include pattern specified!");
        if (m_aSvrlDirectory != null) {
            if (!m_aSvrlDirectory.exists() && !m_aSvrlDirectory.mkdirs())
                throw new MojoExecutionException("Failed to create the SVRL directory " + m_aSvrlDirectory);
        }
    }
    if (m_aXmlErrorDirectory != null) {
        if (m_aXmlErrorDirectory.exists() && !m_aXmlErrorDirectory.isDirectory())
            throw new MojoExecutionException("The specified erroneous XML directory " + m_aXmlErrorDirectory + " is not a directory!");
        if (ArrayHelper.isEmpty(m_aXmlErrorIncludes))
            throw new MojoExecutionException("No erroneous XML include pattern specified!");
        if (m_aSvrlErrorDirectory != null) {
            if (!m_aSvrlErrorDirectory.exists() && !m_aSvrlErrorDirectory.mkdirs())
                throw new MojoExecutionException("Failed to create the erroneous SVRL directory " + m_aSvrlErrorDirectory);
        }
    }
    // 1. Parse Schematron file
    ISchematronResource aSch;
    IErrorList aSCHErrors;
    switch(ESchematronMode.getFromIDOrNull(m_sSchematronProcessingEngine)) {
        case PURE:
            {
                // pure
                final CollectingPSErrorHandler aErrorHdl = new CollectingPSErrorHandler();
                final SchematronResourcePure aRealSCH = new SchematronResourcePure(new FileSystemResource(m_aSchematronFile));
                aRealSCH.setPhase(m_sPhaseName);
                aRealSCH.setLenient(m_bLenient);
                // language code is ignored
                // custom parameters are ignored
                aRealSCH.setErrorHandler(aErrorHdl);
                aRealSCH.validateCompletely();
                aSch = aRealSCH;
                aSCHErrors = aErrorHdl.getAllErrors();
                break;
            }
        case SCHEMATRON:
            {
                // SCH
                final CollectingTransformErrorListener aErrorHdl = new CollectingTransformErrorListener();
                final SchematronResourceSCH aRealSCH = new SchematronResourceSCH(new FileSystemResource(m_aSchematronFile));
                aRealSCH.setPhase(m_sPhaseName);
                aRealSCH.setLanguageCode(m_sLanguageCode);
                aRealSCH.setForceCacheResult(m_bForceCacheResult);
                aRealSCH.parameters().setAll(m_aCustomParameters);
                aRealSCH.setErrorListener(aErrorHdl);
                aRealSCH.isValidSchematron();
                aSch = aRealSCH;
                aSCHErrors = aErrorHdl.getErrorList();
                break;
            }
        case SCHXSLT_XSLT2:
            {
                // SchXslt
                final CollectingTransformErrorListener aErrorHdl = new CollectingTransformErrorListener();
                final SchematronResourceSchXslt_XSLT2 aRealSCH = new SchematronResourceSchXslt_XSLT2(new FileSystemResource(m_aSchematronFile));
                aRealSCH.setPhase(m_sPhaseName);
                aRealSCH.setLanguageCode(m_sLanguageCode);
                aRealSCH.setForceCacheResult(m_bForceCacheResult);
                aRealSCH.parameters().setAll(m_aCustomParameters);
                aRealSCH.setErrorListener(aErrorHdl);
                aRealSCH.isValidSchematron();
                aSch = aRealSCH;
                aSCHErrors = aErrorHdl.getErrorList();
                break;
            }
        case XSLT:
            {
                // SCH
                final CollectingTransformErrorListener aErrorHdl = new CollectingTransformErrorListener();
                final SchematronResourceXSLT aRealSCH = new SchematronResourceXSLT(new FileSystemResource(m_aSchematronFile));
                // phase is ignored
                // language code is ignored
                aRealSCH.parameters().setAll(m_aCustomParameters);
                aRealSCH.setErrorListener(aErrorHdl);
                aRealSCH.isValidSchematron();
                aSch = aRealSCH;
                aSCHErrors = aErrorHdl.getErrorList();
                break;
            }
        default:
            throw new MojoExecutionException("No handler for processing engine '" + m_sSchematronProcessingEngine + "'");
    }
    if (aSCHErrors != null) {
        // Error validating the Schematrons!!
        boolean bAnyError = false;
        for (final IError aError : aSCHErrors) {
            if (aError.getErrorLevel().isGE(EErrorLevel.ERROR))
                bAnyError = true;
            PluginErrorListener.logIError(buildContext, m_aSchematronFile, aError);
        }
        if (bAnyError)
            throw new MojoExecutionException("The provided Schematron file contains errors. See log for details.");
    }
    getLog().info("Successfully parsed Schematron file '" + m_aSchematronFile.getPath() + "'");
    // 2. for all XML files that match the pattern
    final ICommonsList<String> aErrorMessages = new CommonsArrayList<>();
    if (m_aXmlDirectory != null) {
        // Expect success
        _performValidation(aSch, m_aXmlDirectory, m_aXmlIncludes, m_aXmlExcludes, m_aSvrlDirectory, true, aErrorMessages);
    }
    if (m_aXmlErrorDirectory != null) {
        // Expect error
        _performValidation(aSch, m_aXmlErrorDirectory, m_aXmlErrorIncludes, m_aXmlErrorExcludes, m_aSvrlErrorDirectory, false, aErrorMessages);
    }
    if (!m_bFailFast && aErrorMessages.isNotEmpty()) {
        // Build collecting error message
        aErrorMessages.add(0, aErrorMessages.size() + " errors found:");
        final String sCollectedErrorMessages = StringHelper.getImploded("\n  ", aErrorMessages);
        throw new MojoFailureException(sCollectedErrorMessages);
    }
}
Also used : BuildContext(org.sonatype.plexus.build.incremental.BuildContext) FileIOError(com.helger.commons.io.file.FileIOError) FileOperationManager(com.helger.commons.io.file.FileOperationManager) SchematronResourceSCH(com.helger.schematron.sch.SchematronResourceSCH) IError(com.helger.commons.error.IError) FileSystemResource(com.helger.commons.io.resource.FileSystemResource) Component(org.apache.maven.plugins.annotations.Component) Parameter(org.apache.maven.plugins.annotations.Parameter) SchematronResourceXSLT(com.helger.schematron.xslt.SchematronResourceXSLT) AbstractSVRLMessage(com.helger.schematron.svrl.AbstractSVRLMessage) Mojo(org.apache.maven.plugins.annotations.Mojo) TransformerCustomizerSCH(com.helger.schematron.sch.TransformerCustomizerSCH) SVRLHelper(com.helger.schematron.svrl.SVRLHelper) ESchematronMode(com.helger.schematron.ESchematronMode) MavenProject(org.apache.maven.project.MavenProject) Locale(java.util.Locale) Map(java.util.Map) VisibleForTesting(com.helger.commons.annotation.VisibleForTesting) CollectingTransformErrorListener(com.helger.xml.transform.CollectingTransformErrorListener) LifecyclePhase(org.apache.maven.plugins.annotations.LifecyclePhase) ReturnsMutableCopy(com.helger.commons.annotation.ReturnsMutableCopy) Nonnull(javax.annotation.Nonnull) TransformSourceFactory(com.helger.xml.transform.TransformSourceFactory) Nullable(javax.annotation.Nullable) ArrayHelper(com.helger.commons.collection.ArrayHelper) EErrorLevel(com.helger.commons.error.level.EErrorLevel) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) StringHelper(com.helger.commons.string.StringHelper) SVRLMarshaller(com.helger.schematron.svrl.SVRLMarshaller) StaticLoggerBinder(org.slf4j.impl.StaticLoggerBinder) CollectingPSErrorHandler(com.helger.schematron.pure.errorhandler.CollectingPSErrorHandler) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) File(java.io.File) MojoFailureException(org.apache.maven.plugin.MojoFailureException) ISchematronResource(com.helger.schematron.ISchematronResource) CommonsHashMap(com.helger.commons.collection.impl.CommonsHashMap) SchematronResourceSchXslt_XSLT2(com.helger.schematron.schxslt.xslt2.SchematronResourceSchXslt_XSLT2) ICommonsList(com.helger.commons.collection.impl.ICommonsList) SchematronOutputType(com.helger.schematron.svrl.jaxb.SchematronOutputType) ICommonsMap(com.helger.commons.collection.impl.ICommonsMap) DirectoryScanner(org.codehaus.plexus.util.DirectoryScanner) Since(com.helger.commons.annotation.Since) SchematronResourcePure(com.helger.schematron.pure.SchematronResourcePure) IErrorList(com.helger.commons.error.list.IErrorList) AbstractMojo(org.apache.maven.plugin.AbstractMojo) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) CSchematron(com.helger.schematron.CSchematron) ISchematronResource(com.helger.schematron.ISchematronResource) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) FileSystemResource(com.helger.commons.io.resource.FileSystemResource) CollectingTransformErrorListener(com.helger.xml.transform.CollectingTransformErrorListener) IError(com.helger.commons.error.IError) SchematronResourceXSLT(com.helger.schematron.xslt.SchematronResourceXSLT) SchematronResourceSCH(com.helger.schematron.sch.SchematronResourceSCH) SchematronResourceSchXslt_XSLT2(com.helger.schematron.schxslt.xslt2.SchematronResourceSchXslt_XSLT2) IErrorList(com.helger.commons.error.list.IErrorList) SchematronResourcePure(com.helger.schematron.pure.SchematronResourcePure) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) CollectingPSErrorHandler(com.helger.schematron.pure.errorhandler.CollectingPSErrorHandler)

Example 2 with SchematronResourceSCH

use of com.helger.schematron.sch.SchematronResourceSCH in project ph-schematron by phax.

the class Schematron method execute.

@Override
public void execute() throws BuildException {
    boolean bCanRun = false;
    if (m_aSchematronFile == null)
        _errorOrFail("No Schematron file specified!");
    else if (m_aSchematronFile.exists() && !m_aSchematronFile.isFile())
        _errorOrFail("The specified Schematron file " + m_aSchematronFile + " is not a file!");
    else if (m_eSchematronProcessingEngine == null)
        _errorOrFail("An invalid Schematron processing instance is specified! Only one of the following values is allowed: " + StringHelper.getImplodedMapped(", ", ESchematronMode.values(), x -> "'" + x.getID() + "'"));
    else if (m_aResCollections.isEmpty())
        _errorOrFail("No XML resources to be validated specified! Add e.g. a <fileset> element.");
    else if (m_aSvrlDirectory != null && !m_aSvrlDirectory.exists() && !m_aSvrlDirectory.mkdirs())
        _errorOrFail("Failed to create the SVRL directory " + m_aSvrlDirectory);
    else
        bCanRun = true;
    if (bCanRun) {
        // Set error level
        if (m_aErrorRoles.isNotEmpty()) {
            // Set global default error level determinator
            SVRLHelper.setErrorLevelDeterminator(new DefaultSVRLErrorLevelDeterminator() {

                @Override
                @Nonnull
                public IErrorLevel getErrorLevelFromString(@Nullable final String sFlag) {
                    if (sFlag != null) {
                        // Check custom error roles; #66
                        for (final Schematron.ErrorRole aCustomRole : m_aErrorRoles) if (aCustomRole.equalsIgnoreCase(sFlag))
                            return EErrorLevel.ERROR;
                    }
                    // Fall back to default
                    return super.getErrorLevelFromString(sFlag);
                }
            });
        }
        // 1. Parse Schematron file
        final Locale aDisplayLocale = Locale.US;
        ISchematronResource aSch = null;
        IErrorList aSCHErrors = null;
        switch(m_eSchematronProcessingEngine) {
            case PURE:
                {
                    // pure
                    final CollectingPSErrorHandler aErrorHdl = new CollectingPSErrorHandler();
                    final SchematronResourcePure aRealSCH = new SchematronResourcePure(new FileSystemResource(m_aSchematronFile));
                    aRealSCH.setPhase(m_sPhaseName);
                    aRealSCH.setErrorHandler(aErrorHdl);
                    aRealSCH.setEntityResolver(getEntityResolver());
                    aRealSCH.validateCompletely();
                    aSch = aRealSCH;
                    aSCHErrors = aErrorHdl.getAllErrors();
                    break;
                }
            case SCHEMATRON:
                {
                    // SCH
                    final IStringMap aParams = new StringMap();
                    m_aParameters.forEach(x -> x.addToMap(aParams));
                    if (aParams.isNotEmpty())
                        _info("Using the following custom parameters: " + aParams);
                    final CollectingTransformErrorListener aErrorHdl = new CollectingTransformErrorListener();
                    final SchematronResourceSCH aRealSCH = new SchematronResourceSCH(new FileSystemResource(m_aSchematronFile));
                    aRealSCH.setPhase(m_sPhaseName);
                    aRealSCH.setLanguageCode(m_sLanguageCode);
                    aRealSCH.setForceCacheResult(m_bForceCacheResult);
                    aRealSCH.setErrorListener(aErrorHdl);
                    aRealSCH.setURIResolver(getURIResolver());
                    aRealSCH.setEntityResolver(getEntityResolver());
                    aRealSCH.parameters().setAll(aParams);
                    aRealSCH.isValidSchematron();
                    aSch = aRealSCH;
                    aSCHErrors = aErrorHdl.getErrorList();
                    break;
                }
            case SCHXSLT_XSLT2:
                {
                    // SchXslt
                    final IStringMap aParams = new StringMap();
                    m_aParameters.forEach(x -> x.addToMap(aParams));
                    if (aParams.isNotEmpty())
                        _info("Using the following custom parameters: " + aParams);
                    final CollectingTransformErrorListener aErrorHdl = new CollectingTransformErrorListener();
                    final SchematronResourceSchXslt_XSLT2 aRealSCH = new SchematronResourceSchXslt_XSLT2(new FileSystemResource(m_aSchematronFile));
                    aRealSCH.setPhase(m_sPhaseName);
                    aRealSCH.setLanguageCode(m_sLanguageCode);
                    aRealSCH.setForceCacheResult(m_bForceCacheResult);
                    aRealSCH.setErrorListener(aErrorHdl);
                    aRealSCH.setURIResolver(getURIResolver());
                    aRealSCH.setEntityResolver(getEntityResolver());
                    aRealSCH.parameters().setAll(aParams);
                    aRealSCH.isValidSchematron();
                    aSch = aRealSCH;
                    aSCHErrors = aErrorHdl.getErrorList();
                    break;
                }
            case XSLT:
                {
                    // XSLT
                    final IStringMap aParams = new StringMap();
                    m_aParameters.forEach(x -> x.addToMap(aParams));
                    if (aParams.isNotEmpty())
                        _info("Using the following custom parameters: " + aParams);
                    final CollectingTransformErrorListener aErrorHdl = new CollectingTransformErrorListener();
                    final SchematronResourceXSLT aRealSCH = new SchematronResourceXSLT(new FileSystemResource(m_aSchematronFile));
                    // phase and language are ignored because this was decided when the
                    // XSLT was created
                    aRealSCH.setErrorListener(aErrorHdl);
                    aRealSCH.setURIResolver(getURIResolver());
                    aRealSCH.setEntityResolver(getEntityResolver());
                    aRealSCH.parameters().setAll(aParams);
                    aRealSCH.isValidSchematron();
                    aSch = aRealSCH;
                    aSCHErrors = aErrorHdl.getErrorList();
                    break;
                }
            default:
                _errorOrFail("No handler for processing engine '" + m_eSchematronProcessingEngine + "'");
                break;
        }
        boolean bAnyParsingError = false;
        if (aSCHErrors != null)
            // Error validating the Schematrons!!
            for (final IError aError : aSCHErrors) if (aError.getErrorLevel().isGE(EErrorLevel.ERROR)) {
                _error("Error in Schematron: " + aError.getAsString(aDisplayLocale));
                bAnyParsingError = true;
            } else if (aError.getErrorLevel().isGE(EErrorLevel.WARN))
                _warn("Warning in Schematron: " + aError.getAsString(aDisplayLocale));
            else
                _info("Information in Schematron: " + aError.getAsString(aDisplayLocale));
        if (bAnyParsingError)
            _errorOrFail("The provided Schematron file contains errors. See log for details.");
        else {
            // Schematron is okay
            _info("Successfully parsed Schematron file '" + m_aSchematronFile.getPath() + "'");
            // Start validation
            _performValidation(aSch, m_aResCollections, m_aSvrlDirectory, m_bExpectSuccess);
        }
    }
}
Also used : FileResource(org.apache.tools.ant.types.resources.FileResource) SchematronResourceXSLT(com.helger.schematron.xslt.SchematronResourceXSLT) ESchematronMode(com.helger.schematron.ESchematronMode) Locale(java.util.Locale) Map(java.util.Map) TransformSourceFactory(com.helger.xml.transform.TransformSourceFactory) EntityResolver(org.xml.sax.EntityResolver) ErrorTextProvider(com.helger.commons.error.ErrorTextProvider) DefaultSVRLErrorLevelDeterminator(com.helger.schematron.svrl.DefaultSVRLErrorLevelDeterminator) Resource(org.apache.tools.ant.types.Resource) SVRLMarshaller(com.helger.schematron.svrl.SVRLMarshaller) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) SVRLResourceError(com.helger.schematron.svrl.SVRLResourceError) Serializable(java.io.Serializable) ISchematronResource(com.helger.schematron.ISchematronResource) SchematronResourceSchXslt_XSLT2(com.helger.schematron.schxslt.xslt2.SchematronResourceSchXslt_XSLT2) ICommonsList(com.helger.commons.collection.impl.ICommonsList) FileProvider(org.apache.tools.ant.types.resources.FileProvider) ICommonsMap(com.helger.commons.collection.impl.ICommonsMap) IErrorList(com.helger.commons.error.list.IErrorList) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) OverrideOnDemand(com.helger.commons.annotation.OverrideOnDemand) SchematronResourceSCH(com.helger.schematron.sch.SchematronResourceSCH) IError(com.helger.commons.error.IError) FileSystemResource(com.helger.commons.io.resource.FileSystemResource) URIResolver(javax.xml.transform.URIResolver) UsedViaReflection(com.helger.commons.annotation.UsedViaReflection) ResourceCollection(org.apache.tools.ant.types.ResourceCollection) StringMap(com.helger.commons.collection.attr.StringMap) AbstractSVRLMessage(com.helger.schematron.svrl.AbstractSVRLMessage) TransformerCustomizerSCH(com.helger.schematron.sch.TransformerCustomizerSCH) SVRLHelper(com.helger.schematron.svrl.SVRLHelper) IErrorLevel(com.helger.commons.error.level.IErrorLevel) CollectingTransformErrorListener(com.helger.xml.transform.CollectingTransformErrorListener) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) SVRLNamespaceContext(com.helger.schematron.svrl.SVRLNamespaceContext) EErrorLevel(com.helger.commons.error.level.EErrorLevel) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) FileOperations(com.helger.commons.io.file.FileOperations) StringHelper(com.helger.commons.string.StringHelper) CollectingPSErrorHandler(com.helger.schematron.pure.errorhandler.CollectingPSErrorHandler) BuildException(org.apache.tools.ant.BuildException) File(java.io.File) XMLCatalog(org.apache.tools.ant.types.XMLCatalog) CommonsHashMap(com.helger.commons.collection.impl.CommonsHashMap) SchematronOutputType(com.helger.schematron.svrl.jaxb.SchematronOutputType) IStringMap(com.helger.commons.collection.attr.IStringMap) SchematronResourcePure(com.helger.schematron.pure.SchematronResourcePure) ResourceUtils(org.apache.tools.ant.util.ResourceUtils) Locale(java.util.Locale) StringMap(com.helger.commons.collection.attr.StringMap) IStringMap(com.helger.commons.collection.attr.IStringMap) ISchematronResource(com.helger.schematron.ISchematronResource) Nonnull(javax.annotation.Nonnull) FileSystemResource(com.helger.commons.io.resource.FileSystemResource) CollectingTransformErrorListener(com.helger.xml.transform.CollectingTransformErrorListener) IError(com.helger.commons.error.IError) SchematronResourceXSLT(com.helger.schematron.xslt.SchematronResourceXSLT) SchematronResourceSCH(com.helger.schematron.sch.SchematronResourceSCH) SchematronResourceSchXslt_XSLT2(com.helger.schematron.schxslt.xslt2.SchematronResourceSchXslt_XSLT2) IStringMap(com.helger.commons.collection.attr.IStringMap) IErrorLevel(com.helger.commons.error.level.IErrorLevel) IErrorList(com.helger.commons.error.list.IErrorList) DefaultSVRLErrorLevelDeterminator(com.helger.schematron.svrl.DefaultSVRLErrorLevelDeterminator) SchematronResourcePure(com.helger.schematron.pure.SchematronResourcePure) CollectingPSErrorHandler(com.helger.schematron.pure.errorhandler.CollectingPSErrorHandler)

Example 3 with SchematronResourceSCH

use of com.helger.schematron.sch.SchematronResourceSCH in project ph-schematron by phax.

the class Issue008Test method validateAndProduceSVRL.

public static void validateAndProduceSVRL(@Nonnull final File aSchematron, final File aXML) throws Exception {
    final SchematronResourceSCH aSCH = SchematronResourceSCH.fromFile(aSchematron);
    // Assign custom parameters
    aSCH.parameters().put("xyz", "mobile");
    aSCH.parameters().put("expected", "");
    if (false)
        System.out.println(XMLWriter.getNodeAsString(aSCH.getXSLTProvider().getXSLTDocument()));
    // Perform validation
    final SchematronOutputType aSVRL = aSCH.applySchematronValidationToSVRL(new FileSystemResource(aXML));
    assertNotNull(aSVRL);
    if (false)
        System.out.println(new SVRLMarshaller().getAsString(aSVRL));
}
Also used : SchematronOutputType(com.helger.schematron.svrl.jaxb.SchematronOutputType) SchematronResourceSCH(com.helger.schematron.sch.SchematronResourceSCH) SVRLMarshaller(com.helger.schematron.svrl.SVRLMarshaller) FileSystemResource(com.helger.commons.io.resource.FileSystemResource)

Example 4 with SchematronResourceSCH

use of com.helger.schematron.sch.SchematronResourceSCH in project ph-schematron by phax.

the class Issue101Test method _validateAndProduceSVRL.

private static void _validateAndProduceSVRL(@Nonnull final File aSchematron, @Nonnull final File aXML) throws Exception {
    SchematronDebug.setSaveIntermediateXSLTFiles(true);
    final SchematronResourceSCH aSCH = SchematronResourceSCH.fromFile(aSchematron);
    aSCH.setAllowForeignElements(true);
    // Perform validation
    final SchematronOutputType aSVRL = aSCH.applySchematronValidationToSVRL(new FileSystemResource(aXML));
    assertNotNull(aSVRL);
    LOGGER.info("SVRL:\n" + new SVRLMarshaller().getAsString(aSVRL));
    assertEquals(2, SVRLHelper.getAllFailedAssertionsAndSuccessfulReports(aSVRL).size());
}
Also used : SchematronOutputType(com.helger.schematron.svrl.jaxb.SchematronOutputType) SchematronResourceSCH(com.helger.schematron.sch.SchematronResourceSCH) SVRLMarshaller(com.helger.schematron.svrl.SVRLMarshaller) FileSystemResource(com.helger.commons.io.resource.FileSystemResource)

Example 5 with SchematronResourceSCH

use of com.helger.schematron.sch.SchematronResourceSCH in project ph-schematron by phax.

the class IssueGlobalLetTest method validateAndProduceSVRL.

public static void validateAndProduceSVRL(final File schematron, final File xml) throws Exception {
    final IReadableResource aSchematron = new FileSystemResource(schematron.getAbsoluteFile());
    final IReadableResource anXMLSource = new FileSystemResource(xml.getAbsoluteFile());
    final AbstractSchematronResource pure = new SchematronResourceSCH(aSchematron);
    final SchematronOutputType aSVRL = pure.applySchematronValidationToSVRL(anXMLSource);
    assertNotNull(aSVRL);
    if (false)
        LOGGER.info(new SVRLMarshaller().setFormattedOutput(true).getAsString(aSVRL));
}
Also used : SchematronOutputType(com.helger.schematron.svrl.jaxb.SchematronOutputType) SchematronResourceSCH(com.helger.schematron.sch.SchematronResourceSCH) IReadableResource(com.helger.commons.io.resource.IReadableResource) SVRLMarshaller(com.helger.schematron.svrl.SVRLMarshaller) FileSystemResource(com.helger.commons.io.resource.FileSystemResource) AbstractSchematronResource(com.helger.schematron.AbstractSchematronResource)

Aggregations

SchematronResourceSCH (com.helger.schematron.sch.SchematronResourceSCH)14 FileSystemResource (com.helger.commons.io.resource.FileSystemResource)12 SchematronOutputType (com.helger.schematron.svrl.jaxb.SchematronOutputType)12 SVRLMarshaller (com.helger.schematron.svrl.SVRLMarshaller)11 IReadableResource (com.helger.commons.io.resource.IReadableResource)4 SchematronResourcePure (com.helger.schematron.pure.SchematronResourcePure)4 ISchematronResource (com.helger.schematron.ISchematronResource)3 SchematronResourceSchXslt_XSLT2 (com.helger.schematron.schxslt.xslt2.SchematronResourceSchXslt_XSLT2)3 SchematronResourceXSLT (com.helger.schematron.xslt.SchematronResourceXSLT)3 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)3 Nonnull (javax.annotation.Nonnull)3 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)2 CommonsHashMap (com.helger.commons.collection.impl.CommonsHashMap)2 ICommonsList (com.helger.commons.collection.impl.ICommonsList)2 ICommonsMap (com.helger.commons.collection.impl.ICommonsMap)2 IError (com.helger.commons.error.IError)2 EErrorLevel (com.helger.commons.error.level.EErrorLevel)2 IErrorList (com.helger.commons.error.list.IErrorList)2 StringHelper (com.helger.commons.string.StringHelper)2 AbstractSchematronResource (com.helger.schematron.AbstractSchematronResource)2