You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2008/12/08 01:12:43 UTC
svn commit: r724224 - in
/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl:
msg/XMLSchemaMessages.properties xs/XMLSchemaValidator.java
Author: mrglavas
Date: Sun Dec 7 16:12:42 2008
New Revision: 724224
URL: http://svn.apache.org/viewvc?rev=724224&view=rev
Log:
Report an error if the name of the root element does not match the name of the specified root element declaration.
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties?rev=724224&r1=724223&r2=724224&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties Sun Dec 7 16:12:42 2008
@@ -67,7 +67,8 @@
cvc-datatype-valid.1.2.1 = cvc-datatype-valid.1.2.1: ''{0}'' is not a valid value for ''{1}''.
cvc-datatype-valid.1.2.2 = cvc-datatype-valid.1.2.2: ''{0}'' is not a valid value of list type ''{1}''.
cvc-datatype-valid.1.2.3 = cvc-datatype-valid.1.2.3: ''{0}'' is not a valid value of union type ''{1}''.
- cvc-elt.1 = cvc-elt.1: Cannot find the declaration of element ''{0}''.
+ cvc-elt.1.a = cvc-elt.1.a: Cannot find the declaration of element ''{0}''.
+ cvc-elt.1.b = cvc-elt.1.b: The name of the element does not match the name of the element declaration. Saw ''{0}''. Expected ''{1}''.
cvc-elt.2 = cvc-elt.2: The value of '{'abstract'}' in the element declaration for ''{0}'' must be false.
cvc-elt.3.1 = cvc-elt.3.1: Attribute ''{1}'' must not appear on element ''{0}'', because the '{'nillable'}' property of ''{0}'' is false.
cvc-elt.3.2.1 = cvc-elt.3.2.1: Element ''{0}'' cannot have character or element information [children], because ''{1}'' is specified.
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java?rev=724224&r1=724223&r2=724224&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java Sun Dec 7 16:12:42 2008
@@ -2006,16 +2006,17 @@
// 1.1.1.1 An element declaration was stipulated by the processor
if (fRootElementDeclaration != null) {
fCurrentElemDecl = fRootElementDeclaration;
+ checkElementMatchesRootElementDecl(fCurrentElemDecl, element);
}
else if (fRootElementDeclQName != null) {
- processRootElementDeclQName();
+ processRootElementDeclQName(fRootElementDeclQName, element);
}
// 1.2.1.1 A type definition was stipulated by the processor
else if (fRootTypeDefinition != null) {
fCurrentType = fRootTypeDefinition;
}
else if (fRootTypeQName != null) {
- processRootTypeQName();
+ processRootTypeQName(fRootTypeQName);
}
}
@@ -2084,7 +2085,7 @@
// of this. - SG
fXSIErrorReporter.fErrorReporter.reportError(
XSMessageFormatter.SCHEMA_DOMAIN,
- "cvc-elt.1",
+ "cvc-elt.1.a",
new Object[] { element.rawname },
XMLErrorReporter.SEVERITY_ERROR);
}
@@ -3414,46 +3415,58 @@
return actualValue;
} // elementLocallyValidComplexType
- void processRootTypeQName() {
- String rootTypeNamespace = fRootTypeQName.getNamespaceURI();
+ void processRootTypeQName(final javax.xml.namespace.QName rootTypeQName) {
+ String rootTypeNamespace = rootTypeQName.getNamespaceURI();
if (rootTypeNamespace != null && rootTypeNamespace.equals(XMLConstants.NULL_NS_URI)) {
rootTypeNamespace = null;
}
if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(rootTypeNamespace)) {
- fCurrentType = SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(fRootTypeQName.getLocalPart());
+ fCurrentType = SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(rootTypeQName.getLocalPart());
}
else {
final SchemaGrammar grammarForRootType = findSchemaGrammar(
XSDDescription.CONTEXT_ELEMENT, rootTypeNamespace, null, null, null);
if (grammarForRootType != null) {
- fCurrentType = grammarForRootType.getGlobalTypeDecl(fRootTypeQName.getLocalPart());
+ fCurrentType = grammarForRootType.getGlobalTypeDecl(rootTypeQName.getLocalPart());
}
}
if (fCurrentType == null) {
- String typeName = (fRootTypeQName.getPrefix().equals(XMLConstants.DEFAULT_NS_PREFIX)) ?
- fRootTypeQName.getLocalPart() :
- fRootTypeQName.getPrefix()+":"+fRootTypeQName.getLocalPart();
+ String typeName = (rootTypeQName.getPrefix().equals(XMLConstants.DEFAULT_NS_PREFIX)) ?
+ rootTypeQName.getLocalPart() :
+ rootTypeQName.getPrefix()+":"+rootTypeQName.getLocalPart();
reportSchemaError("cvc-type.1", new Object[] {typeName});
}
} // processRootTypeQName
- void processRootElementDeclQName() {
- String rootElementDeclNamespace = fRootElementDeclQName.getNamespaceURI();
+ void processRootElementDeclQName(final javax.xml.namespace.QName rootElementDeclQName, final QName element) {
+ String rootElementDeclNamespace = rootElementDeclQName.getNamespaceURI();
if (rootElementDeclNamespace != null && rootElementDeclNamespace.equals(XMLConstants.NULL_NS_URI)) {
rootElementDeclNamespace = null;
}
final SchemaGrammar grammarForRootElement = findSchemaGrammar(
XSDDescription.CONTEXT_ELEMENT, rootElementDeclNamespace, null, null, null);
if (grammarForRootElement != null) {
- fCurrentElemDecl = grammarForRootElement.getGlobalElementDecl(fRootElementDeclQName.getLocalPart());
+ fCurrentElemDecl = grammarForRootElement.getGlobalElementDecl(rootElementDeclQName.getLocalPart());
}
if (fCurrentElemDecl == null) {
- String declName = (fRootElementDeclQName.getPrefix().equals(XMLConstants.DEFAULT_NS_PREFIX)) ?
- fRootElementDeclQName.getLocalPart() :
- fRootElementDeclQName.getPrefix()+":"+fRootElementDeclQName.getLocalPart();
- reportSchemaError("cvc-elt.1", new Object[] {declName});
+ String declName = (rootElementDeclQName.getPrefix().equals(XMLConstants.DEFAULT_NS_PREFIX)) ?
+ rootElementDeclQName.getLocalPart() :
+ rootElementDeclQName.getPrefix()+":"+rootElementDeclQName.getLocalPart();
+ reportSchemaError("cvc-elt.1.a", new Object[] {declName});
+ }
+ else {
+ checkElementMatchesRootElementDecl(fCurrentElemDecl, element);
}
} // processRootElementDeclQName
+
+ void checkElementMatchesRootElementDecl(final XSElementDecl rootElementDecl, final QName element) {
+ // Report an error if the name of the element does
+ // not match the name of the specified element declaration.
+ if (element.localpart != rootElementDecl.fName ||
+ element.uri != rootElementDecl.fTargetNamespace) {
+ reportSchemaError("cvc-elt.1.b", new Object[] {element.rawname, rootElementDecl.fName});
+ }
+ } // checkElementMatchesRootElementDecl
void reportSchemaError(String key, Object[] arguments) {
if (fDoValidation)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org