You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ne...@apache.org on 2001/05/15 19:21:41 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/validators/schema/identity ValueStore.java Field.java XPathMatcher.java
neilg 01/05/15 10:21:40
Modified: java/src/org/apache/xerces/msg SchemaMessages.java
java/src/org/apache/xerces/validators/common
XMLValidator.java
java/src/org/apache/xerces/validators/schema
SchemaMessageProvider.java
java/src/org/apache/xerces/validators/schema/identity
ValueStore.java Field.java XPathMatcher.java
Log:
cvc-identity-constraint.4.2.3: keys that match elements declared to have nillable true.
Revision Changes Path
1.15 +2 -1 xml-xerces/java/src/org/apache/xerces/msg/SchemaMessages.java
Index: SchemaMessages.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/msg/SchemaMessages.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- SchemaMessages.java 2001/05/10 21:39:25 1.14
+++ SchemaMessages.java 2001/05/15 17:20:54 1.15
@@ -63,7 +63,7 @@
* This file contains error and warning messages for the Schema validator
* The messages are arranged in key and value tuples in a ListResourceBundle.
*
- * @version $Id: SchemaMessages.java,v 1.14 2001/05/10 21:39:25 neilg Exp $
+ * @version $Id: SchemaMessages.java,v 1.15 2001/05/15 17:20:54 neilg Exp $
*/
public class SchemaMessages extends ListResourceBundle {
/** The list resource bundle contents. */
@@ -113,6 +113,7 @@
{"FieldMultipleMatch", "Identity constraint error: field \"{0}\" matches more than one value within the scope of its selector; fields must match unique values"},
{"KeyRefOutOfScope", "Identity Constraint error: identity constraint \"{0}\" has a keyref which refers to a key or unique that is out of scope."},
{"AbsentKeyValue", "Identity Constraint error (cvc-identity-constraint.4.2.1): element \"{0}\" has a key with no value."},
+ {"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."},
};
1.148 +13 -2 xml-xerces/java/src/org/apache/xerces/validators/common/XMLValidator.java
Index: XMLValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/common/XMLValidator.java,v
retrieving revision 1.147
retrieving revision 1.148
diff -u -r1.147 -r1.148
--- XMLValidator.java 2001/05/11 18:48:52 1.147
+++ XMLValidator.java 2001/05/15 17:21:05 1.148
@@ -124,7 +124,7 @@
/**
* This class is the super all-in-one validator used by the parser.
*
- * @version $Id: XMLValidator.java,v 1.147 2001/05/11 18:48:52 lehors Exp $
+ * @version $Id: XMLValidator.java,v 1.148 2001/05/15 17:21:05 neilg Exp $
*/
public final class XMLValidator
implements DefaultEntityHandler.EventHandler,
@@ -4616,7 +4616,18 @@
//
// ValueStore methods
//
-
+
+ /* reports an error if an element is matched
+ * has nillable true and is matched by a key.
+ */
+
+ public void reportNilError(IdentityConstraint id) throws Exception {
+ if(id.getType() == IdentityConstraint.KEY) {
+ int code = SchemaMessageProvider.KeyMatchesNillable;
+ reportSchemaError(code, new Object[]{id.getElementName()});
+ }
+ } // reportNilError
+
/**
* Adds the specified value to the value store.
*
1.15 +3 -1 xml-xerces/java/src/org/apache/xerces/validators/schema/SchemaMessageProvider.java
Index: SchemaMessageProvider.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/SchemaMessageProvider.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- SchemaMessageProvider.java 2001/05/10 21:39:30 1.14
+++ SchemaMessageProvider.java 2001/05/15 17:21:16 1.15
@@ -178,9 +178,10 @@
FieldMultipleMatch = 40,
KeyRefOutOfScope = 41,
AbsentKeyValue = 42,
+ KeyMatchesNillable = 43,
// ...
- MSG_MAX_CODE = 43;
+ MSG_MAX_CODE = 44;
//
// Minor Codes
//
@@ -232,6 +233,7 @@
"FieldMultipleMatch",
"KeyRefOutOfScope",
"AbsentKeyValue",
+ "KeyMatchesNillable",
// END
};
}
1.4 +7 -1 xml-xerces/java/src/org/apache/xerces/validators/schema/identity/ValueStore.java
Index: ValueStore.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/identity/ValueStore.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ValueStore.java 2001/05/01 13:56:11 1.3
+++ ValueStore.java 2001/05/15 17:21:25 1.4
@@ -75,7 +75,7 @@
*
* @author Andy Clark, IBM
*
- * @version $Id: ValueStore.java,v 1.3 2001/05/01 13:56:11 neilg Exp $
+ * @version $Id: ValueStore.java,v 1.4 2001/05/15 17:21:25 neilg Exp $
*/
public interface ValueStore {
@@ -92,5 +92,11 @@
* once within a selection scope.
*/
public void addValue(Field field, IDValue value) throws Exception;
+
+ /* report an error if a nillable element is being keyed on.
+ * the implementor must check that a <key> really is present, not a <unique> or <keyref>.
+ * @param: id: the IdentityConstraint that has matched.
+ */
+ public void reportNilError(IdentityConstraint id) throws Exception;
} // interface ValueStore
1.9 +6 -3 xml-xerces/java/src/org/apache/xerces/validators/schema/identity/Field.java
Index: Field.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/identity/Field.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Field.java 2001/05/08 19:55:44 1.8
+++ Field.java 2001/05/15 17:21:28 1.9
@@ -68,7 +68,7 @@
* Schema identity constraint field.
*
* @author Andy Clark, IBM
- * @version $Id: Field.java,v 1.8 2001/05/08 19:55:44 neilg Exp $
+ * @version $Id: Field.java,v 1.9 2001/05/15 17:21:28 neilg Exp $
*/
public class Field {
@@ -206,8 +206,11 @@
* This method is called when the XPath handler matches the
* XPath expression.
*/
- protected void matched(String content, DatatypeValidator val) throws Exception {
- super.matched(content, val);
+ protected void matched(String content, DatatypeValidator val, boolean isNil) throws Exception {
+ super.matched(content, val, isNil);
+ if(isNil) {
+ fStore.reportNilError(fIdentityConstraint);
+ }
fStore.addValue(Field.this, new IDValue(content, val));
// once we've stored the value for this field, we set the mayMatch
// member to false so that, in the same scope, we don't match any more
1.13 +6 -5 xml-xerces/java/src/org/apache/xerces/validators/schema/identity/XPathMatcher.java
Index: XPathMatcher.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/identity/XPathMatcher.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- XPathMatcher.java 2001/05/10 21:39:32 1.12
+++ XPathMatcher.java 2001/05/15 17:21:31 1.13
@@ -61,6 +61,7 @@
import org.apache.xerces.validators.common.XMLAttributeDecl;
import org.apache.xerces.validators.common.XMLElementDecl;
import org.apache.xerces.validators.schema.SchemaGrammar;
+import org.apache.xerces.validators.schema.SchemaSymbols;
import org.apache.xerces.validators.datatype.DatatypeValidator;
import org.apache.xerces.utils.IntStack;
@@ -79,7 +80,7 @@
*
* @author Andy Clark, IBM
*
- * @version $Id: XPathMatcher.java,v 1.12 2001/05/10 21:39:32 neilg Exp $
+ * @version $Id: XPathMatcher.java,v 1.13 2001/05/15 17:21:31 neilg Exp $
*/
public class XPathMatcher {
@@ -237,7 +238,7 @@
* XPath expression. Subclasses can override this method to
* provide default handling upon a match.
*/
- protected void matched(String content, DatatypeValidator val) throws Exception {
+ protected void matched(String content, DatatypeValidator val, boolean isNil) throws Exception {
if (DEBUG_METHODS3) {
System.out.println(toString()+"#matched(\""+normalize(content)+"\")");
}
@@ -434,7 +435,7 @@
XMLAttributeDecl tempAttDecl = new XMLAttributeDecl();
fGrammar.getAttributeDecl(attIndex, tempAttDecl);
DatatypeValidator aValidator = tempAttDecl.datatypeValidator;
- matched(fMatchedString, aValidator);
+ matched(fMatchedString, aValidator, false);
}
}
break;
@@ -519,11 +520,11 @@
if (fBufferContent) {
fBufferContent = false;
fMatchedString = fMatchedBuffer.toString();
- int eIndex = fGrammar.getElementDeclIndex(element, scope);
+ int eIndex = fGrammar.getElementDeclIndex(element, scope);
XMLElementDecl temp = new XMLElementDecl();
fGrammar.getElementDecl(eIndex, temp);
DatatypeValidator val = temp.datatypeValidator;
- matched(fMatchedString, val);
+ matched(fMatchedString, val, (fGrammar.getElementDeclMiscFlags(eIndex) & SchemaSymbols.NILLABLE) != 0);
}
clear();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org