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/04/09 22:22:40 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/validators/schema SchemaMessageProvider.java
neilg 01/04/09 13:22:39
Modified: java/src/org/apache/xerces/parsers DOMParser.java
java/src/org/apache/xerces/validators/common
XMLValidator.java
java/src/org/apache/xerces/msg SchemaMessages.java
java/src/org/apache/xerces/validators/schema
SchemaMessageProvider.java
Log:
added support for default and fixed values of elements with simple content.
Revision Changes Path
1.42 +8 -3 xml-xerces/java/src/org/apache/xerces/parsers/DOMParser.java
Index: DOMParser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/DOMParser.java,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- DOMParser.java 2001/03/27 21:45:50 1.41
+++ DOMParser.java 2001/04/09 20:22:30 1.42
@@ -109,7 +109,7 @@
* DOMParser provides a parser which produces a W3C DOM tree as its output
*
*
- * @version $Id: DOMParser.java,v 1.41 2001/03/27 21:45:50 lehors Exp $
+ * @version $Id: DOMParser.java,v 1.42 2001/04/09 20:22:30 neilg Exp $
*/
public class DOMParser
extends XMLParser
@@ -1338,8 +1338,13 @@
} // comment(int)
- /** Not called. */
- public void characters(char ch[], int start, int length) throws Exception {}
+ // Callers who know they're interacting with this parser should use
+ // characters(int); callers who don't know which parser they
+ // are interacting with, or who can't be sure of sharing
+ // the same stringPool, should use this method.
+ public void characters(char ch[], int start, int length) throws Exception {
+ characters(fStringPool.addSymbol(new String(ch, start, length)));
+ } // characters(char[], int, int)
/** Not called. */
public void ignorableWhitespace(char ch[], int start, int length) throws Exception {}
1.133 +31 -4 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.132
retrieving revision 1.133
diff -u -r1.132 -r1.133
--- XMLValidator.java 2001/04/06 20:37:40 1.132
+++ XMLValidator.java 2001/04/09 20:22:33 1.133
@@ -122,7 +122,7 @@
/**
* This class is the super all-in-one validator used by the parser.
*
- * @version $Id: XMLValidator.java,v 1.132 2001/04/06 20:37:40 elena Exp $
+ * @version $Id: XMLValidator.java,v 1.133 2001/04/09 20:22:33 neilg Exp $
*/
public final class XMLValidator
implements DefaultEntityHandler.EventHandler,
@@ -4007,9 +4007,36 @@
+",locapart: "+fStringPool.toString(fTempElementDecl.name.localpart));
} else {
String value =fDatatypeBuffer.toString();
- fCurrentDV.validate(value, null);
- }
-
+ // check for fixed/default values of elements here.
+ if( ((SchemaGrammar)fGrammar).getElementDefaultValue(fCurrentElementIndex) != null &&
+ ((SchemaGrammar)fGrammar).getElementDefaultValue(fCurrentElementIndex).equals("")) {
+ fCurrentDV.validate(value, null);
+ } else {
+ String currentElementDefault = ((SchemaGrammar)fGrammar).getElementDefaultValue(fCurrentElementIndex);
+ if((((SchemaGrammar)fGrammar).getElementDeclMiscFlags(fCurrentElementIndex) & SchemaSymbols.FIXED) != 0) {
+ if(value.equals("")) { // use fixed as default value
+ // Note: this is inefficient where the DOMParser
+ // is concerned. However, if we used the characters(int)
+ // callback instead, this would be just as inefficient for SAX.
+ fDocumentHandler.characters(currentElementDefault.toCharArray(), 0, currentElementDefault.length());
+ } else { // must check in valuespace!
+ if (fCurrentDV.compare(value, currentElementDefault) != 0) {
+ fErrorReporter.reportError(fErrorReporter.getLocator(),
+ SchemaMessageProvider.SCHEMA_DOMAIN,
+ SchemaMessageProvider.FixedDiffersFromActual,
+ 0, null,
+ XMLErrorReporter.ERRORTYPE_RECOVERABLE_ERROR);
+ }
+ }
+ } else {
+ if(value.equals("")) { // use default value
+ fDocumentHandler.characters(currentElementDefault.toCharArray(), 0, currentElementDefault.length());
+ } else { // must validate value
+ fCurrentDV.validate(value, null);
+ }
+ }
+ }
+ }
} catch (InvalidDatatypeValueException idve) {
fErrorReporter.reportError(fErrorReporter.getLocator(),
SchemaMessageProvider.SCHEMA_DOMAIN,
1.10 +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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- SchemaMessages.java 2001/02/20 06:12:27 1.9
+++ SchemaMessages.java 2001/04/09 20:22:36 1.10
@@ -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.9 2001/02/20 06:12:27 andyc Exp $
+ * @version $Id: SchemaMessages.java,v 1.10 2001/04/09 20:22:36 neilg Exp $
*/
public class SchemaMessages extends ListResourceBundle {
/** The list resource bundle contents. */
@@ -107,6 +107,7 @@
{ "KeyNotFound", "Key with value [{0}] not found for identity constraint of element \"{1}\"." },
{ "UnknownField", "Internal identity constraint error; unknown field \"{0}\"." },
{ "KeyRefReferNotFound", "Key reference declaration \"{0}\" refers to unknown key with name \"{1}\"." },
+ { "FixedDiffersFromActual", "The content of this element is not equivalent to the value of the \"fixed\" attribute in the element's declaration in the schema."},
};
/** Returns the list resource bundle contents. */
1.10 +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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- SchemaMessageProvider.java 2001/02/20 06:12:28 1.9
+++ SchemaMessageProvider.java 2001/04/09 20:22:38 1.10
@@ -173,7 +173,8 @@
UnknownField = 36,
KeyRefReferNotFound = 37,
// ...
- MSG_MAX_CODE = 38;
+ FixedDiffersFromActual = 38,
+ MSG_MAX_CODE = 39;
//
// Minor Codes
//
@@ -220,6 +221,7 @@
"KeyNotFound",
"UnknownField",
"KeyRefReferNotFound",
+ "FixedDiffersFromActual",
// END
};
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org