Search in sources :

Example 1 with SchematronOutputType

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

the class SchematronResourcePure method applySchematronValidation.

@Nullable
public Document applySchematronValidation(@Nonnull final Node aXMLNode, @Nullable final String sBaseURI) throws Exception {
    ValueEnforcer.notNull(aXMLNode, "XMLNode");
    final SchematronOutputType aSO = applySchematronValidationToSVRL(aXMLNode, sBaseURI);
    return new SVRLMarshaller().getAsDocument(aSO);
}
Also used : SchematronOutputType(com.helger.schematron.svrl.jaxb.SchematronOutputType) SVRLMarshaller(com.helger.schematron.svrl.SVRLMarshaller) Nullable(javax.annotation.Nullable)

Example 2 with SchematronOutputType

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

the class SchematronHelperFuncTest method testReadValidSchematronInvalidXML.

@Test
public void testReadValidSchematronInvalidXML() throws Exception {
    final SchematronOutputType aSO = SchematronResourceSCH.fromClassPath(VALID_SCHEMATRON).applySchematronValidationToSVRL(new ClassPathResource(VALID_XMLINSTANCE + ".does.not.exist"));
    assertNull("Invalid XML", aSO);
}
Also used : SchematronOutputType(com.helger.schematron.svrl.jaxb.SchematronOutputType) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Test(org.junit.Test)

Example 3 with SchematronOutputType

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

the class SchematronHelperFuncTest method testReadInvalidSchematronValidXML.

@Test
public void testReadInvalidSchematronValidXML() throws Exception {
    final SchematronOutputType aSO = SchematronResourceSCH.fromClassPath(VALID_SCHEMATRON + ".does.not.exist").applySchematronValidationToSVRL(new ClassPathResource(VALID_XMLINSTANCE));
    assertNull("Invalid Schematron", aSO);
}
Also used : SchematronOutputType(com.helger.schematron.svrl.jaxb.SchematronOutputType) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Test(org.junit.Test)

Example 4 with SchematronOutputType

use of com.helger.schematron.svrl.jaxb.SchematronOutputType 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 5 with SchematronOutputType

use of com.helger.schematron.svrl.jaxb.SchematronOutputType 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)

Aggregations

SchematronOutputType (com.helger.schematron.svrl.jaxb.SchematronOutputType)56 SVRLMarshaller (com.helger.schematron.svrl.SVRLMarshaller)31 FileSystemResource (com.helger.commons.io.resource.FileSystemResource)30 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 ISchematronResource (com.helger.schematron.ISchematronResource)10 SchematronResourceSCH (com.helger.schematron.sch.SchematronResourceSCH)10 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 SVRLFailedAssert (com.helger.schematron.svrl.SVRLFailedAssert)4 MapBasedXPathFunctionResolver (com.helger.xml.xpath.MapBasedXPathFunctionResolver)4 File (java.io.File)4 Nonnull (javax.annotation.Nonnull)4 LoggingPSValidationHandler (com.helger.schematron.pure.validation.LoggingPSValidationHandler)3 XQueryAsXPathFunctionConverter (com.helger.schematron.pure.xpath.XQueryAsXPathFunctionConverter)3