[132230] Provide support for alternative XML Schema validator implementations
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/AbstractNestedValidator.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/AbstractNestedValidator.java index 0f363e8..bef6d16 100644 --- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/AbstractNestedValidator.java +++ b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/AbstractNestedValidator.java
@@ -100,7 +100,7 @@ // Should I know that I'm validating a project as opposed to files? else { - Object []parms = {this.getClass().getName()}; + Object []parms = {getValidatorID()}; Collection files = (Collection) context.loadModel(GET_PROJECT_FILES, parms); Iterator iter = files.iterator(); while (iter.hasNext() && !reporter.isCancelled()) @@ -120,6 +120,18 @@ } /** + * Provides the id of this validator. The ID is used by the validation + * framework. It usually is the fully qualified class name of the class + * implementing the IValidator interface. + * + * @return a String with the ID of this validator. + */ + protected String getValidatorID() + { + return this.getClass().getName(); + } + + /** * Get the name of this validator. The name will be reported to the * validation framework. * Subclasses must implement this method.
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/DelegatingSourceValidator.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/DelegatingSourceValidator.java index e9db1ae..6dc6364 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/DelegatingSourceValidator.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/DelegatingSourceValidator.java
@@ -17,6 +17,7 @@ import java.util.List; import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.Path; @@ -28,6 +29,7 @@ import org.eclipse.wst.validation.internal.core.IMessageAccess; import org.eclipse.wst.validation.internal.core.ValidationException; import org.eclipse.wst.validation.internal.provisional.core.IMessage; +import org.eclipse.wst.validation.internal.provisional.core.IProjectValidationContext; import org.eclipse.wst.validation.internal.provisional.core.IReporter; import org.eclipse.wst.validation.internal.provisional.core.IValidationContext; import org.eclipse.wst.validation.internal.provisional.core.IValidator; @@ -75,7 +77,7 @@ } // My Implementation of IHelper - class MyHelper implements IValidationContext { + class MyHelper implements IProjectValidationContext { InputStream inputStream; IFile file; @@ -108,6 +110,13 @@ return new String[]{file.getFullPath().toString()}; return new String[0]; } + + public IProject getProject() { + if (file != null) { + return file.getProject(); + } + return null; + } } // My Implementation of IReporter
diff --git a/bundles/org.eclipse.wst.xsd.core/plugin.properties b/bundles/org.eclipse.wst.xsd.core/plugin.properties index 4aea974..31c32c9 100644 --- a/bundles/org.eclipse.wst.xsd.core/plugin.properties +++ b/bundles/org.eclipse.wst.xsd.core/plugin.properties
@@ -17,5 +17,6 @@ XSD_Content_Type=XSD _UI_XML_SCHEMA_VALIDATOR = XML Schema Validator +_UI_XERCES_VALIDATOR_DELEGATE = Xerces-based XML Schema Validator Bundle-Vendor.0 = Eclipse.org \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.core/plugin.xml b/bundles/org.eclipse.wst.xsd.core/plugin.xml index dbe1792..e4a0932 100644 --- a/bundles/org.eclipse.wst.xsd.core/plugin.xml +++ b/bundles/org.eclipse.wst.xsd.core/plugin.xml
@@ -40,7 +40,7 @@ <run async="true" - class="org.eclipse.wst.xsd.core.internal.validation.eclipse.Validator" + class="org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator" enabled="true" fullBuild="true" incremental="true"> @@ -48,4 +48,12 @@ </validator> </extension> + <extension + point="org.eclipse.wst.validation.validatorDelegates"> + <delegate + class="org.eclipse.wst.xsd.core.internal.validation.eclipse.Validator" + name="%_UI_XERCES_VALIDATOR_DELEGATE" + target="org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator"/> + </extension> + </plugin>
diff --git a/bundles/org.eclipse.wst.xsd.core/src-validation/org/eclipse/wst/xsd/core/internal/validation/eclipse/Validator.java b/bundles/org.eclipse.wst.xsd.core/src-validation/org/eclipse/wst/xsd/core/internal/validation/eclipse/Validator.java index 13acc4d..1b7f773 100644 --- a/bundles/org.eclipse.wst.xsd.core/src-validation/org/eclipse/wst/xsd/core/internal/validation/eclipse/Validator.java +++ b/bundles/org.eclipse.wst.xsd.core/src-validation/org/eclipse/wst/xsd/core/internal/validation/eclipse/Validator.java
@@ -73,4 +73,16 @@ message.setAttribute(SQUIGGLE_NAME_OR_VALUE_ATTRIBUTE, messageInfo[1]); } } + + /* + * (non-Javadoc) + * @see org.eclipse.wst.xml.core.internal.validation.core.AbstractNestedValidator#getValidatorID() + */ + protected String getValidatorID() + { + // Because this class is used as a delegate, return the id of the validator + // which delegates to this class. + + return XSDDelegatingValidator.class.getName(); + } }
diff --git a/bundles/org.eclipse.wst.xsd.core/src-validation/org/eclipse/wst/xsd/core/internal/validation/eclipse/XSDDelegatingValidator.java b/bundles/org.eclipse.wst.xsd.core/src-validation/org/eclipse/wst/xsd/core/internal/validation/eclipse/XSDDelegatingValidator.java new file mode 100644 index 0000000..3f615ba --- /dev/null +++ b/bundles/org.eclipse.wst.xsd.core/src-validation/org/eclipse/wst/xsd/core/internal/validation/eclipse/XSDDelegatingValidator.java
@@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.xsd.core.internal.validation.eclipse; + +import org.eclipse.wst.validation.internal.delegates.DelegatingValidator; + +/** + * This class provides a unique name (class name) which the validation framework + * will use to identify the XSD validator. The actual delegating validator + * functionality is provided by the base class. The actual validation + * functionality is provided by the delegates registered with this class as + * their target. + */ +public class XSDDelegatingValidator extends DelegatingValidator +{ + /** + * Default constructor. + */ + public XSDDelegatingValidator() + { + } +}