Search in sources :

Example 1 with ResourceStreamSource

use of com.helger.xml.transform.ResourceStreamSource in project ph-schematron by phax.

the class Issue29Test method validateXmlUsingSchematron.

@Nullable
static SchematronOutputType validateXmlUsingSchematron(@Nonnull final IReadableResource aRes) {
    SchematronOutputType ob = null;
    // Must use the XSLT based version, because of "key" usage
    final ISchematronResource aResSCH = new SchematronResourcePure(new ClassPathResource("issues/github29/pbs.sch"));
    if (!aResSCH.isValidSchematron())
        throw new IllegalArgumentException("Invalid Schematron!");
    try {
        final Document aDoc = aResSCH.applySchematronValidation(new ResourceStreamSource(aRes));
        if (aDoc != null) {
            final SVRLMarshaller marshaller = new SVRLMarshaller();
            ob = marshaller.read(aDoc);
        }
    } catch (final Exception pE) {
        pE.printStackTrace();
    }
    return ob;
}
Also used : SchematronOutputType(org.oclc.purl.dsdl.svrl.SchematronOutputType) ISchematronResource(com.helger.schematron.ISchematronResource) ResourceStreamSource(com.helger.xml.transform.ResourceStreamSource) SVRLMarshaller(com.helger.schematron.svrl.SVRLMarshaller) Document(org.w3c.dom.Document) SchematronResourcePure(com.helger.schematron.pure.SchematronResourcePure) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Nullable(javax.annotation.Nullable)

Aggregations

ClassPathResource (com.helger.commons.io.resource.ClassPathResource)1 ISchematronResource (com.helger.schematron.ISchematronResource)1 SchematronResourcePure (com.helger.schematron.pure.SchematronResourcePure)1 SVRLMarshaller (com.helger.schematron.svrl.SVRLMarshaller)1 ResourceStreamSource (com.helger.xml.transform.ResourceStreamSource)1 Nullable (javax.annotation.Nullable)1 SchematronOutputType (org.oclc.purl.dsdl.svrl.SchematronOutputType)1 Document (org.w3c.dom.Document)1