Search in sources :

Example 26 with IReadableResource

use of com.helger.commons.io.resource.IReadableResource in project ph-schematron by phax.

the class Issue25Test method testIssue25Valid.

@Test
public void testIssue25Valid() throws Exception {
    final IReadableResource aSCH = new ClassPathResource("test-sch/xfront/example05/check-classifications.sch");
    final IReadableResource aXML = new ClassPathResource("test-sch/xfront/example05/valid-document.xml");
    final SchematronOutputType aSOT = SchematronHelper.applySchematron(new SchematronResourcePure(aSCH), aXML);
    assertNotNull(aSOT);
    assertTrue(SVRLHelper.getAllFailedAssertions(aSOT).isEmpty());
}
Also used : SchematronOutputType(org.oclc.purl.dsdl.svrl.SchematronOutputType) IReadableResource(com.helger.commons.io.resource.IReadableResource) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) SchematronResourcePure(com.helger.schematron.pure.SchematronResourcePure) Test(org.junit.Test)

Example 27 with IReadableResource

use of com.helger.commons.io.resource.IReadableResource in project ph-schematron by phax.

the class Issue6Test method validateAndProduceSVRL.

@SuppressFBWarnings("BC_IMPOSSIBLE_INSTANCEOF")
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 aSCH = new SchematronResourceSCH(aSchematron);
    if (aSCH instanceof SchematronResourcePure)
        ((SchematronResourcePure) aSCH).setErrorHandler(new LoggingPSErrorHandler());
    else
        System.out.println(XMLWriter.getNodeAsString(((SchematronResourceSCH) aSCH).getXSLTProvider().getXSLTDocument()));
    final SchematronOutputType aSVRL = aSCH.applySchematronValidationToSVRL(anXMLSource);
    assertNotNull(aSVRL);
    if (false)
        System.out.println(new SVRLMarshaller().getAsString(aSVRL));
}
Also used : SchematronOutputType(org.oclc.purl.dsdl.svrl.SchematronOutputType) SchematronResourceSCH(com.helger.schematron.xslt.SchematronResourceSCH) LoggingPSErrorHandler(com.helger.schematron.pure.errorhandler.LoggingPSErrorHandler) 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) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 28 with IReadableResource

use of com.helger.commons.io.resource.IReadableResource in project ph-schematron by phax.

the class IssueGC9Test 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 29 with IReadableResource

use of com.helger.commons.io.resource.IReadableResource in project ph-schematron by phax.

the class IssueXsltKeyTest 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)
        System.out.println(new SVRLMarshaller().getAsString(aSVRL));
}
Also used : SchematronOutputType(org.oclc.purl.dsdl.svrl.SchematronOutputType) SchematronResourceSCH(com.helger.schematron.xslt.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 30 with IReadableResource

use of com.helger.commons.io.resource.IReadableResource in project ph-schematron by phax.

the class IssueGC5Test 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 SchematronResourcePure pure = new SchematronResourcePure(aSchematron);
    // final FileOutputStream fos = new FileOutputStream (result);
    // final Result res = new StreamResult (fos);
    // res.setSystemId(result.getAbsolutePath());
    // final SchematronOutputType svrl = pure.applySchematronValidationToSVRL
    // (anXMLSource);
    final SchematronOutputType aSO = SchematronHelper.applySchematron(pure, anXMLSource);
    final List<SVRLFailedAssert> aFailedAsserts = SVRLHelper.getAllFailedAssertions(aSO);
    System.out.println(aFailedAsserts);
}
Also used : SchematronOutputType(org.oclc.purl.dsdl.svrl.SchematronOutputType) SVRLFailedAssert(com.helger.schematron.svrl.SVRLFailedAssert) IReadableResource(com.helger.commons.io.resource.IReadableResource) FileSystemResource(com.helger.commons.io.resource.FileSystemResource) SchematronResourcePure(com.helger.schematron.pure.SchematronResourcePure)

Aggregations

IReadableResource (com.helger.commons.io.resource.IReadableResource)37 Test (org.junit.Test)25 ClassPathResource (com.helger.commons.io.resource.ClassPathResource)18 CascadingStyleSheet (com.helger.css.decl.CascadingStyleSheet)12 LoggingCSSParseErrorHandler (com.helger.css.reader.errorhandler.LoggingCSSParseErrorHandler)12 SchematronOutputType (org.oclc.purl.dsdl.svrl.SchematronOutputType)11 SchematronResourcePure (com.helger.schematron.pure.SchematronResourcePure)9 FileSystemResource (com.helger.commons.io.resource.FileSystemResource)8 CSSWriter (com.helger.css.writer.CSSWriter)8 PSSchema (com.helger.schematron.pure.model.PSSchema)7 SVRLMarshaller (com.helger.schematron.svrl.SVRLMarshaller)7 CSSReaderSettings (com.helger.css.reader.CSSReaderSettings)6 AbstractSchematronResource (com.helger.schematron.AbstractSchematronResource)6 IMicroDocument (com.helger.xml.microdom.IMicroDocument)6 CollectingPSErrorHandler (com.helger.schematron.pure.errorhandler.CollectingPSErrorHandler)5 PSReader (com.helger.schematron.pure.exchange.PSReader)5 IPSErrorHandler (com.helger.schematron.pure.errorhandler.IPSErrorHandler)4 IMicroElement (com.helger.xml.microdom.IMicroElement)3 File (java.io.File)3 Nonnull (javax.annotation.Nonnull)3