[104413] Fix for DTD validation messages when working disconnected.
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLValidator.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLValidator.java index 2f372dd..f9afc1e 100644 --- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLValidator.java +++ b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLValidator.java
@@ -18,6 +18,7 @@ import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; +import java.net.ConnectException; import java.net.URL; import java.net.UnknownHostException; import java.text.MessageFormat; @@ -65,6 +66,7 @@ private static final String _UI_PROBLEMS_VALIDATING_FILE_NOT_FOUND = "_UI_PROBLEMS_VALIDATING_FILE_NOT_FOUND"; private static final String _UI_PROBLEMS_VALIDATING_UNKNOWN_HOST = "_UI_PROBLEMS_VALIDATING_UNKNOWN_HOST"; + private static final String _UI_PROBLEMS_CONNECTION_REFUSED = "_UI_PROBLEMS_CONNECTION_REFUSED"; private static final String FILE_NOT_FOUND_KEY = "FILE_NOT_FOUND"; @@ -240,26 +242,37 @@ */ protected void addValidationMessage(XMLValidationInfo valinfo, IOException exception) { - String messageStr = exception.getMessage(); - Throwable cause = exception.getCause(); - while(messageStr == null && cause != null){ - cause = exception.getCause(); - if(cause != null){ - messageStr = cause.getMessage(); - } + String validationMessageStr = exception.getMessage(); + Throwable cause = exception.getCause() != null ? exception.getCause() : exception; + while(validationMessageStr == null && cause != null){ + String localizedMessage = cause.getLocalizedMessage(); + cause = cause.getCause(); + if(cause == null && localizedMessage != null ) + { + validationMessageStr = localizedMessage; + } } - if (messageStr != null) + + if (validationMessageStr != null) { - if (exception instanceof FileNotFoundException) + if (cause instanceof FileNotFoundException) { - messageStr = MessageFormat.format(resourceBundle.getString(_UI_PROBLEMS_VALIDATING_FILE_NOT_FOUND), new Object [] { messageStr }); + validationMessageStr = MessageFormat.format(resourceBundle.getString(_UI_PROBLEMS_VALIDATING_FILE_NOT_FOUND), new Object [] { validationMessageStr }); } - else if (exception instanceof UnknownHostException) + else if (cause instanceof UnknownHostException) { - messageStr = MessageFormat.format(resourceBundle.getString(_UI_PROBLEMS_VALIDATING_UNKNOWN_HOST), new Object [] { messageStr }); + validationMessageStr = MessageFormat.format(resourceBundle.getString(_UI_PROBLEMS_VALIDATING_UNKNOWN_HOST), new Object [] { validationMessageStr }); } + else if(cause instanceof ConnectException) + { + validationMessageStr = resourceBundle.getString(_UI_PROBLEMS_CONNECTION_REFUSED); + } + } + + if (validationMessageStr != null) + { XMLLocator locator = valinfo.getXMLLocator(); - valinfo.addError(messageStr, locator != null ? locator.getLineNumber() : 1, locator != null ? locator.getColumnNumber() : 0, valinfo.getFileURI(), FILE_NOT_FOUND_KEY, null); + valinfo.addWarning(validationMessageStr, locator != null ? locator.getLineNumber() : 1, locator != null ? locator.getColumnNumber() : 0, valinfo.getFileURI(), FILE_NOT_FOUND_KEY, null); } }
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/ValidationInfo.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/ValidationInfo.java index 2959cca..378dbf2 100644 --- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/ValidationInfo.java +++ b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/ValidationInfo.java
@@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. + * Copyright (c) 2001, 2005 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 *******************************************************************************/ @@ -111,7 +111,23 @@ */ public void addWarning(String message, int line, int column, String uri) { - addMessage(message, line, column, uri, SEV_WARNING, null, null); + addWarning(message, line, column, uri, null, null); + } + + /** + * + * Add an error message. + * + * @param message The message to add. + * @param line The line location of the message. + * @param column The column location of the message. + * @param uri The URI of the file that contains the message. + * @param key The key for the message. + * @param messageArguments more information about the error + */ + public void addWarning(String message, int line, int column, String uri, String key, Object[] messageArguments) + { + addMessage(message, line, column, uri, SEV_WARNING, key, messageArguments); } /**
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/xmlvalidation.properties b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/xmlvalidation.properties index 9ed380a..35e7142 100644 --- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/xmlvalidation.properties +++ b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/xmlvalidation.properties
@@ -1,10 +1,10 @@ ############################################################################### -# Copyright (c) 2001, 2004 IBM Corporation and others. +# Copyright (c) 2001, 2005 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 ############################################################################### @@ -13,14 +13,16 @@ ! Usage: ! {0} replaced with the host name ! -_UI_PROBLEMS_VALIDATING_UNKNOWN_HOST = Unable to connect to host: "{0}". +_UI_PROBLEMS_VALIDATING_UNKNOWN_HOST = The file cannot be validated as the host "{0}" is currently unreachable. ! Usage: ! {0} replaced with the file name ! -_UI_PROBLEMS_VALIDATING_FILE_NOT_FOUND = File not found: "{0}". +_UI_PROBLEMS_VALIDATING_FILE_NOT_FOUND = The file cannot be validated as the XML Schema "{0}" that is specified as describing the syntax of the file cannot be located. + +_UI_PROBLEMS_CONNECTION_REFUSED = The file cannot be validated as there was a connection problem. ! ! Referenced File Dialog Related Message ! -_UI_REF_FILE_ERROR_MESSAGE = Referenced file contains errors ({0}). For more information, right click on the message and select "Show Details..." \ No newline at end of file +_UI_REF_FILE_ERROR_MESSAGE = Referenced file contains errors ({0}). For more information, right click on the message and select "Show Details..."