Search in sources :

Example 16 with SchematronOutputType

use of org.oclc.purl.dsdl.svrl.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(org.oclc.purl.dsdl.svrl.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 17 with SchematronOutputType

use of org.oclc.purl.dsdl.svrl.SchematronOutputType in project ph-schematron by phax.

the class IssueGC7Test 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(org.oclc.purl.dsdl.svrl.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 18 with SchematronOutputType

use of org.oclc.purl.dsdl.svrl.SchematronOutputType in project ph-schematron by phax.

the class SVRLMarshallerTest 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(org.oclc.purl.dsdl.svrl.SchematronOutputType) Document(org.w3c.dom.Document) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Test(org.junit.Test)

Example 19 with SchematronOutputType

use of org.oclc.purl.dsdl.svrl.SchematronOutputType in project ph-schematron by phax.

the class SVRLMarshallerTest 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 SchematronOutputType aSVRL = new SVRLMarshaller().read(new ClassPathResource("test-xml/goodOrder01.xml"));
    assertNull(aSVRL);
}
Also used : SchematronOutputType(org.oclc.purl.dsdl.svrl.SchematronOutputType) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Test(org.junit.Test)

Example 20 with SchematronOutputType

use of org.oclc.purl.dsdl.svrl.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 aSO == null ? null : new SVRLMarshaller().getAsDocument(aSO);
}
Also used : SchematronOutputType(org.oclc.purl.dsdl.svrl.SchematronOutputType) SVRLMarshaller(com.helger.schematron.svrl.SVRLMarshaller) Nullable(javax.annotation.Nullable)

Aggregations

SchematronOutputType (org.oclc.purl.dsdl.svrl.SchematronOutputType)41 Test (org.junit.Test)20 SVRLMarshaller (com.helger.schematron.svrl.SVRLMarshaller)18 FileSystemResource (com.helger.commons.io.resource.FileSystemResource)17 SchematronResourcePure (com.helger.schematron.pure.SchematronResourcePure)15 ClassPathResource (com.helger.commons.io.resource.ClassPathResource)14 IReadableResource (com.helger.commons.io.resource.IReadableResource)11 Document (org.w3c.dom.Document)8 AbstractSchematronResource (com.helger.schematron.AbstractSchematronResource)6 LoggingPSErrorHandler (com.helger.schematron.pure.errorhandler.LoggingPSErrorHandler)6 ISchematronResource (com.helger.schematron.ISchematronResource)5 SchematronResourceSCH (com.helger.schematron.xslt.SchematronResourceSCH)5 MapBasedXPathFunctionResolver (com.helger.xml.xpath.MapBasedXPathFunctionResolver)5 SVRLFailedAssert (com.helger.schematron.svrl.SVRLFailedAssert)4 File (java.io.File)4 XQueryAsXPathFunctionConverter (com.helger.schematron.xpath.XQueryAsXPathFunctionConverter)3 Nonnull (javax.annotation.Nonnull)3 Nullable (javax.annotation.Nullable)3 CollectingPSErrorHandler (com.helger.schematron.pure.errorhandler.CollectingPSErrorHandler)2 PSReader (com.helger.schematron.pure.exchange.PSReader)2