Search in sources :

Example 6 with SchematronOutputType

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

Example 7 with SchematronOutputType

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

the class SVRLMarshallerFuncTest method testWriteValid.

@Test
public void testWriteValid() throws Exception {
    final Document aDoc = SchematronResourceSCH.fromClassPath(VALID_SCHEMATRON).applySchematronValidation(new ClassPathResource(VALID_XMLINSTANCE));
    assertNotNull(aDoc);
    final SchematronOutputType aSO = new SVRLMarshaller().read(aDoc);
    // Create XML
    final Document aDoc2 = new SVRLMarshaller().getAsDocument(aSO);
    assertNotNull(aDoc2);
    assertEquals(CSVRL.SVRL_NAMESPACE_URI, aDoc2.getDocumentElement().getNamespaceURI());
    // Create String
    final String sDoc2 = new SVRLMarshaller().getAsString(aSO);
    assertTrue(StringHelper.hasText(sDoc2));
    assertTrue(sDoc2.contains(CSVRL.SVRL_NAMESPACE_URI));
}
Also used : SchematronOutputType(com.helger.schematron.svrl.jaxb.SchematronOutputType) Document(org.w3c.dom.Document) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Test(org.junit.Test)

Example 8 with SchematronOutputType

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

the class SVRLMarshallerFuncTest method testReadInvalidSchematron.

@Test
public void testReadInvalidSchematron() {
    try {
        // Read null
        new SVRLMarshaller().read((Node) null);
        fail();
    } catch (final NullPointerException ex) {
    }
    try {
        // Read empty XML
        new SVRLMarshaller().read(XMLFactory.newDocument());
        fail();
    } catch (final NullPointerException ex) {
    }
    // Read XML that is not SVRL
    final ClassPathResource aRes = new ClassPathResource("test-xml/goodOrder01.xml");
    assertTrue(aRes.exists());
    final SchematronOutputType aSVRL = new SVRLMarshaller().read(aRes);
    assertNull(aSVRL);
}
Also used : SchematronOutputType(com.helger.schematron.svrl.jaxb.SchematronOutputType) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Test(org.junit.Test)

Example 9 with SchematronOutputType

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

the class Issue085Test method validateAndProduceSVRL.

public static void validateAndProduceSVRL(@Nonnull final File aSchematron, final File aXML) throws Exception {
    final SchematronResourceSCH aSCH = SchematronResourceSCH.fromFile(aSchematron);
    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 10 with SchematronOutputType

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

the class Issue108Test method _validateAndProduceSVRL.

private static void _validateAndProduceSVRL(@Nonnull final File aSchematron, @Nonnull final File aXML) throws Exception {
    SchematronDebug.setSaveIntermediateXSLTFiles(true);
    final ISchematronResource aSCH = SchematronResourceSCH.fromFile(aSchematron);
    // Perform validation
    final SchematronOutputType aSVRL = aSCH.applySchematronValidationToSVRL(new FileSystemResource(aXML));
    assertNotNull(aSVRL);
    LOGGER.info("SVRL:\n" + new SVRLMarshaller().getAsString(aSVRL));
    if (false)
        assertTrue(SVRLHelper.getAllFailedAssertionsAndSuccessfulReports(aSVRL).isEmpty());
}
Also used : SchematronOutputType(com.helger.schematron.svrl.jaxb.SchematronOutputType) ISchematronResource(com.helger.schematron.ISchematronResource) 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