use of eu.esdihumboldt.hale.io.schematron.validator.SchematronInstanceValidator in project hale by halestudio.
the class SchematronInstanceValidatorTest method testValidate.
private void testValidate(String schematronResource, String xmlResource, boolean expectSuccess) throws Exception {
SchematronInstanceValidator validator = new SchematronInstanceValidator();
validator.setSource(new ResourceInputSupplier(getClass(), xmlResource));
validator.setSchematronLocation(getClass().getResource(schematronResource).toURI());
IOReport report = validator.execute(null);
assertEquals("Unexpected report result", expectSuccess, report.isSuccess());
}
use of eu.esdihumboldt.hale.io.schematron.validator.SchematronInstanceValidator in project hale by halestudio.
the class SchematronValidatorConfigurationDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
// create composite
Composite composite = (Composite) super.createDialogArea(parent);
Composite container = new Composite(composite, SWT.NONE);
GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
container.setLayoutData(data);
schematronRulesFile = new OpenFileFieldEditor("metadataFile", "Schematron schema file", true, FileFieldEditor.VALIDATE_ON_KEY_STROKE, container);
schematronRulesFile.setEmptyStringAllowed(false);
schematronRulesFile.setFilterNames(new String[] { "Schematron schema (*.xml, *.sch)" });
schematronRulesFile.setFileExtensions(new String[] { "*.xml; *.sch" });
SchematronInstanceValidator validator = this.getProvider();
if (validator != null && validator.getSchematronLocation() != null && validator.getSchematronLocation().getScheme().equals("file")) {
File file = new File(validator.getSchematronLocation().getPath());
schematronRulesFile.setStringValue(file.getAbsolutePath());
} else {
// isValid starts with false even if emptyStringAllowed is true.
// -> force validation hack
schematronRulesFile.setStringValue(" ");
schematronRulesFile.setStringValue("");
}
return composite;
}
Aggregations