313405 - better validation for persistence and orm xml when content is not valid. Checking in patch for Paul.
diff --git a/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties b/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties
index 9e4e16b..7ef934e 100644
--- a/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties
+++ b/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties
@@ -14,13 +14,14 @@
 PROJECT_NO_PERSISTENCE_XML=No persistence.xml file found in project
 PROJECT_MULTIPLE_PERSISTENCE_XML=Multiple persistence.xml files in project
 XML_VERSION_NOT_LATEST=A more recent version of this document is supported by this JPA platform
-PERSISTENCE_XML_INVALID_CONTENT=Invalid content (no root node)
+PERSISTENCE_XML_INVALID_CONTENT=The persistence.xml file does not have recognized content.
+PERSISTENCE_XML_UNSUPPORTED_CONTENT=The persistence.xml file does not have supported content for this JPA platform.
 PERSISTENCE_NO_PERSISTENCE_UNIT=No persistence unit defined
 PERSISTENCE_MULTIPLE_PERSISTENCE_UNITS=Multiple persistence units defined - only the first persistence unit will be recognized
 PERSISTENCE_UNIT_UNSPECIFIED_MAPPING_FILE=Unspecified mapping file
-PERSISTENCE_UNIT_UNSUPPORTED_MAPPING_FILE_CONTENT=Mapping file \"{0}\" does not have supported content for this JPA platform
-PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE=Mapping file \"{0}\" cannot be resolved
-PERSISTENCE_UNIT_INVALID_MAPPING_FILE=Mapping file \"{0}\" does not have ORM content
+PERSISTENCE_UNIT_UNSUPPORTED_MAPPING_FILE_CONTENT=Mapping file {0} does not have supported content for this JPA platform.
+PERSISTENCE_UNIT_INVALID_MAPPING_FILE=Mapping file {0} does not have recognized content.
+PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE=Mapping file \"{0}\" cannot be resolved.
 PERSISTENCE_UNIT_DUPLICATE_MAPPING_FILE=Duplicate mapping file \"{0}\"
 PERSISTENCE_UNIT_UNSPECIFIED_CLASS=Unspecified class
 PERSISTENCE_UNIT_NONEXISTENT_CLASS=Class \"{0}\" cannot be resolved
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractMappingFileRef.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractMappingFileRef.java
index 9594048..c38e23e 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractMappingFileRef.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractMappingFileRef.java
@@ -225,55 +225,53 @@
 	@Override
 	public void validate(List<IMessage> messages, IReporter reporter) {
 		super.validate(messages, reporter);
-
+		
 		if (StringTools.stringIsEmpty(this.fileName)) {
 			messages.add(
 				DefaultJpaValidationMessages.buildMessage(
 					IMessage.HIGH_SEVERITY,
 					JpaValidationMessages.PERSISTENCE_UNIT_UNSPECIFIED_MAPPING_FILE,
 					this,
-					this.getValidationTextRange()
-				)
-			);
+					this.getValidationTextRange()));
 			return;
 		}
-
+		
 		if (this.mappingFile == null) {
-			messages.add(
-				DefaultJpaValidationMessages.buildMessage(
-					IMessage.HIGH_SEVERITY,
-					this.buildMissingMappingFileMessageID(),
-					new String[] {this.fileName},
-					this,
-					this.getValidationTextRange()
-				)
-			);
+			messages.add(buildMappingFileValidationMessage());
 			return;
 		}
-
-		if (this.mappingFile.getRoot() == null) {
-			messages.add(
-				DefaultJpaValidationMessages.buildMessage(
-					IMessage.HIGH_SEVERITY,
-					JpaValidationMessages.PERSISTENCE_UNIT_INVALID_MAPPING_FILE,
-					new String[] {this.fileName},
-					this,
-					this.getValidationTextRange()
-				)
-			);
-		}
-
+		
 		this.mappingFile.validate(messages, reporter);
 	}
-
-	protected String buildMissingMappingFileMessageID() {
-		return this.getPlatformFile().exists() ?
-					JpaValidationMessages.PERSISTENCE_UNIT_UNSUPPORTED_MAPPING_FILE_CONTENT :
-					JpaValidationMessages.PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE;
+	
+	protected IMessage buildMappingFileValidationMessage() {
+		int severity = IMessage.HIGH_SEVERITY;
+		IFile file = getPlatformFile();
+		if (file.exists()) {
+			JpaXmlResource xmlResource = getJpaProject().getMappingFileXmlResource(this.fileName);
+			if (xmlResource != null 
+					&& ! getJpaPlatform().supportsResourceType(xmlResource.getResourceType())) {
+				return DefaultJpaValidationMessages.buildMessage(
+					severity,
+					JpaValidationMessages.PERSISTENCE_UNIT_UNSUPPORTED_MAPPING_FILE_CONTENT,
+					new String[] {file.getName()},
+					file);
+			}
+			return DefaultJpaValidationMessages.buildMessage(
+				severity,
+				JpaValidationMessages.PERSISTENCE_UNIT_INVALID_MAPPING_FILE,
+				new String[] {file.getName()},
+				file);
+		}
+		return DefaultJpaValidationMessages.buildMessage(
+			severity,
+			JpaValidationMessages.PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE,
+			new String[] {this.fileName},
+			this,
+			getValidationTextRange());
 	}
-
+	
 	protected IFile getPlatformFile() {
 		return this.getJpaProject().convertToPlatformFile(this.fileName);
 	}
-
 }
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/GenericRootContextNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/GenericRootContextNode.java
index 2c9fa06..1625ac7 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/GenericRootContextNode.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/GenericRootContextNode.java
@@ -192,13 +192,7 @@
 		}
 
 		if (this.persistenceXml == null) {
-			messages.add(
-				DefaultJpaValidationMessages.buildMessage(
-					IMessage.HIGH_SEVERITY,
-					this.buildMissingFileMessageID(),
-					this
-				)
-			);
+			messages.add(buildPersistenceXmlValidationMessage());
 			return;
 		}
 		if ( ! this.jpaProject.discoversAnnotatedClasses()) {
@@ -207,10 +201,27 @@
 		this.persistenceXml.validate(messages, reporter);
 	}
 
-	protected String buildMissingFileMessageID() {
-		return this.getPlatformFile().exists() ?
-					JpaValidationMessages.PERSISTENCE_XML_INVALID_CONTENT :
-					JpaValidationMessages.PROJECT_NO_PERSISTENCE_XML;
+	protected IMessage buildPersistenceXmlValidationMessage() {
+		int severity = IMessage.HIGH_SEVERITY;
+		IFile file = getPlatformFile();
+		if (file.exists()) {
+			JpaXmlResource xmlResource = this.jpaProject.getPersistenceXmlResource();
+			if (xmlResource != null 
+					&& ! getJpaPlatform().supportsResourceType(xmlResource.getResourceType())) {
+				return DefaultJpaValidationMessages.buildMessage(
+					severity,
+					JpaValidationMessages.PERSISTENCE_XML_UNSUPPORTED_CONTENT,
+					file);
+			}
+			return DefaultJpaValidationMessages.buildMessage(
+				severity,
+				JpaValidationMessages.PERSISTENCE_XML_INVALID_CONTENT,
+				file);
+		}
+		return DefaultJpaValidationMessages.buildMessage(
+			severity,
+			JpaValidationMessages.PROJECT_NO_PERSISTENCE_XML,
+			this);
 	}
 
 	protected IFile getPlatformFile() {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java
index f99cf1d..d559a91 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java
@@ -21,6 +21,7 @@
 	public static final String PROJECT_MULTIPLE_PERSISTENCE_XML = "PROJECT_MULTIPLE_PERSISTENCE_XML";
 	public static final String XML_VERSION_NOT_LATEST = "XML_VERSION_NOT_LATEST";
 	public static final String PERSISTENCE_XML_INVALID_CONTENT = "PERSISTENCE_XML_INVALID_CONTENT";
+	public static final String PERSISTENCE_XML_UNSUPPORTED_CONTENT = "PERSISTENCE_XML_UNSUPPORTED_CONTENT";
 	public static final String PERSISTENCE_NO_PERSISTENCE_UNIT = "PERSISTENCE_NO_PERSISTENCE_UNIT";
 	public static final String PERSISTENCE_MULTIPLE_PERSISTENCE_UNITS = "PERSISTENCE_MULTIPLE_PERSISTENCE_UNITS";
 	public static final String PERSISTENCE_UNIT_UNSPECIFIED_MAPPING_FILE = "PERSISTENCE_UNIT_UNSPECIFIED_MAPPING_FILE";
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/base/BaseJpaPlatformUi.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/base/BaseJpaPlatformUi.java
index 04e3c10..d08d7af 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/base/BaseJpaPlatformUi.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/base/BaseJpaPlatformUi.java
@@ -160,6 +160,7 @@
 				return definition;
 			}
 		}
+		// TODO (bug 313632) - return a null resource ui definition?
 		throw new IllegalArgumentException("No resource UI definition for the resource type: " + resourceType); //$NON-NLS-1$
 	}
 	
@@ -168,6 +169,7 @@
 			return (MappingResourceUiDefinition) getResourceUiDefinition(resourceType);
 		}
 		catch (ClassCastException cce) {
+			// TODO (bug 313632) - return a null resource ui definition?
 			throw new IllegalArgumentException("No mapping resource UI definition for the resource type: " + resourceType, cce); //$NON-NLS-1$
 		}
 	}