Search in sources :

Example 31 with SchematronOutputType

use of com.helger.schematron.svrl.jaxb.SchematronOutputType in project ph-schematron by phax.

the class IssueGC6Test 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 SchematronResourcePure(aSchematron);
    final SchematronOutputType aSVRL = pure.applySchematronValidationToSVRL(anXMLSource);
    assertNotNull(aSVRL);
    if (false)
        System.out.println(new SVRLMarshaller().getAsString(aSVRL));
}
Also used : SchematronOutputType(com.helger.schematron.svrl.jaxb.SchematronOutputType) 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) SchematronResourcePure(com.helger.schematron.pure.SchematronResourcePure)

Example 32 with SchematronOutputType

use of com.helger.schematron.svrl.jaxb.SchematronOutputType in project ph-schematron by phax.

the class Issue011Test method validateAndProduceSVRL.

public static void validateAndProduceSVRL(@Nonnull final File aSchematron, final File aXML) throws Exception {
    final SchematronResourcePure aSCH = SchematronResourcePure.fromFile(aSchematron);
    aSCH.setErrorHandler(new LoggingPSErrorHandler());
    assertTrue(aSCH.isValidSchematron());
    // 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) LoggingPSErrorHandler(com.helger.schematron.pure.errorhandler.LoggingPSErrorHandler) SVRLMarshaller(com.helger.schematron.svrl.SVRLMarshaller) FileSystemResource(com.helger.commons.io.resource.FileSystemResource) SchematronResourcePure(com.helger.schematron.pure.SchematronResourcePure)

Example 33 with SchematronOutputType

use of com.helger.schematron.svrl.jaxb.SchematronOutputType in project ph-schematron by phax.

the class Issue016Test method testIssue16.

@Test
public void testIssue16() throws Exception {
    final File schematronFile = new ClassPathResource("issues/github16/sample_schematron.sch").getAsFile();
    final File xmlFile = new ClassPathResource("issues/github16/test.xml").getAsFile();
    final SchematronOutputType outputType = SchematronUtil.validateXMLViaXSLTSchematronFull(schematronFile, xmlFile);
    assertNotNull(outputType);
    final List<SVRLSuccessfulReport> succeededList = SVRLHelper.getAllSuccessfulReports(outputType);
    for (final SVRLSuccessfulReport succeededReport : succeededList) {
        LOGGER.info("Report Test: " + succeededReport.getTest());
    }
    int i = 1;
    final List<SVRLFailedAssert> aFailedList = SVRLHelper.getAllFailedAssertions(outputType);
    for (final SVRLFailedAssert failedAssert : aFailedList) {
        LOGGER.info(i++ + ". Location:" + failedAssert.getLocation());
        LOGGER.info("Test: " + failedAssert.getTest());
        LOGGER.info("Text: " + failedAssert.getText());
        final List<DiagnosticReference> diagnisticReferences = failedAssert.getDiagnisticReferences();
        for (final DiagnosticReference diagnisticRef : diagnisticReferences) {
            LOGGER.info("Diag ref: " + diagnisticRef.getDiagnostic());
            LOGGER.info("Diag text: " + diagnisticRef.getContentAtIndex(0));
        }
    }
    if (aFailedList.isEmpty()) {
        LOGGER.info("PASS");
    } else {
        LOGGER.info("FAIL");
    }
}
Also used : SchematronOutputType(com.helger.schematron.svrl.jaxb.SchematronOutputType) SVRLFailedAssert(com.helger.schematron.svrl.SVRLFailedAssert) DiagnosticReference(com.helger.schematron.svrl.jaxb.DiagnosticReference) SVRLSuccessfulReport(com.helger.schematron.svrl.SVRLSuccessfulReport) File(java.io.File) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Test(org.junit.Test)

Example 34 with SchematronOutputType

use of com.helger.schematron.svrl.jaxb.SchematronOutputType in project ph-schematron by phax.

the class Issue029Test method testGood.

@Test
@Ignore("Takes too long - more than 1 min")
public void testGood() throws Exception {
    final SchematronOutputType aSOT = validateXmlUsingSchematron(new GZIPReadableResource(new ClassPathResource("issues/github29/sample.xml.gz")));
    assertNotNull(aSOT);
    final ICommonsList<SVRLFailedAssert> aErrors = SVRLHelper.getAllFailedAssertions(aSOT);
    assertNotNull(aErrors);
    LOGGER.info("Errors found: " + aErrors);
}
Also used : SchematronOutputType(com.helger.schematron.svrl.jaxb.SchematronOutputType) SVRLFailedAssert(com.helger.schematron.svrl.SVRLFailedAssert) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) GZIPReadableResource(com.helger.commons.io.resource.wrapped.GZIPReadableResource) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 35 with SchematronOutputType

use of com.helger.schematron.svrl.jaxb.SchematronOutputType in project ph-schematron by phax.

the class Issue047Test method validateAndProduceSVRL.

public static void validateAndProduceSVRL(@Nonnull final File aSchematron, final File aXML) throws Exception {
    IXPathConfig aXPathConfig = new XPathConfigBuilder().setXPathFunctionResolver((aFunctionName, aArity) -> {
        System.out.println(aFunctionName + " - " + aArity);
        return null;
    }).build();
    final SchematronResourcePure aSCH = new SchematronResourcePure(new FileSystemResource(aSchematron)).setXPathConfig(aXPathConfig);
    // Perform validation
    final SchematronOutputType aSVRL = aSCH.applySchematronValidationToSVRL(new FileSystemResource(aXML));
    assertNotNull(aSVRL);
    if (false)
        System.out.println(new SVRLMarshaller().getAsString(aSVRL));
}
Also used : IXPathConfig(com.helger.schematron.pure.xpath.IXPathConfig) SVRLMarshaller(com.helger.schematron.svrl.SVRLMarshaller) Assert.assertNotNull(org.junit.Assert.assertNotNull) FileSystemResource(com.helger.commons.io.resource.FileSystemResource) SchematronOutputType(com.helger.schematron.svrl.jaxb.SchematronOutputType) Test(org.junit.Test) SchematronResourcePure(com.helger.schematron.pure.SchematronResourcePure) Nonnull(javax.annotation.Nonnull) File(java.io.File) XPathConfigBuilder(com.helger.schematron.pure.xpath.XPathConfigBuilder) SchematronOutputType(com.helger.schematron.svrl.jaxb.SchematronOutputType) SVRLMarshaller(com.helger.schematron.svrl.SVRLMarshaller) XPathConfigBuilder(com.helger.schematron.pure.xpath.XPathConfigBuilder) FileSystemResource(com.helger.commons.io.resource.FileSystemResource) IXPathConfig(com.helger.schematron.pure.xpath.IXPathConfig) SchematronResourcePure(com.helger.schematron.pure.SchematronResourcePure)

Aggregations

SchematronOutputType (com.helger.schematron.svrl.jaxb.SchematronOutputType)59 SVRLMarshaller (com.helger.schematron.svrl.SVRLMarshaller)33 FileSystemResource (com.helger.commons.io.resource.FileSystemResource)32 Test (org.junit.Test)21 SchematronResourcePure (com.helger.schematron.pure.SchematronResourcePure)18 ClassPathResource (com.helger.commons.io.resource.ClassPathResource)15 IReadableResource (com.helger.commons.io.resource.IReadableResource)13 SchematronResourceSCH (com.helger.schematron.sch.SchematronResourceSCH)12 ISchematronResource (com.helger.schematron.ISchematronResource)11 AbstractSchematronResource (com.helger.schematron.AbstractSchematronResource)9 Document (org.w3c.dom.Document)9 LoggingPSErrorHandler (com.helger.schematron.pure.errorhandler.LoggingPSErrorHandler)7 IXPathConfig (com.helger.schematron.pure.xpath.IXPathConfig)6 XPathConfigBuilder (com.helger.schematron.pure.xpath.XPathConfigBuilder)6 Nonnull (javax.annotation.Nonnull)5 SVRLFailedAssert (com.helger.schematron.svrl.SVRLFailedAssert)4 MapBasedXPathFunctionResolver (com.helger.xml.xpath.MapBasedXPathFunctionResolver)4 File (java.io.File)4 LoggingPSValidationHandler (com.helger.schematron.pure.validation.LoggingPSValidationHandler)3 XQueryAsXPathFunctionConverter (com.helger.schematron.pure.xpath.XQueryAsXPathFunctionConverter)3