use of com.helger.commons.io.resource.ClassPathResource in project ph-schematron by phax.
the class PSPreprocessorTest method testWithTitle.
@Test
public void testWithTitle() throws SchematronException {
final PSPreprocessor aPreprocessor = new PSPreprocessor(PSXPathQueryBinding.getInstance()).setKeepTitles(true).setKeepDiagnostics(true);
final IReadableResource aRes = new ClassPathResource("test-sch/example-3-5.sch");
final IMicroDocument aDoc = SchematronHelper.getWithResolvedSchematronIncludes(aRes);
final PSReader aReader = new PSReader(aRes);
final PSSchema aSchema = aReader.readSchemaFromXML(aDoc.getDocumentElement());
final PSSchema aPreprocessedSchema = aPreprocessor.getAsPreprocessedSchema(aSchema);
assertNotNull(aPreprocessedSchema);
assertTrue(aPreprocessedSchema.isValid(new DoNothingPSErrorHandler()));
// Because titles are not in minimal mode
assertFalse(aPreprocessedSchema.isMinimal());
}
use of com.helger.commons.io.resource.ClassPathResource in project ph-schematron by phax.
the class Issue29Test 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);
s_aLogger.info("Errors found: " + aErrors);
}
use of com.helger.commons.io.resource.ClassPathResource 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;
}
use of com.helger.commons.io.resource.ClassPathResource in project ph-schematron by phax.
the class Issue25Test method testIssue25Invalid.
@Test
public void testIssue25Invalid() throws Exception {
final IReadableResource aSCH = new ClassPathResource("test-sch/xfront/example05/check-classifications.sch");
final IReadableResource aXML = new ClassPathResource("test-sch/xfront/example05/invalid-document.xml");
final SchematronOutputType aSOT = SchematronHelper.applySchematron(new SchematronResourcePure(aSCH), aXML);
assertNotNull(aSOT);
assertTrue(SVRLHelper.getAllFailedAssertions(aSOT).isNotEmpty());
}
use of com.helger.commons.io.resource.ClassPathResource 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());
}
Aggregations