Author: mrglavas
Date: Sun Jan 8 21:49:54 2006
New Revision: 367212
URL: http://svn.apache.org/viewcvs?rev=367212&view=rev
Log:
JIRA Issue #1092:
https://issues.apache.org/jira/browse/XERCESJ-1092
Improvements to identity constraint error message reporting. Patch thanks to
George Cristian Bina.
I made some modifications to the original patch, mostly to the text of the
error messages. I've
also removed a couple messages which are no longer in use.
Modified:
xerces/java/trunk/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/Field.java
Modified:
xerces/java/trunk/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
URL:
http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties?rev=367212&r1=367211&r2=367212&view=diff
==============================================================================
---
xerces/java/trunk/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
(original)
+++
xerces/java/trunk/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
Sun Jan 8 21:49:54 2006
@@ -14,20 +14,18 @@
# Identity constraints
- AbsentKeyValue = Identity Constraint error
(cvc-identity-constraint.4.2.1): element \"{0}\" has a key with no value.
+ AbsentKeyValue = cvc-identity-constraint.4.2.1.a: Element \"{0}\" has
no value for the key \"{1}\".
DuplicateField = Duplicate match in scope for field \"{0}\".
- DuplicateKey = Duplicate key value [{0}] declared for identity
constraint of element \"{1}\".
- DuplicateUnique = Duplicate unique value [{0}] declared for identity
constraint of element \"{1}\".
- FieldMultipleMatch = Identity constraint error: field \"{0}\" matches
more than one value within the scope of its selector; fields must match unique
values.
+ DuplicateKey = cvc-identity-constraint.4.2.2: Duplicate key value
[{0}] declared for identity constraint \"{2}\" of element \"{1}\".
+ DuplicateUnique = cvc-identity-constraint.4.1: Duplicate unique value
[{0}] declared for identity constraint \"{2}\" of element \"{1}\".
+ FieldMultipleMatch = cvc-identity-constraint.3: Field \"{0}\" of
identity constraint \"{1}\" matches more than one value within the scope of its
selector; fields must match unique values.
FixedDiffersFromActual = The content of this element is not equivalent
to the value of the \"fixed\" attribute in the element's declaration in the
schema.
- KeyMatchesNillable = Identity Constraint error
(cvc-identity-constraint.4.2.3): element \"{0}\" has a key which matches an
element which has nillable set to true.
- KeyNotEnoughValues = Not enough values specified for <key
name=\"{1}\"> identity constraint specified for element \"{0}\".
- KeyNotFound = Key ''{0}'' with value ''{1}'' not found for identity
constraint of element ''{2}''.
- KeyRefNotEnoughValues = Not enough values specified for <keyref
name=\"{1}\"> identity constraint specified for element \"{0}\".
+ KeyMatchesNillable = cvc-identity-constraint.4.2.3: Element \"{0}\"
has the key \"{1}\" which matches an element which has nillable set to true.
+ KeyNotEnoughValues = cvc-identity-constraint.4.2.1.b: Not enough
values specified for <key name=\"{1}\"> identity constraint specified for
element \"{0}\".
+ KeyNotFound = cvc-identity-constraint.4.3: Key ''{0}'' with value
''{1}'' not found for identity constraint of element ''{2}''.
KeyRefOutOfScope = Identity Constraint error: identity constraint
\"{0}\" has a keyref which refers to a key or unique that is out of scope.
KeyRefReferNotFound = Key reference declaration \"{0}\" refers to
unknown key with name \"{1}\".
- UniqueNotEnoughValues = Not enough values specified for <unique>
identity constraint specified for element \"{0}\".
- UnknownField = Internal identity constraint error; unknown field
\"{0}\".
+ UnknownField = Internal identity constraint error; unknown field
\"{0}\" for identity constraint \"{2}\" specified for element \"{1}\".
# Ideally, we should only use the following error keys, not the ones under
# "Identity constraints". And we should cover all of the following errors.
Modified:
xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
URL:
http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java?rev=367212&r1=367211&r2=367212&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
(original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java Sun
Jan 8 21:49:54 2006
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -3400,7 +3400,8 @@
if (fIdentityConstraint.getCategory() ==
IdentityConstraint.IC_KEY) {
String code = "AbsentKeyValue";
String eName = fIdentityConstraint.getElementName();
- reportSchemaError(code, new Object[] { eName });
+ String cName =
fIdentityConstraint.getIdentityConstraintName();
+ reportSchemaError(code, new Object[] { eName, cName });
}
return;
}
@@ -3415,9 +3416,9 @@
if (fIdentityConstraint.getCategory() ==
IdentityConstraint.IC_KEY) {
String code = "KeyNotEnoughValues";
UniqueOrKey key = (UniqueOrKey) fIdentityConstraint;
- String ename = fIdentityConstraint.getElementName();
- String kname = key.getIdentityConstraintName();
- reportSchemaError(code, new Object[] { ename, kname });
+ String eName = fIdentityConstraint.getElementName();
+ String cName = key.getIdentityConstraintName();
+ reportSchemaError(code, new Object[] { eName, cName });
}
return;
}
@@ -3470,12 +3471,15 @@
// do we even know this field?
if (i == -1) {
String code = "UnknownField";
- reportSchemaError(code, new Object[] { field.toString()});
+ String eName = fIdentityConstraint.getElementName();
+ String cName = fIdentityConstraint.getIdentityConstraintName();
+ reportSchemaError(code, new Object[] { field.toString(),
eName, cName });
return;
}
if (Boolean.TRUE != mayMatch(field)) {
String code = "FieldMultipleMatch";
- reportSchemaError(code, new Object[] { field.toString()});
+ String cName = fIdentityConstraint.getIdentityConstraintName();
+ reportSchemaError(code, new Object[] { field.toString(), cName
});
} else {
fValuesCount++;
}
@@ -3756,8 +3760,9 @@
if (contains()) {
String code = "DuplicateUnique";
String value = toString(fLocalValues);
- String ename = fIdentityConstraint.getElementName();
- reportSchemaError(code, new Object[] { value, ename });
+ String eName = fIdentityConstraint.getElementName();
+ String cName = fIdentityConstraint.getIdentityConstraintName();
+ reportSchemaError(code, new Object[] { value, eName, cName });
}
} // duplicateValue(Hashtable)
@@ -3792,8 +3797,9 @@
if (contains()) {
String code = "DuplicateKey";
String value = toString(fLocalValues);
- String ename = fIdentityConstraint.getElementName();
- reportSchemaError(code, new Object[] { value, ename });
+ String eName = fIdentityConstraint.getElementName();
+ String cName = fIdentityConstraint.getIdentityConstraintName();
+ reportSchemaError(code, new Object[] { value, eName, cName });
}
} // duplicateValue(Hashtable)
Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/Field.java
URL:
http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/Field.java?rev=367212&r1=367211&r2=367212&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/Field.java
(original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/Field.java Sun Jan
8 21:49:54 2006
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2005 The Apache Software Foundation.
+ * Copyright 2001-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -173,7 +173,8 @@
super.matched(actualValue, valueType, itemValueType, isNil);
if(isNil && (fIdentityConstraint.getCategory() ==
IdentityConstraint.IC_KEY)) {
String code = "KeyMatchesNillable";
- fStore.reportError(code, new
Object[]{fIdentityConstraint.getElementName()});
+ fStore.reportError(code,
+ new Object[]{fIdentityConstraint.getElementName(),
fIdentityConstraint.getIdentityConstraintName()});
}
fStore.addValue(Field.this, actualValue,
convertToPrimitiveKind(valueType), convertToPrimitiveKind(itemValueType));
// once we've stored the value for this field, we set the mayMatch
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]