use of com.helger.schematron.svrl.jaxb.SchematronOutputType in project ph-schematron by phax.
the class IssueGC6Test 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));
}
use of com.helger.schematron.svrl.jaxb.SchematronOutputType in project ph-schematron by phax.
the class Issue011Test 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());
assertTrue(aSCH.isValidSchematron());
// Perform validation
final SchematronOutputType aSVRL = aSCH.applySchematronValidationToSVRL(new FileSystemResource(aXML));
assertNotNull(aSVRL);
if (false)
System.out.println(new SVRLMarshaller().getAsString(aSVRL));
}
use of com.helger.schematron.svrl.jaxb.SchematronOutputType in project ph-schematron by phax.
the class Issue016Test method testIssue16.
@Test
public void testIssue16() throws Exception {
final File schematronFile = new ClassPathResource("issues/github16/sample_schematron.sch").getAsFile();
final File xmlFile = new ClassPathResource("issues/github16/test.xml").getAsFile();
final SchematronOutputType outputType = SchematronUtil.validateXMLViaXSLTSchematronFull(schematronFile, xmlFile);
assertNotNull(outputType);
final List<SVRLSuccessfulReport> succeededList = SVRLHelper.getAllSuccessfulReports(outputType);
for (final SVRLSuccessfulReport succeededReport : succeededList) {
LOGGER.info("Report Test: " + succeededReport.getTest());
}
int i = 1;
final List<SVRLFailedAssert> aFailedList = SVRLHelper.getAllFailedAssertions(outputType);
for (final SVRLFailedAssert failedAssert : aFailedList) {
LOGGER.info(i++ + ". Location:" + failedAssert.getLocation());
LOGGER.info("Test: " + failedAssert.getTest());
LOGGER.info("Text: " + failedAssert.getText());
final List<DiagnosticReference> diagnisticReferences = failedAssert.getDiagnisticReferences();
for (final DiagnosticReference diagnisticRef : diagnisticReferences) {
LOGGER.info("Diag ref: " + diagnisticRef.getDiagnostic());
LOGGER.info("Diag text: " + diagnisticRef.getContentAtIndex(0));
}
}
if (aFailedList.isEmpty()) {
LOGGER.info("PASS");
} else {
LOGGER.info("FAIL");
}
}
use of com.helger.schematron.svrl.jaxb.SchematronOutputType in project ph-schematron by phax.
the class Issue029Test method testGood.
@Test
@Ignore("Takes too long - more than 1 min")
public void testGood() throws Exception {
final SchematronOutputType aSOT = validateXmlUsingSchematron(new GZIPReadableResource(new ClassPathResource("issues/github29/sample.xml.gz")));
assertNotNull(aSOT);
final ICommonsList<SVRLFailedAssert> aErrors = SVRLHelper.getAllFailedAssertions(aSOT);
assertNotNull(aErrors);
LOGGER.info("Errors found: " + aErrors);
}
use of com.helger.schematron.svrl.jaxb.SchematronOutputType in project ph-schematron by phax.
the class Issue047Test method validateAndProduceSVRL.
public static void validateAndProduceSVRL(@Nonnull final File aSchematron, final File aXML) throws Exception {
IXPathConfig aXPathConfig = new XPathConfigBuilder().setXPathFunctionResolver((aFunctionName, aArity) -> {
System.out.println(aFunctionName + " - " + aArity);
return null;
}).build();
final SchematronResourcePure aSCH = new SchematronResourcePure(new FileSystemResource(aSchematron)).setXPathConfig(aXPathConfig);
// Perform validation
final SchematronOutputType aSVRL = aSCH.applySchematronValidationToSVRL(new FileSystemResource(aXML));
assertNotNull(aSVRL);
if (false)
System.out.println(new SVRLMarshaller().getAsString(aSVRL));
}
Aggregations