use of com.helger.schematron.SchematronException in project ph-schematron by phax.
the class PSXPathBoundSchemaTest method testBindAllInvalidSchematrons.
@Test
public void testBindAllInvalidSchematrons() {
for (final IReadableResource aRes : SchematronTestHelper.getAllInvalidSchematronFiles()) {
System.out.println(aRes);
try {
// Parse the schema
final PSSchema aSchema = new PSReader(aRes).readSchema();
final CollectingPSErrorHandler aCEH = new CollectingPSErrorHandler();
PSXPathQueryBinding.getInstance().bind(aSchema, null, aCEH);
// Either an ERROR was collected or an exception was thrown
assertTrue(aCEH.getErrorList().getMostSevereErrorLevel().isGE(EErrorLevel.ERROR));
} catch (final SchematronException ex) {
System.out.println(" " + ex.getMessage());
}
}
}
use of com.helger.schematron.SchematronException in project ph-schematron by phax.
the class SchematronResourcePure method createBoundSchema.
@Nonnull
protected IPSBoundSchema createBoundSchema() {
final IReadableResource aResource = getResource();
final IPSErrorHandler aErrorHandler = getErrorHandler();
final PSBoundSchemaCacheKey aCacheKey = new PSBoundSchemaCacheKey(aResource, getPhase(), aErrorHandler, getVariableResolver(), getFunctionResolver(), getEntityResolver());
if (aResource instanceof AbstractMemoryReadableResource || !isUseCache()) {
// No need to cache anything for memory resources
try {
return aCacheKey.createBoundSchema();
} catch (final SchematronException ex) {
// Convert to runtime exception
throw new IllegalStateException("Failed to bind Schematron", ex);
}
}
// happens
return PSBoundSchemaCache.getInstance().getFromCache(aCacheKey);
}
Aggregations