Search in sources :

Example 1 with XMLValidationConfiguration

use of org.eclipse.wst.xml.core.internal.validation.XMLValidationConfiguration in project webtools.sourceediting by eclipse.

the class BaseTestCase method setUp.

/* (non-Javadoc)
   * @see junit.framework.TestCase#setUp()
   */
protected void setUp() throws IOException {
    PLUGIN_ABSOLUTE_PATH = XMLValidatorTestsPlugin.getPluginLocation().toString() + "/";
    configuration = new XMLValidationConfiguration();
    try {
        configuration.setFeature(XMLValidationConfiguration.WARN_NO_GRAMMAR, false);
        configuration.setFeature(XMLValidationConfiguration.INDICATE_NO_GRAMMAR, 0);
    } catch (Exception e) {
        fail("Unable to set the feature on the XML validation configuration.");
    }
}
Also used : XMLValidationConfiguration(org.eclipse.wst.xml.core.internal.validation.XMLValidationConfiguration) IOException(java.io.IOException)

Example 2 with XMLValidationConfiguration

use of org.eclipse.wst.xml.core.internal.validation.XMLValidationConfiguration in project webtools.sourceediting by eclipse.

the class ErrorCustomizationManagerTest method testErrorReportedOnCorrectElement.

/**
 * Test that an error customizer is only called for the
 * correct element.
 */
public void testErrorReportedOnCorrectElement() {
    IErrorMessageCustomizer testCustomizer = new IErrorMessageCustomizer() {

        public String customizeMessage(ElementInformation elementInfo, String key, Object[] arguments) {
            if (elementInfo.getLocalname().equals("child1")) {
                fail("An error was reported for the child1 element.");
            }
            return null;
        }
    };
    ErrorCustomizationRegistry registry = ErrorCustomizationRegistry.getInstance();
    registry.addErrorMessageCustomizer("http://www.example.org/simplenested", testCustomizer);
    try {
        String PLUGIN_ABSOLUTE_PATH = XMLValidatorTestsPlugin.getPluginLocation().toString() + "/";
        String uri = "file:///" + PLUGIN_ABSOLUTE_PATH + "testresources/samples/bugfixes/CustomErrorReportedOnCorrectElement/simplenested.xml";
        XMLValidator validator = new XMLValidator();
        validator.validate(uri, null, new XMLValidationConfiguration());
        validator.validate(uri, null, new XMLValidationConfiguration());
    } catch (IOException e) {
        fail("An exception occurred while running the test:" + e);
    }
}
Also used : XMLValidationConfiguration(org.eclipse.wst.xml.core.internal.validation.XMLValidationConfiguration) IOException(java.io.IOException) XMLValidator(org.eclipse.wst.xml.core.internal.validation.XMLValidator)

Example 3 with XMLValidationConfiguration

use of org.eclipse.wst.xml.core.internal.validation.XMLValidationConfiguration in project webtools.sourceediting by eclipse.

the class Validator method validate.

public ValidationReport validate(String uri, InputStream inputstream, NestedValidatorContext context, ValidationResult result) {
    XMLValidator validator = XMLValidator.getInstance();
    XMLValidationConfiguration configuration = new XMLValidationConfiguration();
    try {
        // Preferences pluginPreferences = XMLCorePlugin.getDefault().getPluginPreferences();
        configuration.setFeature(XMLValidationConfiguration.INDICATE_NO_GRAMMAR, indicateNoGrammar);
        final IPreferencesService preferencesService = Platform.getPreferencesService();
        configuration.setFeature(XMLValidationConfiguration.INDICATE_NO_DOCUMENT_ELEMENT, preferencesService.getInt(XMLCorePlugin.getDefault().getBundle().getSymbolicName(), XMLCorePreferenceNames.INDICATE_NO_DOCUMENT_ELEMENT, -1, fPreferenceScopes));
        configuration.setFeature(XMLValidationConfiguration.USE_XINCLUDE, preferencesService.getBoolean(XMLCorePlugin.getDefault().getBundle().getSymbolicName(), XMLCorePreferenceNames.USE_XINCLUDE, false, fPreferenceScopes));
        configuration.setFeature(XMLValidationConfiguration.HONOUR_ALL_SCHEMA_LOCATIONS, preferencesService.getBoolean(XMLCorePlugin.getDefault().getBundle().getSymbolicName(), XMLCorePreferenceNames.HONOUR_ALL_SCHEMA_LOCATIONS, true, fPreferenceScopes));
    } catch (Exception e) {
    // TODO: Unable to set the preference. Log this problem.
    }
    XMLValidationReport valreport = validator.validate(uri, inputstream, configuration, result, context);
    return valreport;
}
Also used : XMLValidationConfiguration(org.eclipse.wst.xml.core.internal.validation.XMLValidationConfiguration) XMLValidationReport(org.eclipse.wst.xml.core.internal.validation.XMLValidationReport) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService)

Aggregations

XMLValidationConfiguration (org.eclipse.wst.xml.core.internal.validation.XMLValidationConfiguration)3 IOException (java.io.IOException)2 IPreferencesService (org.eclipse.core.runtime.preferences.IPreferencesService)1 XMLValidationReport (org.eclipse.wst.xml.core.internal.validation.XMLValidationReport)1 XMLValidator (org.eclipse.wst.xml.core.internal.validation.XMLValidator)1