Search in sources :

Example 6 with SVRLMarshaller

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

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

Example 8 with SVRLMarshaller

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

the class Issue20140523Test 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 9 with SVRLMarshaller

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

Example 10 with SVRLMarshaller

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

the class Issue54Test method validateAndProduceSVRL.

public static void validateAndProduceSVRL(@Nonnull final File aSchematron, final File aXML) throws Exception {
    final ISchematronResource aSCH = SchematronResourcePure.fromFile(aSchematron);
    // Perform validation
    final SchematronOutputType aSVRL = aSCH.applySchematronValidationToSVRL(new FileSystemResource(aXML));
    assertNotNull(aSVRL);
    if (false)
        System.out.println(new SVRLMarshaller().getAsString(aSVRL));
}
Also used : SchematronOutputType(org.oclc.purl.dsdl.svrl.SchematronOutputType) ISchematronResource(com.helger.schematron.ISchematronResource) SVRLMarshaller(com.helger.schematron.svrl.SVRLMarshaller) FileSystemResource(com.helger.commons.io.resource.FileSystemResource)

Aggregations

SVRLMarshaller (com.helger.schematron.svrl.SVRLMarshaller)18 SchematronOutputType (org.oclc.purl.dsdl.svrl.SchematronOutputType)18 FileSystemResource (com.helger.commons.io.resource.FileSystemResource)13 SchematronResourcePure (com.helger.schematron.pure.SchematronResourcePure)9 IReadableResource (com.helger.commons.io.resource.IReadableResource)7 AbstractSchematronResource (com.helger.schematron.AbstractSchematronResource)6 SchematronResourceSCH (com.helger.schematron.xslt.SchematronResourceSCH)5 ISchematronResource (com.helger.schematron.ISchematronResource)4 Nullable (javax.annotation.Nullable)3 ClassPathResource (com.helger.commons.io.resource.ClassPathResource)2 LoggingPSErrorHandler (com.helger.schematron.pure.errorhandler.LoggingPSErrorHandler)2 PSReader (com.helger.schematron.pure.exchange.PSReader)2 PSSchema (com.helger.schematron.pure.model.PSSchema)2 File (java.io.File)2 Nonnull (javax.annotation.Nonnull)2 OverrideOnDemand (com.helger.commons.annotation.OverrideOnDemand)1 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)1 CommonsHashMap (com.helger.commons.collection.impl.CommonsHashMap)1 ICommonsList (com.helger.commons.collection.impl.ICommonsList)1 ICommonsMap (com.helger.commons.collection.impl.ICommonsMap)1