Search in sources :

Example 1 with SchematronInstanceValidator

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());
}
Also used : SchematronInstanceValidator(eu.esdihumboldt.hale.io.schematron.validator.SchematronInstanceValidator) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport)

Example 2 with SchematronInstanceValidator

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;
}
Also used : OpenFileFieldEditor(eu.esdihumboldt.hale.ui.util.io.OpenFileFieldEditor) Composite(org.eclipse.swt.widgets.Composite) SchematronInstanceValidator(eu.esdihumboldt.hale.io.schematron.validator.SchematronInstanceValidator) GridData(org.eclipse.swt.layout.GridData) File(java.io.File)

Aggregations

SchematronInstanceValidator (eu.esdihumboldt.hale.io.schematron.validator.SchematronInstanceValidator)2 IOReport (eu.esdihumboldt.hale.common.core.io.report.IOReport)1 OpenFileFieldEditor (eu.esdihumboldt.hale.ui.util.io.OpenFileFieldEditor)1 File (java.io.File)1 GridData (org.eclipse.swt.layout.GridData)1 Composite (org.eclipse.swt.widgets.Composite)1