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 2012/09/04 06:46:01 UTC
svn commit: r1380447 - in
/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl:
dtd/XMLDTDValidator.java validation/ConfigurableValidationState.java
validation/ValidationState.java xs/XMLSchemaValidator.java
Author: mrglavas
Date: Tue Sep 4 04:46:01 2012
New Revision: 1380447
URL: http://svn.apache.org/viewvc?rev=1380447&view=rev
Log:
JIRA Issue #1581: https://issues.apache.org/jira/browse/XERCESJ-1581. Report multiple IDREF errors during DTD and XML Schema validation (in document order).
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dtd/XMLDTDValidator.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/validation/ConfigurableValidationState.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/validation/ValidationState.java
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/dtd/XMLDTDValidator.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dtd/XMLDTDValidator.java?rev=1380447&r1=1380446&r2=1380447&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dtd/XMLDTDValidator.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dtd/XMLDTDValidator.java Tue Sep 4 04:46:01 2012
@@ -17,6 +17,8 @@
package org.apache.xerces.impl.dtd;
+import java.util.Iterator;
+
import org.apache.xerces.impl.Constants;
import org.apache.xerces.impl.RevalidationHandler;
import org.apache.xerces.impl.XMLEntityManager;
@@ -2066,12 +2068,14 @@ public class XMLDTDValidator
// IDREF and IDREFS attr (V_IDREF0)
//
if (fPerformValidation) {
- String value = fValidationState.checkIDRefID();
- if (value != null) {
- fErrorReporter.reportError( XMLMessageFormatter.XML_DOMAIN,
- "MSG_ELEMENT_WITH_ID_REQUIRED",
- new Object[]{value},
- XMLErrorReporter.SEVERITY_ERROR );
+ Iterator invIdRefs = fValidationState.checkIDRefID();
+ if (invIdRefs != null) {
+ while (invIdRefs.hasNext()) {
+ fErrorReporter.reportError( XMLMessageFormatter.XML_DOMAIN,
+ "MSG_ELEMENT_WITH_ID_REQUIRED",
+ new Object[]{invIdRefs.next()},
+ XMLErrorReporter.SEVERITY_ERROR );
+ }
}
}
return;
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/validation/ConfigurableValidationState.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/validation/ConfigurableValidationState.java?rev=1380447&r1=1380446&r2=1380447&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/validation/ConfigurableValidationState.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/validation/ConfigurableValidationState.java Tue Sep 4 04:46:01 2012
@@ -17,6 +17,8 @@
package org.apache.xerces.impl.validation;
+import java.util.Iterator;
+
/**
* <p>An extension of ValidationState which can be configured to turn
* off checking for ID/IDREF errors and unparsed entity errors.</p>
@@ -72,7 +74,7 @@ public class ConfigurableValidationState
* @return null, if ID/IDREF checking is turned off
* otherwise, returns the value of the super implementation
*/
- public final String checkIDRefID() {
+ public final Iterator checkIDRefID() {
return (fIdIdrefChecking) ? super.checkIDRefID() : null;
}
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/validation/ValidationState.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/validation/ValidationState.java?rev=1380447&r1=1380446&r2=1380447&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/validation/ValidationState.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/validation/ValidationState.java Tue Sep 4 04:46:01 2012
@@ -18,7 +18,10 @@
package org.apache.xerces.impl.validation;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.Locale;
import org.apache.xerces.impl.Constants;
@@ -53,7 +56,7 @@ public class ValidationState implements
//REVISIT: Should replace with a lighter structure.
private final HashMap fIdTable = new HashMap();
- private final HashMap fIdRefTable = new HashMap();
+ private final LinkedHashMap fIdRefTable = new LinkedHashMap();
private final static Object fNullValue = new Object();
private TypeValidatorHelper fTypeValidatorHelper = null;
@@ -92,18 +95,23 @@ public class ValidationState implements
/**
* return null if all IDREF values have a corresponding ID value;
- * otherwise return the first IDREF value without a matching ID value.
+ * otherwise return an iterator for all the IDREF values without
+ * a matching ID value.
*/
- public String checkIDRefID () {
+ public Iterator checkIDRefID() {
+ LinkedHashSet missingIDs = null;
Iterator iter = fIdRefTable.keySet().iterator();
String key;
while (iter.hasNext()) {
key = (String) iter.next();
if (!containsID(key)) {
- return key;
+ if (missingIDs == null) {
+ missingIDs = new LinkedHashSet();
+ }
+ missingIDs.add(key);
}
}
- return null;
+ return (missingIDs != null) ? missingIDs.iterator() : null;
}
protected boolean containsID(String name) {
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=1380447&r1=1380446&r2=1380447&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 Tue Sep 4 04:46:01 2012
@@ -2780,10 +2780,12 @@ public class XMLSchemaValidator
// have we reached the end tag of the validation root?
if (fElementDepth == 0) {
// 7 If the element information item is the validation root, it must be valid per Validation Root Valid (ID/IDREF) (3.3.4).
- String invIdRef = fValidationState.checkIDRefID();
+ Iterator invIdRefs = fValidationState.checkIDRefID();
fValidationState.resetIDTables();
- if (invIdRef != null) {
- reportSchemaError("cvc-id.1", new Object[] { invIdRef });
+ if (invIdRefs != null) {
+ while (invIdRefs.hasNext()) {
+ reportSchemaError("cvc-id.1", new Object[] { invIdRefs.next() });
+ }
}
// check extra schema constraints
if (fFullChecking && !fUseGrammarPoolOnly) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org