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 2003/08/21 22:41:49 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/dtd XMLDTDProcessor.java XMLDTDValidator.java
mrglavas 2003/08/21 13:41:49
Modified: java/src/org/apache/xerces/impl/dtd XMLDTDProcessor.java
XMLDTDValidator.java
Log:
Fixing E2: Check uniqueness of enum lists when attdecl is validated instead of once for each instance in the document. Before, a list may have been checked none or many times.
Revision Changes Path
1.8 +23 -1 xml-xerces/java/src/org/apache/xerces/impl/dtd/XMLDTDProcessor.java
Index: XMLDTDProcessor.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dtd/XMLDTDProcessor.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XMLDTDProcessor.java 8 May 2003 20:11:55 -0000 1.7
+++ XMLDTDProcessor.java 21 Aug 2003 20:41:49 -0000 1.8
@@ -946,6 +946,28 @@
}
}
}
+
+ // VC: No Duplicate Tokens
+ // XML 1.0 SE Errata - E2
+ if (type == XMLSymbols.fENUMERATIONSymbol || type == XMLSymbols.fNOTATIONSymbol) {
+ outer:
+ for (int i = 0; i < enumeration.length; ++i) {
+ for (int j = i + 1; j < enumeration.length; ++j) {
+ if (enumeration[i].equals(enumeration[j])) {
+ // Only report the first uniqueness violation. There could be others,
+ // but additional overhead would be incurred tracking unique tokens
+ // that have already been encountered. -- mrglavas
+ fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
+ type == XMLSymbols.fENUMERATIONSymbol
+ ? "MSG_DISTINCT_TOKENS_IN_ENUMERATION"
+ : "MSG_DISTINCT_NOTATION_IN_ENUMERATION",
+ new Object[]{ elementName, enumeration[i], attributeName },
+ XMLErrorReporter.SEVERITY_ERROR);
+ break outer;
+ }
+ }
+ }
+ }
// VC: Attribute Default Legal
boolean ok = true;
1.51 +2 -42 xml-xerces/java/src/org/apache/xerces/impl/dtd/XMLDTDValidator.java
Index: XMLDTDValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dtd/XMLDTDValidator.java,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- XMLDTDValidator.java 19 Aug 2003 19:06:14 -0000 1.50
+++ XMLDTDValidator.java 21 Aug 2003 20:41:49 -0000 1.51
@@ -1180,51 +1180,11 @@
String attType = getAttributeTypeName(fTempAttDecl);
int attDefaultType =fTempAttDecl.simpleType.defaultType;
String attValue = null;
-
- boolean found = false;
- if((fTempAttDecl.simpleType.type == XMLSimpleType.TYPE_ENUMERATION ||
- fTempAttDecl.simpleType.type == XMLSimpleType.TYPE_NOTATION) &&
- fPerformValidation) {
-
- for (int i=0; i<fTempAttDecl.simpleType.enumeration.length ; i++) {
- for (int j=0; j<fTempAttDecl.simpleType.enumeration.length ; j++) {
- if (fTempAttDecl.simpleType.enumeration[i].equals
- (fTempAttDecl.simpleType.enumeration[j]) && i!=j) {
- found = true;
- break;
- }
- }
- if (found)
- break;
- }
-
- StringBuffer enumValueString = new StringBuffer();
- if (fTempAttDecl.simpleType.enumeration != null) {
- enumValueString.append("(");
- for (int i = 0; i < fTempAttDecl.simpleType.enumeration.length; i++) {
- enumValueString.append(fTempAttDecl.simpleType.enumeration[i]+" ");
- }
- enumValueString.append(")");
- }
-
- if (found && fTempAttDecl.simpleType.type == XMLSimpleType.TYPE_ENUMERATION) {
- fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
- "MSG_DISTINCT_TOKENS_IN_ENUMERATION",
- new Object[] {attRawName, enumValueString},
- XMLErrorReporter.SEVERITY_ERROR);
-
- } else if (found && fTempAttDecl.simpleType.type == XMLSimpleType.TYPE_NOTATION) {
- fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
- "MSG_DISTINCT_NOTATION_IN_ENUMERATION",
- new Object[] {attRawName, enumValueString},
- XMLErrorReporter.SEVERITY_ERROR);
-
- }
- }
if (fTempAttDecl.simpleType.defaultValue != null) {
attValue = fTempAttDecl.simpleType.defaultValue;
}
+
boolean specified = false;
boolean required = attDefaultType == XMLSimpleType.DEFAULT_TYPE_REQUIRED;
boolean cdata = attType == XMLSymbols.fCDATASymbol;
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org