sandygao 2003/03/11 07:49:33 Modified: java/src/org/apache/xerces/impl/msg XMLSchemaMessages.properties java/src/org/apache/xerces/impl/xs XMLSchemaValidator.java Log: Improve some of the schema error messages, to make it easier to understand. Revision Changes Path 1.64 +4 -3 xml-xerces/java/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties Index: XMLSchemaMessages.properties =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties,v retrieving revision 1.63 retrieving revision 1.64 diff -u -r1.63 -r1.64 --- XMLSchemaMessages.properties 12 Feb 2003 14:23:54 -0000 1.63 +++ XMLSchemaMessages.properties 11 Mar 2003 15:49:32 -0000 1.64 @@ -45,9 +45,10 @@ cvc-complex-type.2.1 = cvc-complex-type.2.1: Element ''{0}'' must have no character or element information item [children], because the type's content type is empty. cvc-complex-type.2.2 = cvc-complex-type.2.2: Element ''{0}'' must have no element [children], and the value must be valid. cvc-complex-type.2.3 = cvc-complex-type.2.3: Element ''{0}'' must have no character [children], because the type's content type is element-only. - cvc-complex-type.2.4.a = cvc-complex-type.2.4.a: Invalid content starting with element ''{0}''. The content must match ''{1}''. - cvc-complex-type.2.4.b = cvc-complex-type.2.4.b: The content of element ''{0}'' is not complete. It must match ''{1}''. + cvc-complex-type.2.4.a = cvc-complex-type.2.4.a: Invalid content starting with element ''{0}''. One of ''{1}'' is expected. + cvc-complex-type.2.4.b = cvc-complex-type.2.4.b: The content of element ''{0}'' is not complete. One of ''{1}'' is expected. cvc-complex-type.2.4.c = cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element ''{0}''. + cvc-complex-type.2.4.d = cvc-complex-type.2.4.d: Invalid content starting with element ''{0}''. No child element is expected at this point. cvc-complex-type.3.1 = cvc-complex-type.3.1: Value ''{2}'' of attribute ''{1}'' of element ''{0}'' is not valid with repect to the corresponding attribute use. cvc-complex-type.3.2.1 = cvc-complex-type.3.2.1: Element ''{0}'' does not have an attribute wildcard for attribute ''{1}''. cvc-complex-type.3.2.2 = cvc-complex-type.3.2.2: Attribute ''{1}'' is not allowed to appear in element ''{0}''. 1.136 +21 -5 xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java Index: XMLSchemaValidator.java =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java,v retrieving revision 1.135 retrieving revision 1.136 diff -u -r1.135 -r1.136 --- XMLSchemaValidator.java 10 Mar 2003 22:13:18 -0000 1.135 +++ XMLSchemaValidator.java 11 Mar 2003 15:49:32 -0000 1.136 @@ -1774,11 +1774,14 @@ if (fCurrCMState[0] == XSCMValidator.FIRST_ERROR) { XSComplexTypeDecl ctype = (XSComplexTypeDecl)fCurrentType; //REVISIT: is it the only case we will have particle = null? - if (ctype.fParticle != null) { - reportSchemaError("cvc-complex-type.2.4.a", new Object[]{element.rawname, ctype.fParticle.toString()}); + Vector next; + if (ctype.fParticle != null && + (next = fCurrentCM.whatCanGoHere(fCurrCMState)).size() > 0) { + String expected = expectedStr(next); + reportSchemaError("cvc-complex-type.2.4.a", new Object[]{element.rawname, expected}); } else { - reportSchemaError("cvc-complex-type.2.4.a", new Object[]{element.rawname, "mixed with no element content"}); + reportSchemaError("cvc-complex-type.2.4.d", new Object[]{element.rawname}); } } } @@ -2981,7 +2984,8 @@ } if (fCurrCMState[0] >= 0 && !fCurrentCM.endContentModel(fCurrCMState)) { - reportSchemaError("cvc-complex-type.2.4.b", new Object[]{element.rawname, ((XSParticleDecl)ctype.getParticle()).toString()}); + String expected = expectedStr(fCurrentCM.whatCanGoHere(fCurrCMState)); + reportSchemaError("cvc-complex-type.2.4.b", new Object[]{element.rawname, expected}); } } } @@ -2993,6 +2997,18 @@ fXSIErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN, key, arguments, XMLErrorReporter.SEVERITY_ERROR); + } + + private String expectedStr(Vector expected) { + StringBuffer ret = new StringBuffer("{"); + int size = expected.size(); + for (int i = 0; i < size; i++) { + if (i > 0) + ret.append(", "); + ret.append(expected.elementAt(i).toString()); + } + ret.append('}'); + return ret.toString(); } /**********************************/
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]