Search in sources :

Example 21 with FileSystemResource

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

the class SchematronResourceSCHCacheTest method testInvalidSchematron.

@Test
public void testInvalidSchematron() {
    assertFalse(new SchematronResourceSCH(new ClassPathResource("test-sch/invalid01.sch")).isValidSchematron());
    assertFalse(new SchematronResourceSCH(new ClassPathResource("test-sch/this.file.does.not.exists")).isValidSchematron());
    assertFalse(new SchematronResourceSCH(new FileSystemResource("src/test/resources/test-sch/invalid01.sch")).isValidSchematron());
    assertFalse(new SchematronResourceSCH(new FileSystemResource("src/test/resources/test-sch/this.file.does.not.exists")).isValidSchematron());
}
Also used : FileSystemResource(com.helger.commons.io.resource.FileSystemResource) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Test(org.junit.Test)

Example 22 with FileSystemResource

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

the class Issue47Test method validateAndProduceSVRL.

public static void validateAndProduceSVRL(@Nonnull final File aSchematron, final File aXML) throws Exception {
    final SchematronResourcePure aSCH = SchematronResourcePure.fromFile(aSchematron);
    aSCH.setFunctionResolver((aFunctionName, aArity) -> {
        System.out.println(aFunctionName + " - " + aArity);
        return null;
    });
    // 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) SVRLMarshaller(com.helger.schematron.svrl.SVRLMarshaller) FileSystemResource(com.helger.commons.io.resource.FileSystemResource) SchematronResourcePure(com.helger.schematron.pure.SchematronResourcePure)

Example 23 with FileSystemResource

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

the class Issue64Test method validateAndProduceSVRL.

public static void validateAndProduceSVRL(@Nonnull final File aSchematron, final File aXML) throws Exception {
    final SchematronResourcePure aSCH = SchematronResourcePure.fromFile(aSchematron);
    aSCH.setErrorHandler(new LoggingPSErrorHandler());
    // Perform validation
    final SchematronOutputType aSVRL = aSCH.applySchematronValidationToSVRL(new FileSystemResource(aXML));
    assertNotNull(aSVRL);
}
Also used : SchematronOutputType(org.oclc.purl.dsdl.svrl.SchematronOutputType) LoggingPSErrorHandler(com.helger.schematron.pure.errorhandler.LoggingPSErrorHandler) FileSystemResource(com.helger.commons.io.resource.FileSystemResource) SchematronResourcePure(com.helger.schematron.pure.SchematronResourcePure)

Example 24 with FileSystemResource

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

the class Issue8Test method validateAndProduceSVRL.

public static void validateAndProduceSVRL(@Nonnull final File aSchematron, final File aXML) throws Exception {
    final SchematronResourceSCH aSCH = SchematronResourceSCH.fromFile(aSchematron);
    // Assign custom parameters
    aSCH.parameters().put("xyz", "mobile");
    aSCH.parameters().put("expected", "");
    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(org.oclc.purl.dsdl.svrl.SchematronOutputType) SchematronResourceSCH(com.helger.schematron.xslt.SchematronResourceSCH) SVRLMarshaller(com.helger.schematron.svrl.SVRLMarshaller) FileSystemResource(com.helger.commons.io.resource.FileSystemResource)

Example 25 with FileSystemResource

use of com.helger.commons.io.resource.FileSystemResource 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

FileSystemResource (com.helger.commons.io.resource.FileSystemResource)25 SchematronOutputType (org.oclc.purl.dsdl.svrl.SchematronOutputType)18 SVRLMarshaller (com.helger.schematron.svrl.SVRLMarshaller)14 SchematronResourcePure (com.helger.schematron.pure.SchematronResourcePure)13 IReadableResource (com.helger.commons.io.resource.IReadableResource)8 AbstractSchematronResource (com.helger.schematron.AbstractSchematronResource)6 SchematronResourceSCH (com.helger.schematron.xslt.SchematronResourceSCH)6 LoggingPSErrorHandler (com.helger.schematron.pure.errorhandler.LoggingPSErrorHandler)5 ISchematronResource (com.helger.schematron.ISchematronResource)4 PSReader (com.helger.schematron.pure.exchange.PSReader)4 PSSchema (com.helger.schematron.pure.model.PSSchema)4 File (java.io.File)4 Test (org.junit.Test)4 PSPreprocessor (com.helger.schematron.pure.preprocess.PSPreprocessor)3 XMLWriterSettings (com.helger.xml.serialize.write.XMLWriterSettings)3 ICommonsList (com.helger.commons.collection.impl.ICommonsList)2 IError (com.helger.commons.error.IError)2 EErrorLevel (com.helger.commons.error.level.EErrorLevel)2 IErrorList (com.helger.commons.error.list.IErrorList)2 StringHelper (com.helger.commons.string.StringHelper)2