Search in sources :

Example 16 with SchematronResourcePure

use of com.helger.schematron.pure.SchematronResourcePure 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 17 with SchematronResourcePure

use of com.helger.schematron.pure.SchematronResourcePure in project ph-schematron by phax.

the class Issue4Test method testReadFromUNCWithInclude.

@Test
public void testReadFromUNCWithInclude() throws Exception {
    final File aSchematronFile = new File("\\\\PC61826\\share\\example-8-5.sch");
    if (aSchematronFile.exists()) {
        final SchematronResourcePure aResPure = SchematronResourcePure.fromFile(aSchematronFile);
        aResPure.setErrorHandler(new LoggingPSErrorHandler());
        aResPure.validateCompletely();
        assertTrue(aResPure.isValidSchematron());
    } else
        s_aLogger.info("Test ignored because file does not exist");
}
Also used : LoggingPSErrorHandler(com.helger.schematron.pure.errorhandler.LoggingPSErrorHandler) File(java.io.File) SchematronResourcePure(com.helger.schematron.pure.SchematronResourcePure) Test(org.junit.Test)

Example 18 with SchematronResourcePure

use of com.helger.schematron.pure.SchematronResourcePure 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 19 with SchematronResourcePure

use of com.helger.schematron.pure.SchematronResourcePure 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

SchematronResourcePure (com.helger.schematron.pure.SchematronResourcePure)19 SchematronOutputType (org.oclc.purl.dsdl.svrl.SchematronOutputType)16 FileSystemResource (com.helger.commons.io.resource.FileSystemResource)13 SVRLMarshaller (com.helger.schematron.svrl.SVRLMarshaller)10 IReadableResource (com.helger.commons.io.resource.IReadableResource)9 Test (org.junit.Test)7 LoggingPSErrorHandler (com.helger.schematron.pure.errorhandler.LoggingPSErrorHandler)6 AbstractSchematronResource (com.helger.schematron.AbstractSchematronResource)5 ClassPathResource (com.helger.commons.io.resource.ClassPathResource)3 ISchematronResource (com.helger.schematron.ISchematronResource)3 CollectingPSErrorHandler (com.helger.schematron.pure.errorhandler.CollectingPSErrorHandler)3 SchematronResourceSCH (com.helger.schematron.xslt.SchematronResourceSCH)3 File (java.io.File)3 Nullable (javax.annotation.Nullable)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 ESchematronMode (com.helger.schematron.ESchematronMode)2