You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by el...@apache.org on 2001/10/11 17:13:34 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes AbstractDatatypeValidator.java AbstractNumericFacetValidator.java AbstractNumericValidator.java AbstractStringValidator.java AnySimpleType.java AnyURIDatatypeValidator.java Base64BinaryDatatypeValidator.java BooleanDatatypeValidator.java DatatypeValidatorFactoryImpl.java DateDatatypeValidator.java DateTimeDatatypeValidator.java DateTimeValidator.java DayDatatypeValidator.java DecimalDatatypeValidator.java DoubleDatatypeValidator.java DurationDatatypeValidator.java FloatDatatypeValidator.java HexBinaryDatatypeValidator.java IDDatatypeValidator.java IDREFDatatypeValidator.java ListDatatypeValidator.java MonthDatatypeValidator.java MonthDayDatatypeValidator.java NOTATIONDatatypeValidator.java QNameDatatypeValidator.java StringDatatypeValidator.java TimeDatatypeValidator.java UnionDatatypeValidator.java YearDatatypeValidator.java YearMonthDatatypeValidator.java
elena 01/10/11 08:13:34
Modified: java/src/org/apache/xerces/impl/v2 SchemaGrammar.java
XSAttributeChecker.java XSDAbstractTraverser.java
XSDComplexTypeTraverser.java
XSDSimpleTypeTraverser.java
java/src/org/apache/xerces/impl/v2/datatypes
AbstractDatatypeValidator.java
AbstractNumericFacetValidator.java
AbstractNumericValidator.java
AbstractStringValidator.java AnySimpleType.java
AnyURIDatatypeValidator.java
Base64BinaryDatatypeValidator.java
BooleanDatatypeValidator.java
DatatypeValidatorFactoryImpl.java
DateDatatypeValidator.java
DateTimeDatatypeValidator.java
DateTimeValidator.java DayDatatypeValidator.java
DecimalDatatypeValidator.java
DoubleDatatypeValidator.java
DurationDatatypeValidator.java
FloatDatatypeValidator.java
HexBinaryDatatypeValidator.java
IDDatatypeValidator.java
IDREFDatatypeValidator.java
ListDatatypeValidator.java
MonthDatatypeValidator.java
MonthDayDatatypeValidator.java
NOTATIONDatatypeValidator.java
QNameDatatypeValidator.java
StringDatatypeValidator.java
TimeDatatypeValidator.java
UnionDatatypeValidator.java
YearDatatypeValidator.java
YearMonthDatatypeValidator.java
Log:
Changed a bit the datatype construction: never throw an exception during a datatype creation (which would have
resulted in wrong type of errors "circular definition"). Instead, use error reporter to report errors.
The code just uses try and catch blocks in constructors, however if design is to remain the same, we need
to revisit the code (remove all code for throwing exceptions from the constructor and validate methods as well).
Also fixed some bugs in Simple types.
Revision Changes Path
1.25 +147 -145 xml-xerces/java/src/org/apache/xerces/impl/v2/SchemaGrammar.java
Index: SchemaGrammar.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/SchemaGrammar.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- SchemaGrammar.java 2001/09/28 18:11:43 1.24
+++ SchemaGrammar.java 2001/10/11 15:13:33 1.25
@@ -71,7 +71,7 @@
* @author Sandy Gao, IBM
* @author Elena Litani, IBM
*
- * @version $Id: SchemaGrammar.java,v 1.24 2001/09/28 18:11:43 neilg Exp $
+ * @version $Id: SchemaGrammar.java,v 1.25 2001/10/11 15:13:33 elena Exp $
*/
public class SchemaGrammar {
@@ -136,147 +136,147 @@
* @param symbolTable
* @param fullSet
*/
- private SchemaGrammar(SymbolTable symbolTable, boolean fullSet) {
+ protected SchemaGrammar(SymbolTable symbolTable, boolean fullSet) {
fSymbolTable = symbolTable;
fTargetNamespace = SchemaSymbols.URI_SCHEMAFORSCHEMA;
+ // REVISIT: for default datatype creation an error reporter is null.
+ // In case we ever see an error, Runtime exception will be thrown
+ // since this is an implementation failure.
+
// set the size of type SymbolHash to double the number of types need
// to be created. which should be the most effecient number.
fGlobalTypeDecls = new SymbolHash((fullSet?FULLSET_COUNT:BASICSET_COUNT)*2);
- try {
- // REVISIT: use XSSimpleTypeDecl instead
- XSComplexTypeDecl anyType = new XSComplexTypeDecl();
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYTYPE, anyType);
- //REVISIT: make anyType the base of anySimpleType
- //DatatypeValidator anySimpleType = new AnySimpleType(anyType, null, false);
- DatatypeValidator anySimpleType = new AnySimpleType(null, null, false);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYSIMPLETYPE, anySimpleType);
- DatatypeValidator stringDV = new StringDatatypeValidator(anySimpleType, null, false);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_STRING, stringDV);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_BOOLEAN, new BooleanDatatypeValidator(anySimpleType, null, false));
- DatatypeValidator decimalDV = new DecimalDatatypeValidator(anySimpleType, null, false);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_DECIMAL, decimalDV);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYURI, new AnyURIDatatypeValidator(anySimpleType, null, false));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_BASE64BINARY, new Base64BinaryDatatypeValidator(anySimpleType, null, false));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_DURATION, new DurationDatatypeValidator(anySimpleType, null, false));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_DATETIME, new DateTimeDatatypeValidator(anySimpleType, null, false));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_TIME, new TimeDatatypeValidator(anySimpleType, null, false));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_DATE, new DateDatatypeValidator(anySimpleType, null, false));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_YEARMONTH, new YearMonthDatatypeValidator(anySimpleType, null, false));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_YEAR, new YearDatatypeValidator(anySimpleType, null, false));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_MONTHDAY, new MonthDayDatatypeValidator(anySimpleType, null, false));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_DAY, new DayDatatypeValidator(anySimpleType, null, false));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_MONTH, new MonthDatatypeValidator(anySimpleType, null, false));
-
- Hashtable facets = new Hashtable(2);
- facets.put(SchemaSymbols.ELT_FRACTIONDIGITS, "0");
- DatatypeValidator integerDV = new DecimalDatatypeValidator(decimalDV, facets, false);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_INTEGER, integerDV);
- facets.clear();
- facets.put(SchemaSymbols.ELT_MAXINCLUSIVE , "0" );
- DatatypeValidator nonPositiveDV = new DecimalDatatypeValidator(integerDV, facets, false);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_NONPOSITIVEINTEGER, nonPositiveDV);
- facets.clear();
- facets.put(SchemaSymbols.ELT_MAXINCLUSIVE , "-1" );
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_NEGATIVEINTEGER, new DecimalDatatypeValidator(nonPositiveDV, facets, false));
- facets.clear();
- facets.put(SchemaSymbols.ELT_MAXINCLUSIVE , "9223372036854775807");
- facets.put(SchemaSymbols.ELT_MININCLUSIVE, "-9223372036854775808");
- DatatypeValidator longDV = new DecimalDatatypeValidator(integerDV, facets, false);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_LONG, longDV);
- facets.clear();
- facets.put(SchemaSymbols.ELT_MAXINCLUSIVE , "2147483647");
- facets.put(SchemaSymbols.ELT_MININCLUSIVE, "-2147483648");
- DatatypeValidator intDV = new DecimalDatatypeValidator(longDV, facets, false);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_INT, intDV);
- facets.clear();
- facets.put(SchemaSymbols.ELT_MAXINCLUSIVE , "32767");
- facets.put(SchemaSymbols.ELT_MININCLUSIVE, "-32768");
- DatatypeValidator shortDV = new DecimalDatatypeValidator(intDV, facets, false);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_SHORT, shortDV);
- facets.clear();
- facets.put(SchemaSymbols.ELT_MAXINCLUSIVE , "127");
- facets.put(SchemaSymbols.ELT_MININCLUSIVE, "-128");
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_BYTE, new DecimalDatatypeValidator(shortDV, facets, false));
- facets.clear();
- facets.put(SchemaSymbols.ELT_MININCLUSIVE, "0" );
- DatatypeValidator nonNegativeDV = new DecimalDatatypeValidator(integerDV, facets, false);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_NONNEGATIVEINTEGER, nonNegativeDV);
- facets.clear();
- facets.put(SchemaSymbols.ELT_MAXINCLUSIVE, "18446744073709551615" );
- DatatypeValidator unsignedLongDV = new DecimalDatatypeValidator(nonNegativeDV, facets, false);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_UNSIGNEDLONG, unsignedLongDV);
- facets.clear();
- facets.put(SchemaSymbols.ELT_MAXINCLUSIVE, "4294967295" );
- DatatypeValidator unsignedIntDV = new DecimalDatatypeValidator(unsignedLongDV, facets, false);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_UNSIGNEDINT, unsignedIntDV);
- facets.clear();
- facets.put(SchemaSymbols.ELT_MAXINCLUSIVE, "65535" );
- DatatypeValidator unsignedShortDV = new DecimalDatatypeValidator(unsignedIntDV, facets, false);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_UNSIGNEDSHORT, unsignedShortDV);
- facets.clear();
- facets.put(SchemaSymbols.ELT_MAXINCLUSIVE, "255" );
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_UNSIGNEDBYTE, new DecimalDatatypeValidator(unsignedShortDV, facets, false));
- facets.clear();
- facets.put(SchemaSymbols.ELT_MININCLUSIVE, "1" );
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_POSITIVEINTEGER, new DecimalDatatypeValidator(nonNegativeDV, facets, false));
-
- if (!fullSet)
- return;
-
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_FLOAT, new FloatDatatypeValidator(anySimpleType, null, false));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_DOUBLE, new DoubleDatatypeValidator(anySimpleType, null, false));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_HEXBINARY, new HexBinaryDatatypeValidator(anySimpleType, null, false));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_NOTATION, new NOTATIONDatatypeValidator(anySimpleType, null, false));
-
- facets.clear();
- facets.put(SchemaSymbols.ELT_WHITESPACE, SchemaSymbols.ATTVAL_REPLACE);
- DatatypeValidator normalizedDV = new StringDatatypeValidator(stringDV, facets, false);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_NORMALIZEDSTRING, normalizedDV);
- facets.clear();
- facets.put(SchemaSymbols.ELT_WHITESPACE, SchemaSymbols.ATTVAL_COLLAPSE);
- DatatypeValidator tokenDV = new StringDatatypeValidator(normalizedDV, facets, false);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_TOKEN, tokenDV);
- facets.clear();
- facets.put(SchemaSymbols.ELT_WHITESPACE, SchemaSymbols.ATTVAL_COLLAPSE);
- //REVISIT: won't run: regexparser, locale, resource bundle
- //facets.put(SchemaSymbols.ELT_PATTERN , "([a-zA-Z]{2}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]+)(-[a-zA-Z]+)*");
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_LANGUAGE, new StringDatatypeValidator(tokenDV, facets, false));
- facets.clear();
- facets.put(SchemaSymbols.ELT_WHITESPACE, SchemaSymbols.ATTVAL_COLLAPSE);
- facets.put(AbstractStringValidator.FACET_SPECIAL_TOKEN, AbstractStringValidator.SPECIAL_TOKEN_NAME);
- DatatypeValidator nameDV = new StringDatatypeValidator(tokenDV, facets, false);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_NAME, nameDV);
- facets.clear();
- facets.put(SchemaSymbols.ELT_WHITESPACE, SchemaSymbols.ATTVAL_COLLAPSE);
- facets.put(AbstractStringValidator.FACET_SPECIAL_TOKEN, AbstractStringValidator.SPECIAL_TOKEN_NCNAME);
- DatatypeValidator ncnameDV = new StringDatatypeValidator(nameDV, facets, false);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_NCNAME, ncnameDV);
- DatatypeValidator qnameDV = new QNameDatatypeValidator(anySimpleType, null, false);
- ((QNameDatatypeValidator)qnameDV).setNCNameValidator(ncnameDV);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_QNAME, qnameDV);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_ID, new IDDatatypeValidator(ncnameDV, null, false));
- DatatypeValidator idrefDV = new IDREFDatatypeValidator(ncnameDV, null, false);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_IDREF, idrefDV);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_IDREFS, new ListDatatypeValidator(idrefDV, null, true));
- //REVISIT: entity validators
- //DatatypeValidator entityDV = new ENTITYDatatypeValidator(ncnameDV, null, false);
- DatatypeValidator entityDV = new StringDatatypeValidator(ncnameDV, null, false);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_ENTITY, entityDV);
- //REVISIT: entity validators
- //fTypeDeclType[0][typeIndex] = new ListDatatypeValidator(entityDV, null, true);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_ENTITIES, new ListDatatypeValidator(entityDV, null, true));
- facets.clear();
- facets.put(SchemaSymbols.ELT_WHITESPACE, SchemaSymbols.ATTVAL_COLLAPSE);
- facets.put(AbstractStringValidator.FACET_SPECIAL_TOKEN, AbstractStringValidator.SPECIAL_TOKEN_NMTOKEN);
- DatatypeValidator nmtokenDV = new StringDatatypeValidator(tokenDV, facets, false);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_NMTOKEN, nmtokenDV);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_NMTOKENS, new ListDatatypeValidator(nmtokenDV, null, true));
- } catch (InvalidDatatypeFacetException idf) {
- // should never reach here
- // REVISIT: report internal error
- }
+ // REVISIT: use XSSimpleTypeDecl instead
+ XSComplexTypeDecl anyType = new XSComplexTypeDecl();
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYTYPE, anyType);
+ //REVISIT: make anyType the base of anySimpleType
+ //DatatypeValidator anySimpleType = new AnySimpleType(anyType, null, false);
+ DatatypeValidator anySimpleType = new AnySimpleType(null, null, false, null);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYSIMPLETYPE, anySimpleType);
+ DatatypeValidator stringDV = new StringDatatypeValidator(anySimpleType, null, false, null);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_STRING, stringDV);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_BOOLEAN, new BooleanDatatypeValidator(anySimpleType, null, false, null));
+ DatatypeValidator decimalDV = new DecimalDatatypeValidator(anySimpleType, null, false, null);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_DECIMAL, decimalDV);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYURI, new AnyURIDatatypeValidator(anySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_BASE64BINARY, new Base64BinaryDatatypeValidator(anySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_DURATION, new DurationDatatypeValidator(anySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_DATETIME, new DateTimeDatatypeValidator(anySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_TIME, new TimeDatatypeValidator(anySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_DATE, new DateDatatypeValidator(anySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_YEARMONTH, new YearMonthDatatypeValidator(anySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_YEAR, new YearDatatypeValidator(anySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_MONTHDAY, new MonthDayDatatypeValidator(anySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_DAY, new DayDatatypeValidator(anySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_MONTH, new MonthDatatypeValidator(anySimpleType, null, false, null));
+
+ Hashtable facets = new Hashtable(2);
+ facets.put(SchemaSymbols.ELT_FRACTIONDIGITS, "0");
+ DatatypeValidator integerDV = new DecimalDatatypeValidator(decimalDV, facets, false, null);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_INTEGER, integerDV);
+ facets.clear();
+ facets.put(SchemaSymbols.ELT_MAXINCLUSIVE , "0" );
+ DatatypeValidator nonPositiveDV = new DecimalDatatypeValidator(integerDV, facets, false, null);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_NONPOSITIVEINTEGER, nonPositiveDV);
+ facets.clear();
+ facets.put(SchemaSymbols.ELT_MAXINCLUSIVE , "-1" );
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_NEGATIVEINTEGER, new DecimalDatatypeValidator(nonPositiveDV, facets, false, null));
+ facets.clear();
+ facets.put(SchemaSymbols.ELT_MAXINCLUSIVE , "9223372036854775807");
+ facets.put(SchemaSymbols.ELT_MININCLUSIVE, "-9223372036854775808");
+ DatatypeValidator longDV = new DecimalDatatypeValidator(integerDV, facets, false, null);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_LONG, longDV);
+ facets.clear();
+ facets.put(SchemaSymbols.ELT_MAXINCLUSIVE , "2147483647");
+ facets.put(SchemaSymbols.ELT_MININCLUSIVE, "-2147483648");
+ DatatypeValidator intDV = new DecimalDatatypeValidator(longDV, facets, false, null);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_INT, intDV);
+ facets.clear();
+ facets.put(SchemaSymbols.ELT_MAXINCLUSIVE , "32767");
+ facets.put(SchemaSymbols.ELT_MININCLUSIVE, "-32768");
+ DatatypeValidator shortDV = new DecimalDatatypeValidator(intDV, facets, false, null);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_SHORT, shortDV);
+ facets.clear();
+ facets.put(SchemaSymbols.ELT_MAXINCLUSIVE , "127");
+ facets.put(SchemaSymbols.ELT_MININCLUSIVE, "-128");
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_BYTE, new DecimalDatatypeValidator(shortDV, facets, false, null));
+ facets.clear();
+ facets.put(SchemaSymbols.ELT_MININCLUSIVE, "0" );
+ DatatypeValidator nonNegativeDV = new DecimalDatatypeValidator(integerDV, facets, false, null);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_NONNEGATIVEINTEGER, nonNegativeDV);
+ facets.clear();
+ facets.put(SchemaSymbols.ELT_MAXINCLUSIVE, "18446744073709551615" );
+ DatatypeValidator unsignedLongDV = new DecimalDatatypeValidator(nonNegativeDV, facets, false, null);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_UNSIGNEDLONG, unsignedLongDV);
+ facets.clear();
+ facets.put(SchemaSymbols.ELT_MAXINCLUSIVE, "4294967295" );
+ DatatypeValidator unsignedIntDV = new DecimalDatatypeValidator(unsignedLongDV, facets, false, null);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_UNSIGNEDINT, unsignedIntDV);
+ facets.clear();
+ facets.put(SchemaSymbols.ELT_MAXINCLUSIVE, "65535" );
+ DatatypeValidator unsignedShortDV = new DecimalDatatypeValidator(unsignedIntDV, facets, false, null);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_UNSIGNEDSHORT, unsignedShortDV);
+ facets.clear();
+ facets.put(SchemaSymbols.ELT_MAXINCLUSIVE, "255" );
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_UNSIGNEDBYTE, new DecimalDatatypeValidator(unsignedShortDV, facets, false, null));
+ facets.clear();
+ facets.put(SchemaSymbols.ELT_MININCLUSIVE, "1" );
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_POSITIVEINTEGER, new DecimalDatatypeValidator(nonNegativeDV, facets, false, null));
+
+ if (!fullSet)
+ return;
+
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_FLOAT, new FloatDatatypeValidator(anySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_DOUBLE, new DoubleDatatypeValidator(anySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_HEXBINARY, new HexBinaryDatatypeValidator(anySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_NOTATION, new NOTATIONDatatypeValidator(anySimpleType, null, false, null));
+
+ facets.clear();
+ facets.put(SchemaSymbols.ELT_WHITESPACE, SchemaSymbols.ATTVAL_REPLACE);
+ DatatypeValidator normalizedDV = new StringDatatypeValidator(stringDV, facets, false, null);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_NORMALIZEDSTRING, normalizedDV);
+ facets.clear();
+ facets.put(SchemaSymbols.ELT_WHITESPACE, SchemaSymbols.ATTVAL_COLLAPSE);
+ DatatypeValidator tokenDV = new StringDatatypeValidator(normalizedDV, facets, false, null);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_TOKEN, tokenDV);
+ facets.clear();
+ facets.put(SchemaSymbols.ELT_WHITESPACE, SchemaSymbols.ATTVAL_COLLAPSE);
+ //REVISIT: won't run: regexparser, locale, resource bundle
+ //facets.put(SchemaSymbols.ELT_PATTERN , "([a-zA-Z]{2}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]+)(-[a-zA-Z]+)*");
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_LANGUAGE, new StringDatatypeValidator(tokenDV, facets, false, null));
+ facets.clear();
+ facets.put(SchemaSymbols.ELT_WHITESPACE, SchemaSymbols.ATTVAL_COLLAPSE);
+ facets.put(AbstractStringValidator.FACET_SPECIAL_TOKEN, AbstractStringValidator.SPECIAL_TOKEN_NAME);
+ DatatypeValidator nameDV = new StringDatatypeValidator(tokenDV, facets, false, null);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_NAME, nameDV);
+ facets.clear();
+ facets.put(SchemaSymbols.ELT_WHITESPACE, SchemaSymbols.ATTVAL_COLLAPSE);
+ facets.put(AbstractStringValidator.FACET_SPECIAL_TOKEN, AbstractStringValidator.SPECIAL_TOKEN_NCNAME);
+ DatatypeValidator ncnameDV = new StringDatatypeValidator(nameDV, facets, false, null);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_NCNAME, ncnameDV);
+ DatatypeValidator qnameDV = new QNameDatatypeValidator(anySimpleType, null, false, null);
+ ((QNameDatatypeValidator)qnameDV).setNCNameValidator(ncnameDV);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_QNAME, qnameDV);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_ID, new IDDatatypeValidator(ncnameDV, null, false, null));
+ DatatypeValidator idrefDV = new IDREFDatatypeValidator(ncnameDV, null, false, null);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_IDREF, idrefDV);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_IDREFS, new ListDatatypeValidator(idrefDV, null, true, null));
+ //REVISIT: entity validators
+ //DatatypeValidator entityDV = new ENTITYDatatypeValidator(ncnameDV, null, false, null);
+ DatatypeValidator entityDV = new StringDatatypeValidator(ncnameDV, null, false, null);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_ENTITY, entityDV);
+ //REVISIT: entity validators
+ //fTypeDeclType[0][typeIndex] = new ListDatatypeValidator(entityDV, null, true);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_ENTITIES, new ListDatatypeValidator(entityDV, null, true, null));
+ facets.clear();
+ facets.put(SchemaSymbols.ELT_WHITESPACE, SchemaSymbols.ATTVAL_COLLAPSE);
+ facets.put(AbstractStringValidator.FACET_SPECIAL_TOKEN, AbstractStringValidator.SPECIAL_TOKEN_NMTOKEN);
+ DatatypeValidator nmtokenDV = new StringDatatypeValidator(tokenDV, facets, false, null);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_NMTOKEN, nmtokenDV);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_NMTOKENS, new ListDatatypeValidator(nmtokenDV, null, true, null));
+
} // <init>(SymbolTable, boolean)
/**
@@ -325,13 +325,14 @@
* register one global type
*/
public final void addGlobalTypeDecl(XSTypeDecl decl) {
- if(decl == null) {
+ if (decl == null) {
System.err.println("decl");
System.exit(0);
- } else if (decl.getXSTypeName() == null) {
+ }
+ else if (decl.getXSTypeName() == null) {
System.err.println("decl.whatever");
System.exit(0);
- }
+ }
fGlobalTypeDecls.put(decl.getXSTypeName(), decl);
}
@@ -348,49 +349,49 @@
* get one global attribute
*/
public final XSAttributeDecl getGlobalAttributeDecl(String declName) {
- return (XSAttributeDecl)fGlobalAttrDecls.get(declName);
+ return(XSAttributeDecl)fGlobalAttrDecls.get(declName);
}
/**
* get one global attribute group
*/
public final XSAttributeGroupDecl getGlobalAttributeGroupDecl(String declName) {
- return (XSAttributeGroupDecl)fGlobalAttrGrpDecls.get(declName);
+ return(XSAttributeGroupDecl)fGlobalAttrGrpDecls.get(declName);
}
/**
* get one global element
*/
public final XSElementDecl getGlobalElementDecl(String declName) {
- return (XSElementDecl)fGlobalElemDecls.get(declName);
+ return(XSElementDecl)fGlobalElemDecls.get(declName);
}
/**
* get one global group
*/
public final XSGroupDecl getGlobalGroupDecl(String declName) {
- return (XSGroupDecl)fGlobalGroupDecls.get(declName);
+ return(XSGroupDecl)fGlobalGroupDecls.get(declName);
}
/**
* get one global notation
*/
public final XSNotationDecl getNotationDecl(String declName) {
- return (XSNotationDecl)fGlobalNotationDecls.get(declName);
+ return(XSNotationDecl)fGlobalNotationDecls.get(declName);
}
/**
* get one global type
*/
public final XSTypeDecl getGlobalTypeDecl(String declName) {
- return (XSTypeDecl)fGlobalTypeDecls.get(declName);
+ return(XSTypeDecl)fGlobalTypeDecls.get(declName);
}
/**
* get one identity constraint
*/
public final IdentityConstraint getIDConstraintDecl(String declName) {
- return (IdentityConstraint)fGlobalIDConstraintDecls.get(declName);
+ return(IdentityConstraint)fGlobalIDConstraintDecls.get(declName);
}
// array to store complex type decls
@@ -419,6 +420,7 @@
// the grammars to hold built-in types
final static SchemaGrammar SG_SchemaNS = new SchemaGrammar(null, true);
final static SchemaGrammar SG_SchemaBasicSet = new SchemaGrammar(null, false);
+
static final XSComplexTypeDecl[] resize(XSComplexTypeDecl[] oldArray, int newSize) {
XSComplexTypeDecl[] newArray = new XSComplexTypeDecl[newSize];
1.26 +4 -1 xml-xerces/java/src/org/apache/xerces/impl/v2/XSAttributeChecker.java
Index: XSAttributeChecker.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSAttributeChecker.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- XSAttributeChecker.java 2001/10/09 20:09:46 1.25
+++ XSAttributeChecker.java 2001/10/11 15:13:33 1.26
@@ -89,7 +89,7 @@
* - use symbol table instead of many hashtables
*
* @author Sandy Gao, IBM
- * @version $Id: XSAttributeChecker.java,v 1.25 2001/10/09 20:09:46 elena Exp $
+ * @version $Id: XSAttributeChecker.java,v 1.26 2001/10/11 15:13:33 elena Exp $
*/
public class XSAttributeChecker {
@@ -1123,6 +1123,9 @@
OneAttr[] reqAttrs = oneEle.attrArray;
for (int i = 0; i < reqAttrs.length; i++) {
OneAttr oneAttr = reqAttrs[i];
+
+ // REVISIT: throw an error on required attribute that does not
+ // appear test case schema_invalid/S3_14/ibm3_14si12.xml
// if the attribute didn't apprear, and
// if the attribute is optional with default value, apply it
1.24 +77 -59 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDAbstractTraverser.java
Index: XSDAbstractTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDAbstractTraverser.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- XSDAbstractTraverser.java 2001/10/07 17:18:06 1.23
+++ XSDAbstractTraverser.java 2001/10/11 15:13:33 1.24
@@ -77,7 +77,7 @@
* @author Elena Litani, IBM
* @author Rahul Srivastava, Sun Microsystems Inc.
*
- * @version $Id: XSDAbstractTraverser.java,v 1.23 2001/10/07 17:18:06 lmartin Exp $
+ * @version $Id: XSDAbstractTraverser.java,v 1.24 2001/10/11 15:13:33 elena Exp $
*/
abstract class XSDAbstractTraverser {
@@ -138,15 +138,15 @@
Object[] attrValues = fAttrChecker.checkAttributes(annotationDecl, isGlobal, schemaDoc);
fAttrChecker.returnAttrArray(attrValues, schemaDoc);
- for(Element child = DOMUtil.getFirstChildElement(annotationDecl);
+ for (Element child = DOMUtil.getFirstChildElement(annotationDecl);
child != null;
child = DOMUtil.getNextSiblingElement(child)) {
String name = child.getLocalName();
// the only valid children of "annotation" are
// "appinfo" and "documentation"
- if(!((name.equals(SchemaSymbols.ELT_APPINFO)) ||
- (name.equals(SchemaSymbols.ELT_DOCUMENTATION)))) {
+ if (!((name.equals(SchemaSymbols.ELT_APPINFO)) ||
+ (name.equals(SchemaSymbols.ELT_DOCUMENTATION)))) {
reportGenericSchemaError("an <annotation> can only contain <appinfo> and <documentation> elements");
}
@@ -161,25 +161,43 @@
}
DatatypeValidator createRestrictedValidator(DatatypeValidator baseValidator,
- Hashtable fFacetData) {
+ Hashtable facetData, XMLErrorReporter reporter) {
DatatypeValidator newDV=null;
Class validatorDef = baseValidator.getClass();
Class [] validatorArgsClass = new Class[] {
org.apache.xerces.impl.v2.datatypes.DatatypeValidator.class,
java.util.Hashtable.class,
- boolean.class};
+ boolean.class,
+ org.apache.xerces.impl.XMLErrorReporter.class};
+ if (facetData != null) {
+
+ String value = (String)facetData.get(SchemaSymbols.ELT_WHITESPACE);
+ //for all datatypes other than string, we don't pass WHITESPACE Facet
+ //its value is always 'collapse' and cannot be reset by user
+ if (value != null && !(baseValidator instanceof StringDatatypeValidator)) {
+ if (!value.equals(SchemaSymbols.ATTVAL_COLLAPSE))
+ reporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
+ "WhitespaceFacetError",
+ new Object [] { value},
+ XMLErrorReporter.SEVERITY_ERROR);
+ facetData.remove(SchemaSymbols.ELT_WHITESPACE);
+ }
+ }
+ Object [] validatorArgs = new Object[] {baseValidator, facetData, Boolean.FALSE, fErrorReporter};
- Object [] validatorArgs = new Object[] {baseValidator, fFacetData, Boolean.FALSE};
try {
Constructor validatorConstructor = validatorDef.getConstructor( validatorArgsClass );
+
newDV = (DatatypeValidator) validatorConstructor.newInstance(validatorArgs);
- } catch (NoSuchMethodException e) {
- } catch ( InstantiationException e ) {
- } catch ( IllegalAccessException e ) {
- } catch ( IllegalArgumentException e ) {
- } catch ( InvocationTargetException e ) {
+
+ }catch (NoSuchMethodException e) {
+ }catch (InstantiationException e) {
+ }catch (IllegalAccessException e) {
+ }catch (IllegalArgumentException e) {
reportGenericSchemaError(e.getMessage());
+ }catch (InvocationTargetException e) {
+ e.printStackTrace();
}
return newDV;
@@ -192,13 +210,13 @@
private final QName fQName = new QName();
class fFacetInfo {
- Hashtable facetdata;
- Element nodeAfterFacets;
+ Hashtable facetdata;
+ Element nodeAfterFacets;
}
fFacetInfo traverseFacets(Element content, Object[] contentAttrs, String simpleTypeName,
- DatatypeValidator baseValidator, XSDocumentInfo schemaDoc,
- SchemaGrammar grammar) {
+ DatatypeValidator baseValidator, XSDocumentInfo schemaDoc,
+ SchemaGrammar grammar) {
fFacetInfo fi = new fFacetInfo();
Hashtable fFacetData = new Hashtable(10);
@@ -231,11 +249,11 @@
String uriStr = schemaDoc.fNamespaceSupport.getURI(prefix);
fQName.setValues(prefix, localpart, null, uriStr );
XSNotationDecl notation = (XSNotationDecl)fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.NOTATION_TYPE , fQName);
-
+
if (notation == null) {
- reportGenericSchemaError("Notation '" + localpart +
- "' not found in the grammar "+ uriStr);
-
+ reportGenericSchemaError("Notation '" + localpart +
+ "' not found in the grammar "+ uriStr);
+
}
enumVal=simpleTypeName;
}
@@ -249,7 +267,7 @@
"ListUnionRestrictionError",
args,
XMLErrorReporter.SEVERITY_ERROR);
-
+
}
else if (facet.equals(SchemaSymbols.ELT_PATTERN)) {
if (fPattern == null) {
@@ -299,11 +317,11 @@
facetType = DatatypeValidator.FACET_FRACTIONDIGITS;
}
else if (facet.equals(SchemaSymbols.ELT_WHITESPACE)) {
-
- if (baseValidator instanceof StringDatatypeValidator)
- facetType= DatatypeValidator.FACET_WHITESPACE;
+
+ if (baseValidator instanceof StringDatatypeValidator)
+ facetType= DatatypeValidator.FACET_WHITESPACE;
}
- else if (facet.equals(SchemaSymbols.ELT_LENGTH)) {
+ else if (facet.equals(SchemaSymbols.ELT_LENGTH)) {
}
else {
break; // a non-facet
@@ -333,7 +351,7 @@
fi.facetdata = fFacetData;
fi.nodeAfterFacets = content;
return fi;
-
+
}
//
@@ -352,43 +370,43 @@
childName = child.getLocalName();
if (childName.equals(SchemaSymbols.ELT_ATTRIBUTE)) {
tempAttrUse = fSchemaHandler.fAttributeTraverser.traverseLocal(child,
- schemaDoc, grammar);
- if (attrGrp.getAttributeUse(tempAttrUse.fAttrDecl.fTargetNamespace,
+ schemaDoc, grammar);
+ if (attrGrp.getAttributeUse(tempAttrUse.fAttrDecl.fTargetNamespace,
tempAttrUse.fAttrDecl.fName)==null) {
- attrGrp.addAttributeUse(tempAttrUse);
+ attrGrp.addAttributeUse(tempAttrUse);
}
else {
- reportGenericSchemaError("Duplicate attribute " +
- tempAttrUse.fAttrDecl.fName + " found ");
+ reportGenericSchemaError("Duplicate attribute " +
+ tempAttrUse.fAttrDecl.fName + " found ");
}
}
else if (childName.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP)) {
//REVISIT: do we need to save some state at this point??
tempAttrGrp = fSchemaHandler.fAttributeGroupTraverser.traverseLocal(
- child, schemaDoc, grammar);
+ child, schemaDoc, grammar);
XSAttributeUse[] attrUseS = tempAttrGrp.getAttributeUses();
XSAttributeUse existingAttrUse = null;
for (int i=0; i<attrUseS.length; i++) {
- existingAttrUse = attrGrp.getAttributeUse(attrUseS[i].fAttrDecl.fTargetNamespace,
- attrUseS[i].fAttrDecl.fName);
- if (existingAttrUse == null) {
- attrGrp.addAttributeUse(attrUseS[i]);
- }
- else {
- reportGenericSchemaError("Duplicate attribute " +
- existingAttrUse.fAttrDecl.fName + " found ");
- }
+ existingAttrUse = attrGrp.getAttributeUse(attrUseS[i].fAttrDecl.fTargetNamespace,
+ attrUseS[i].fAttrDecl.fName);
+ if (existingAttrUse == null) {
+ attrGrp.addAttributeUse(attrUseS[i]);
+ }
+ else {
+ reportGenericSchemaError("Duplicate attribute " +
+ existingAttrUse.fAttrDecl.fName + " found ");
+ }
}
-
+
if (tempAttrGrp.fAttributeWC != null) {
- if (attrGrp.fAttributeWC == null) {
- attrGrp.fAttributeWC = tempAttrGrp.fAttributeWC;
- }
- // perform intersection of attribute wildcard
- else {
- attrGrp.fAttributeWC = attrGrp.fAttributeWC.
- performIntersectionWith(tempAttrGrp.fAttributeWC);
- }
+ if (attrGrp.fAttributeWC == null) {
+ attrGrp.fAttributeWC = tempAttrGrp.fAttributeWC;
+ }
+ // perform intersection of attribute wildcard
+ else {
+ attrGrp.fAttributeWC = attrGrp.fAttributeWC.
+ performIntersectionWith(tempAttrGrp.fAttributeWC);
+ }
}
}
else
@@ -399,14 +417,14 @@
childName = child.getLocalName();
if (childName.equals(SchemaSymbols.ELT_ANYATTRIBUTE)) {
XSWildcardDecl tempAttrWC = fSchemaHandler.fWildCardTraverser.
- traverseAnyAttribute(child, schemaDoc, grammar);
+ traverseAnyAttribute(child, schemaDoc, grammar);
if (attrGrp.fAttributeWC == null) {
- attrGrp.fAttributeWC = tempAttrWC;
+ attrGrp.fAttributeWC = tempAttrWC;
}
// perform intersection of attribute wildcard
else {
- attrGrp.fAttributeWC = attrGrp.fAttributeWC.
- performIntersectionWith(tempAttrWC);
+ attrGrp.fAttributeWC = attrGrp.fAttributeWC.
+ performIntersectionWith(tempAttrWC);
}
child = DOMUtil.getNextSiblingElement(child);
}
@@ -453,16 +471,16 @@
Element checkContent( Element content, Object[] parentAttrs, XSDocumentInfo schemaDoc ) {
if (content == null) {
- return content;
+ return content;
}
if (content.getLocalName().equals(SchemaSymbols.ELT_ANNOTATION)) {
- traverseAnnotationDecl(content, parentAttrs, false, schemaDoc);
+ traverseAnnotationDecl(content, parentAttrs, false, schemaDoc);
- content = DOMUtil.getNextSiblingElement(content);
+ content = DOMUtil.getNextSiblingElement(content);
}
-
+
return content;
}
@@ -502,7 +520,7 @@
// for the child of a model group definition.
if (isGroupChild && (!defaultMin || !defaultMax)) {
Object[] args = new Object[]{parent.getAttribute(SchemaSymbols.ATT_NAME),
- particleName};
+ particleName};
fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
"MinMaxOnGroupChild",
args,
1.23 +2 -2 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDComplexTypeTraverser.java
Index: XSDComplexTypeTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDComplexTypeTraverser.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- XSDComplexTypeTraverser.java 2001/10/07 18:32:31 1.22
+++ XSDComplexTypeTraverser.java 2001/10/11 15:13:33 1.23
@@ -80,7 +80,7 @@
* ((group | all | choice | sequence)?,
* ((attribute | attributeGroup)*, anyAttribute?))))
* </complexType>
- * @version $Id: XSDComplexTypeTraverser.java,v 1.22 2001/10/07 18:32:31 lmartin Exp $
+ * @version $Id: XSDComplexTypeTraverser.java,v 1.23 2001/10/11 15:13:33 elena Exp $
*/
class XSDComplexTypeTraverser extends XSDAbstractParticleTraverser {
@@ -375,7 +375,7 @@
}
- typeInfo.fDatatypeValidator = createRestrictedValidator(baseValidator, fFacetData);
+ typeInfo.fDatatypeValidator = createRestrictedValidator(baseValidator, fFacetData, fErrorReporter);
if (typeInfo.fDatatypeValidator == null) {
// REVISIT error msg
reportGenericSchemaError("Internal error - could not create a new validator");
1.21 +12 -13 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDSimpleTypeTraverser.java
Index: XSDSimpleTypeTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDSimpleTypeTraverser.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- XSDSimpleTypeTraverser.java 2001/10/09 20:09:46 1.20
+++ XSDSimpleTypeTraverser.java 2001/10/11 15:13:33 1.21
@@ -109,7 +109,7 @@
* </union>
*
* @author Elena Litani, IBM
- * @version $Id: XSDSimpleTypeTraverser.java,v 1.20 2001/10/09 20:09:46 elena Exp $
+ * @version $Id: XSDSimpleTypeTraverser.java,v 1.21 2001/10/11 15:13:33 elena Exp $
*/
class XSDSimpleTypeTraverser extends XSDAbstractTraverser {
@@ -160,7 +160,6 @@
String nameProperty = (String)attrValues[XSAttributeChecker.ATTIDX_NAME];
String qualifiedName = nameProperty;
Hashtable fFacetData = null;
-
//---------------------------------------------------
// set qualified name
//---------------------------------------------------
@@ -251,7 +250,12 @@
}
if (DOMUtil.getNextSiblingElement(content) != null) {
// REVISIT: Localize
- reportGenericSchemaError("error in content of simpleType");
+
+ Object[] args = { qualifiedName};
+ fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
+ "InvalidSTContent",
+ args, XMLErrorReporter.SEVERITY_ERROR);
+
}
DatatypeValidator baseValidator = null;
@@ -390,25 +394,20 @@
fListName = fSchemaHandler.EMPTY_STRING;
}
}
-
if (restriction && content != null) {
fFacetInfo fi = traverseFacets(content, contentAttrs,nameProperty, baseValidator, schemaDoc, fGrammar);
fFacetData = fi.facetdata;
}
-
DatatypeValidator newDV = null;
+
if (list) {
- try {
- newDV = new ListDatatypeValidator(baseValidator, fFacetData, true);
- } catch (InvalidDatatypeFacetException e) {
- reportGenericSchemaError(e.getMessage());
- }
+ newDV = new ListDatatypeValidator(baseValidator, fFacetData, true, fErrorReporter);
}
- else if (restriction) {
- newDV = createRestrictedValidator(baseValidator, fFacetData);
+ else if (restriction) {
+ newDV = createRestrictedValidator(baseValidator, fFacetData, fErrorReporter);
}
else { //union
- newDV = new UnionDatatypeValidator(dTValidators);
+ newDV = new UnionDatatypeValidator(dTValidators, fErrorReporter);
}
if (newDV != null && isGlobal) {
1.8 +5 -3 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/AbstractDatatypeValidator.java
Index: AbstractDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/AbstractDatatypeValidator.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- AbstractDatatypeValidator.java 2001/09/19 18:16:07 1.7
+++ AbstractDatatypeValidator.java 2001/10/11 15:13:33 1.8
@@ -57,7 +57,7 @@
/**
- * @version $Id: AbstractDatatypeValidator.java,v 1.7 2001/09/19 18:16:07 neilg Exp $
+ * @version $Id: AbstractDatatypeValidator.java,v 1.8 2001/10/11 15:13:33 elena Exp $
* @author Elena Litani
* @author Jeffrey Rodriguez
*/
@@ -69,6 +69,7 @@
import java.util.Hashtable;
import java.util.Locale;
import org.apache.xerces.impl.v2.XSTypeDecl;
+import org.apache.xerces.impl.XMLErrorReporter;
import org.apache.xerces.impl.v2.util.regex.RegularExpression;
@@ -81,8 +82,9 @@
protected DatatypeMessageProvider fMessageProvider = new DatatypeMessageProvider();
protected Locale fLocale = null;
protected short fFlags = 0; //flags fixed facets
-
- /**
+ protected XMLErrorReporter fErrorReporter = null;
+
+ /**
* Checks that "content" string is valid
* datatype.
* If invalid a Datatype validation exception is thrown.
1.3 +264 -261 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/AbstractNumericFacetValidator.java
Index: AbstractNumericFacetValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/AbstractNumericFacetValidator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractNumericFacetValidator.java 2001/09/19 18:16:07 1.2
+++ AbstractNumericFacetValidator.java 2001/10/11 15:13:33 1.3
@@ -64,6 +64,8 @@
import java.io.IOException;
import org.apache.xerces.impl.v2.SchemaSymbols;
import org.apache.xerces.impl.v2.util.regex.RegularExpression;
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
/**
* AbstractNumericFacetValidator is a base class for decimal, double, float,
@@ -71,7 +73,7 @@
* minInclusive, maxInclusive, minExclusive, maxExclusive according to schema specs.
*
* @author Elena Litani
- * @version $Id: AbstractNumericFacetValidator.java,v 1.2 2001/09/19 18:16:07 neilg Exp $
+ * @version $Id: AbstractNumericFacetValidator.java,v 1.3 2001/10/11 15:13:33 elena Exp $
*/
public abstract class AbstractNumericFacetValidator extends AbstractDatatypeValidator {
@@ -84,27 +86,30 @@
protected static final short INDETERMINATE=2;
- public AbstractNumericFacetValidator () throws InvalidDatatypeFacetException {
- this( null, null, false ); // Native, No Facets defined, Restriction
+ public AbstractNumericFacetValidator () {
+ this( null, null, false, null ); // Native, No Facets defined, Restriction
}
public AbstractNumericFacetValidator ( DatatypeValidator base,
Hashtable facets,
- boolean derivedByList) throws InvalidDatatypeFacetException {
+ boolean derivedByList, XMLErrorReporter reporter) {
fBaseValidator = base;
+ fErrorReporter = reporter;
// list types are handled by ListDatatypeValidator, we do nothing here.
if (derivedByList)
return;
- initializeValues();
- // Set Facets if any defined
- if (facets != null) {
- int result; // result of comparison
- Vector enumeration = null;
- for (Enumeration e = facets.keys(); e.hasMoreElements();) {
- String key = (String) e.nextElement();
- String value = null;
- try {
+ try {
+
+ initializeValues();
+ // Set Facets if any defined
+ if (facets != null) {
+ int result; // result of comparison
+ Vector enumeration = null;
+ for (Enumeration e = facets.keys(); e.hasMoreElements();) {
+ String key = (String) e.nextElement();
+ String value = null;
+
if (key.equals(SchemaSymbols.ELT_PATTERN)) {
fFacetsDefined |= DatatypeValidator.FACET_PATTERN;
fPattern = (String) facets.get(key);
@@ -141,276 +146,274 @@
else {
assignAdditionalFacets(key, facets);
}
- }
- catch (Exception ex) {
- if (value == null) {
- //invalid facet error
- throw new InvalidDatatypeFacetException( ex.getMessage());
- }
- else {
- String msg = getErrorString(
- DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.ILLEGAL_FACET_VALUE],
- new Object [] { value, key});
- throw new InvalidDatatypeFacetException(msg);
- }
- }
- }
- if (fFacetsDefined != 0) {
- // check 4.3.8.c1 error: maxInclusive + maxExclusive
- if (((fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) &&
- ((fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0)) {
- throw new InvalidDatatypeFacetException( "It is an error for both maxInclusive and maxExclusive to be specified for the same datatype." );
- }
- // check 4.3.9.c1 error: minInclusive + minExclusive
- if (((fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0) &&
- ((fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0)) {
- throw new InvalidDatatypeFacetException( "It is an error for both minInclusive and minExclusive to be specified for the same datatype." );
- }
- // check 4.3.7.c1 must: minInclusive <= maxInclusive
- if (((fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0) &&
- ((fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0)) {
- result = compareValues(fMinInclusive, fMaxInclusive);
- if (result == 1 || result == INDETERMINATE)
- throw new InvalidDatatypeFacetException( "minInclusive value ='" + getMinInclusive(false) + "'must be <= maxInclusive value ='" +
- getMaxInclusive(false) + "'. " );
- }
- // check 4.3.8.c2 must: minExclusive <= maxExclusive ??? minExclusive < maxExclusive
- if (((fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) && ((fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0)) {
- result =compareValues(fMinExclusive, fMaxExclusive);
- if (result == 1 || result == INDETERMINATE)
- throw new InvalidDatatypeFacetException( "minExclusive value ='" + getMinExclusive(false) + "'must be <= maxExclusive value ='" +
- getMaxExclusive(false) + "'. " );
- }
- // check 4.3.9.c2 must: minExclusive < maxInclusive
- if (((fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0) && ((fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0)) {
- if (compareValues(fMinExclusive, fMaxInclusive) != -1)
- throw new InvalidDatatypeFacetException( "minExclusive value ='" + getMinExclusive(false) + "'must be > maxInclusive value ='" +
- getMaxInclusive(false) + "'. " );
}
- // check 4.3.10.c1 must: minInclusive < maxExclusive
- if (((fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) && ((fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0)) {
- if (compareValues(fMinInclusive, fMaxExclusive) != -1)
- throw new InvalidDatatypeFacetException( "minInclusive value ='" + getMinInclusive(false) + "'must be < maxExclusive value ='" +
- getMaxExclusive(false) + "'. " );
- }
- checkFacetConstraints();
-
- }
- if (base != null) {
- AbstractNumericFacetValidator numBase = (AbstractNumericFacetValidator)base;
if (fFacetsDefined != 0) {
-
- // check 4.3.7.c2 error:
- // maxInclusive > base.maxInclusive
- // maxInclusive >= base.maxExclusive
- // maxInclusive < base.minInclusive
- // maxInclusive <= base.minExclusive
-
- if (((fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0)) {
- if (((numBase.fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0)) {
- result = compareValues(fMaxInclusive, numBase.fMaxInclusive);
- if ((numBase.fFlags & DatatypeValidator.FACET_MAXINCLUSIVE) != 0 &&
- result != 0) {
- throw new InvalidDatatypeFacetException( "maxInclusive value = '" + getMaxInclusive(false) +
- "' must be equal to base.maxInclusive value = '" +
- getMaxInclusive(true) + "' with attribute {fixed} = true" );
- }
- if (result == 1 || result == INDETERMINATE) {
- throw new InvalidDatatypeFacetException( "maxInclusive value ='" + getMaxInclusive(false) + "' must be <= base.maxInclusive value ='" +
- getMaxInclusive(true) + "'." );
+ // check 4.3.8.c1 error: maxInclusive + maxExclusive
+ if (((fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) &&
+ ((fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0)) {
+ throw new InvalidDatatypeFacetException( "It is an error for both maxInclusive and maxExclusive to be specified for the same datatype." );
+ }
+ // check 4.3.9.c1 error: minInclusive + minExclusive
+ if (((fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0) &&
+ ((fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0)) {
+ throw new InvalidDatatypeFacetException( "It is an error for both minInclusive and minExclusive to be specified for the same datatype." );
+ }
+
+ // check 4.3.7.c1 must: minInclusive <= maxInclusive
+ if (((fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0) &&
+ ((fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0)) {
+ result = compareValues(fMinInclusive, fMaxInclusive);
+ if (result == 1 || result == INDETERMINATE)
+ throw new InvalidDatatypeFacetException( "minInclusive value ='" + getMinInclusive(false) + "'must be <= maxInclusive value ='" +
+ getMaxInclusive(false) + "'. " );
+ }
+ // check 4.3.8.c2 must: minExclusive <= maxExclusive ??? minExclusive < maxExclusive
+ if (((fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) && ((fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0)) {
+ result =compareValues(fMinExclusive, fMaxExclusive);
+ if (result == 1 || result == INDETERMINATE)
+ throw new InvalidDatatypeFacetException( "minExclusive value ='" + getMinExclusive(false) + "'must be <= maxExclusive value ='" +
+ getMaxExclusive(false) + "'. " );
+ }
+ // check 4.3.9.c2 must: minExclusive < maxInclusive
+ if (((fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0) && ((fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0)) {
+ if (compareValues(fMinExclusive, fMaxInclusive) != -1)
+ throw new InvalidDatatypeFacetException( "minExclusive value ='" + getMinExclusive(false) + "'must be > maxInclusive value ='" +
+ getMaxInclusive(false) + "'. " );
+ }
+ // check 4.3.10.c1 must: minInclusive < maxExclusive
+ if (((fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) && ((fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0)) {
+ if (compareValues(fMinInclusive, fMaxExclusive) != -1)
+ throw new InvalidDatatypeFacetException( "minInclusive value ='" + getMinInclusive(false) + "'must be < maxExclusive value ='" +
+ getMaxExclusive(false) + "'. " );
+ }
+ checkFacetConstraints();
+
+ }
+
+ if (base != null) {
+ AbstractNumericFacetValidator numBase = (AbstractNumericFacetValidator)base;
+ if (fFacetsDefined != 0) {
+
+ // check 4.3.7.c2 error:
+ // maxInclusive > base.maxInclusive
+ // maxInclusive >= base.maxExclusive
+ // maxInclusive < base.minInclusive
+ // maxInclusive <= base.minExclusive
+
+ if (((fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0)) {
+ if (((numBase.fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0)) {
+ result = compareValues(fMaxInclusive, numBase.fMaxInclusive);
+ if ((numBase.fFlags & DatatypeValidator.FACET_MAXINCLUSIVE) != 0 &&
+ result != 0) {
+ throw new InvalidDatatypeFacetException( "maxInclusive value = '" + getMaxInclusive(false) +
+ "' must be equal to base.maxInclusive value = '" +
+ getMaxInclusive(true) + "' with attribute {fixed} = true" );
+ }
+ if (result == 1 || result == INDETERMINATE) {
+ throw new InvalidDatatypeFacetException( "maxInclusive value ='" + getMaxInclusive(false) + "' must be <= base.maxInclusive value ='" +
+ getMaxInclusive(true) + "'." );
+ }
}
- }
- if (((numBase.fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) &&
- compareValues(fMaxInclusive, numBase.fMaxExclusive) != -1)
- throw new InvalidDatatypeFacetException(
- "maxInclusive value ='" + getMaxInclusive(false) + "' must be < base.maxExclusive value ='" +
- getMaxExclusive(true) + "'." );
- if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0)) {
- result = compareValues(fMaxInclusive, numBase.fMinInclusive);
- if (result == -1 || result == INDETERMINATE) {
- throw new InvalidDatatypeFacetException( "maxInclusive value ='" + getMaxInclusive(false) + "' must be >= base.minInclusive value ='" +
- getMinInclusive(true) + "'." );
- }
- }
- if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0) &&
- compareValues(fMaxInclusive, numBase.fMinExclusive ) != 1)
- throw new InvalidDatatypeFacetException(
- "maxInclusive value ='" + getMaxInclusive(false) + "' must be > base.minExclusive value ='" +
- getMinExclusive(true) + "'." );
- }
-
- // check 4.3.8.c3 error:
- // maxExclusive > base.maxExclusive
- // maxExclusive > base.maxInclusive
- // maxExclusive <= base.minInclusive
- // maxExclusive <= base.minExclusive
- if (((fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0)) {
- if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0)) {
- result= compareValues(fMaxExclusive, numBase.fMaxExclusive);
- if ((numBase.fFlags & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0 &&
- result != 0) {
- throw new InvalidDatatypeFacetException( "maxExclusive value = '" + getMaxExclusive(false) +
- "' must be equal to base.maxExclusive value = '" +
- getMaxExclusive(true) + "' with attribute {fixed} = true" );
- }
- if (result == 1 || result == INDETERMINATE) {
- throw new InvalidDatatypeFacetException( "maxExclusive value ='" + getMaxExclusive(false) + "' must be < base.maxExclusive value ='" +
- getMaxExclusive(true) + "'." );
- }
- }
- if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0)) {
- result= compareValues(fMaxExclusive, numBase.fMaxInclusive);
- if (result == 1 || result == INDETERMINATE) {
- throw new InvalidDatatypeFacetException( "maxExclusive value ='" + getMaxExclusive(false) + "' must be <= base.maxInclusive value ='" +
- getMaxInclusive(true) + "'." );
- }
- }
- if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0) &&
- compareValues(fMaxExclusive, numBase.fMinExclusive ) != 1)
- throw new InvalidDatatypeFacetException( "maxExclusive value ='" + getMaxExclusive(false) + "' must be > base.minExclusive value ='" +
- getMinExclusive(true) + "'." );
- if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0) &&
- compareValues(fMaxExclusive, numBase.fMinInclusive) != 1)
- throw new InvalidDatatypeFacetException( "maxExclusive value ='" + getMaxExclusive(false) + "' must be > base.minInclusive value ='" +
- getMinInclusive(true) + "'." );
- }
-
- // check 4.3.9.c3 error:
- // minExclusive < base.minExclusive
- // minExclusive > base.maxInclusive ??? minExclusive >= base.maxInclusive
- // minExclusive < base.minInclusive
- // minExclusive >= base.maxExclusive
- if (((fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0)) {
- if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0)) {
- result= compareValues(fMinExclusive, numBase.fMinExclusive);
- if ((numBase.fFlags & DatatypeValidator.FACET_MINEXCLUSIVE) != 0 &&
- result != 0) {
- throw new InvalidDatatypeFacetException( "minExclusive value = '" + getMinExclusive(false) +
- "' must be equal to base.minExclusive value = '" +
- getMinExclusive(true) + "' with attribute {fixed} = true" );
- }
- if (result == -1 || result == INDETERMINATE) {
- throw new InvalidDatatypeFacetException( "minExclusive value ='" + getMinExclusive(false) + "' must be >= base.minExclusive value ='" +
- getMinExclusive(true) + "'." );
- }
- }
- if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0)) {
- result=compareValues(fMinExclusive, numBase.fMaxInclusive);
- if (result == 1 || result == INDETERMINATE) {
+ if (((numBase.fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) &&
+ compareValues(fMaxInclusive, numBase.fMaxExclusive) != -1)
throw new InvalidDatatypeFacetException(
- "minExclusive value ='" + getMinExclusive(false) + "' must be <= base.maxInclusive value ='" +
- getMaxInclusive(true) + "'." );
+ "maxInclusive value ='" + getMaxInclusive(false) + "' must be < base.maxExclusive value ='" +
+ getMaxExclusive(true) + "'." );
+ if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0)) {
+ result = compareValues(fMaxInclusive, numBase.fMinInclusive);
+ if (result == -1 || result == INDETERMINATE) {
+ throw new InvalidDatatypeFacetException( "maxInclusive value ='" + getMaxInclusive(false) + "' must be >= base.minInclusive value ='" +
+ getMinInclusive(true) + "'." );
+ }
}
- }
- if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0)) {
- result = compareValues(fMinExclusive, numBase.fMinInclusive);
- if (result == -1 || result == INDETERMINATE) {
+ if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0) &&
+ compareValues(fMaxInclusive, numBase.fMinExclusive ) != 1)
throw new InvalidDatatypeFacetException(
- "minExclusive value ='" + getMinExclusive(false) + "' must be >= base.minInclusive value ='" +
- getMinInclusive(true) + "'." );
- }
+ "maxInclusive value ='" + getMaxInclusive(false) + "' must be > base.minExclusive value ='" +
+ getMinExclusive(true) + "'." );
}
- if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) &&
- compareValues(fMinExclusive, numBase.fMaxExclusive) != -1)
- throw new InvalidDatatypeFacetException( "minExclusive value ='" + getMinExclusive(false) + "' must be < base.maxExclusive value ='" +
- getMaxExclusive(true) + "'." );
- }
-
- // check 4.3.10.c2 error:
- // minInclusive < base.minInclusive
- // minInclusive > base.maxInclusive
- // minInclusive <= base.minExclusive
- // minInclusive >= base.maxExclusive
- if (((fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0)) {
- if (((numBase.fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0)) {
- result = compareValues(fMinInclusive, numBase.fMinInclusive);
- if ((numBase.fFlags & DatatypeValidator.FACET_MININCLUSIVE) != 0 &&
- result != 0) {
- throw new InvalidDatatypeFacetException( "minInclusive value = '" + getMinInclusive(false) +
- "' must be equal to base.minInclusive value = '" +
- getMinInclusive(true) + "' with attribute {fixed} = true" );
- }
- if (result == -1 || result == INDETERMINATE) {
- throw new InvalidDatatypeFacetException( "minInclusive value ='" + getMinInclusive(false) + "' must be >= base.minInclusive value ='" +
+
+ // check 4.3.8.c3 error:
+ // maxExclusive > base.maxExclusive
+ // maxExclusive > base.maxInclusive
+ // maxExclusive <= base.minInclusive
+ // maxExclusive <= base.minExclusive
+ if (((fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0)) {
+ if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0)) {
+ result= compareValues(fMaxExclusive, numBase.fMaxExclusive);
+ if ((numBase.fFlags & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0 &&
+ result != 0) {
+ throw new InvalidDatatypeFacetException( "maxExclusive value = '" + getMaxExclusive(false) +
+ "' must be equal to base.maxExclusive value = '" +
+ getMaxExclusive(true) + "' with attribute {fixed} = true" );
+ }
+ if (result == 1 || result == INDETERMINATE) {
+ throw new InvalidDatatypeFacetException( "maxExclusive value ='" + getMaxExclusive(false) + "' must be < base.maxExclusive value ='" +
+ getMaxExclusive(true) + "'." );
+ }
+ }
+ if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0)) {
+ result= compareValues(fMaxExclusive, numBase.fMaxInclusive);
+ if (result == 1 || result == INDETERMINATE) {
+ throw new InvalidDatatypeFacetException( "maxExclusive value ='" + getMaxExclusive(false) + "' must be <= base.maxInclusive value ='" +
+ getMaxInclusive(true) + "'." );
+ }
+ }
+ if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0) &&
+ compareValues(fMaxExclusive, numBase.fMinExclusive ) != 1)
+ throw new InvalidDatatypeFacetException( "maxExclusive value ='" + getMaxExclusive(false) + "' must be > base.minExclusive value ='" +
+ getMinExclusive(true) + "'." );
+ if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0) &&
+ compareValues(fMaxExclusive, numBase.fMinInclusive) != 1)
+ throw new InvalidDatatypeFacetException( "maxExclusive value ='" + getMaxExclusive(false) + "' must be > base.minInclusive value ='" +
getMinInclusive(true) + "'." );
- }
}
- if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0)) {
- result=compareValues(fMinInclusive, numBase.fMaxInclusive);
- if (result == 1 || result == INDETERMINATE) {
- throw new InvalidDatatypeFacetException( "minInclusive value ='" + getMinInclusive(false) + "' must be <= base.maxInclusive value ='" +
- getMaxInclusive(true) + "'." );
- }
+
+ // check 4.3.9.c3 error:
+ // minExclusive < base.minExclusive
+ // minExclusive > base.maxInclusive ??? minExclusive >= base.maxInclusive
+ // minExclusive < base.minInclusive
+ // minExclusive >= base.maxExclusive
+ if (((fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0)) {
+ if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0)) {
+ result= compareValues(fMinExclusive, numBase.fMinExclusive);
+ if ((numBase.fFlags & DatatypeValidator.FACET_MINEXCLUSIVE) != 0 &&
+ result != 0) {
+ throw new InvalidDatatypeFacetException( "minExclusive value = '" + getMinExclusive(false) +
+ "' must be equal to base.minExclusive value = '" +
+ getMinExclusive(true) + "' with attribute {fixed} = true" );
+ }
+ if (result == -1 || result == INDETERMINATE) {
+ throw new InvalidDatatypeFacetException( "minExclusive value ='" + getMinExclusive(false) + "' must be >= base.minExclusive value ='" +
+ getMinExclusive(true) + "'." );
+ }
+ }
+ if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0)) {
+ result=compareValues(fMinExclusive, numBase.fMaxInclusive);
+ if (result == 1 || result == INDETERMINATE) {
+ throw new InvalidDatatypeFacetException(
+ "minExclusive value ='" + getMinExclusive(false) + "' must be <= base.maxInclusive value ='" +
+ getMaxInclusive(true) + "'." );
+ }
+ }
+ if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0)) {
+ result = compareValues(fMinExclusive, numBase.fMinInclusive);
+ if (result == -1 || result == INDETERMINATE) {
+ throw new InvalidDatatypeFacetException(
+ "minExclusive value ='" + getMinExclusive(false) + "' must be >= base.minInclusive value ='" +
+ getMinInclusive(true) + "'." );
+ }
+ }
+ if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) &&
+ compareValues(fMinExclusive, numBase.fMaxExclusive) != -1)
+ throw new InvalidDatatypeFacetException( "minExclusive value ='" + getMinExclusive(false) + "' must be < base.maxExclusive value ='" +
+ getMaxExclusive(true) + "'." );
}
- if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0) &&
- compareValues(fMinInclusive, numBase.fMinExclusive ) != 1)
- throw new InvalidDatatypeFacetException( "minInclusive value ='" + getMinInclusive(false) + "' must be > base.minExclusive value ='" +
- getMinExclusive(true) + "'." );
- if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) &&
- compareValues(fMinInclusive, numBase.fMaxExclusive) != -1)
- throw new InvalidDatatypeFacetException( "minInclusive value ='" + getMinInclusive(false) + "' must be < base.maxExclusive value ='" +
- getMaxExclusive(true) + "'." );
+
+ // check 4.3.10.c2 error:
+ // minInclusive < base.minInclusive
+ // minInclusive > base.maxInclusive
+ // minInclusive <= base.minExclusive
+ // minInclusive >= base.maxExclusive
+ if (((fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0)) {
+ if (((numBase.fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0)) {
+ result = compareValues(fMinInclusive, numBase.fMinInclusive);
+ if ((numBase.fFlags & DatatypeValidator.FACET_MININCLUSIVE) != 0 &&
+ result != 0) {
+ throw new InvalidDatatypeFacetException( "minInclusive value = '" + getMinInclusive(false) +
+ "' must be equal to base.minInclusive value = '" +
+ getMinInclusive(true) + "' with attribute {fixed} = true" );
+ }
+ if (result == -1 || result == INDETERMINATE) {
+ throw new InvalidDatatypeFacetException( "minInclusive value ='" + getMinInclusive(false) + "' must be >= base.minInclusive value ='" +
+ getMinInclusive(true) + "'." );
+ }
+ }
+ if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0)) {
+ result=compareValues(fMinInclusive, numBase.fMaxInclusive);
+ if (result == 1 || result == INDETERMINATE) {
+ throw new InvalidDatatypeFacetException( "minInclusive value ='" + getMinInclusive(false) + "' must be <= base.maxInclusive value ='" +
+ getMaxInclusive(true) + "'." );
+ }
+ }
+ if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0) &&
+ compareValues(fMinInclusive, numBase.fMinExclusive ) != 1)
+ throw new InvalidDatatypeFacetException( "minInclusive value ='" + getMinInclusive(false) + "' must be > base.minExclusive value ='" +
+ getMinExclusive(true) + "'." );
+ if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) &&
+ compareValues(fMinInclusive, numBase.fMaxExclusive) != -1)
+ throw new InvalidDatatypeFacetException( "minInclusive value ='" + getMinInclusive(false) + "' must be < base.maxExclusive value ='" +
+ getMaxExclusive(true) + "'." );
+ }
+ checkBaseFacetConstraints();
+
}
- checkBaseFacetConstraints();
+ // check question error: fractionDigits > base.fractionDigits ???
+ // check question error: fractionDigits > base.totalDigits ???
+ // check question error: totalDigits conflicts with bounds ???
- }
- // check question error: fractionDigits > base.fractionDigits ???
- // check question error: fractionDigits > base.totalDigits ???
- // check question error: totalDigits conflicts with bounds ???
-
- // inherit enumeration
- if ((fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) == 0 &&
- (numBase.fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) != 0) {
- fFacetsDefined |= DatatypeValidator.FACET_ENUMERATION;
- fEnumeration = numBase.fEnumeration;
- }
- // inherit maxExclusive
- if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) &&
- !((fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) && !((fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0)) {
- fFacetsDefined |= FACET_MAXEXCLUSIVE;
- fMaxExclusive = numBase.fMaxExclusive;
- }
- // inherit maxInclusive
- if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0) &&
- !((fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) && !((fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0)) {
- fFacetsDefined |= FACET_MAXINCLUSIVE;
- fMaxInclusive = numBase.fMaxInclusive;
- }
- // inherit minExclusive
- if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0) &&
- !((fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0) && !((fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0)) {
- fFacetsDefined |= FACET_MINEXCLUSIVE;
- fMinExclusive = numBase.fMinExclusive;
- }
- // inherit minExclusive
- if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0) &&
- !((fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0) && !((fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0)) {
- fFacetsDefined |= FACET_MININCLUSIVE;
- fMinInclusive = numBase.fMinInclusive;
- }
+ // inherit enumeration
+ if ((fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) == 0 &&
+ (numBase.fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) != 0) {
+ fFacetsDefined |= DatatypeValidator.FACET_ENUMERATION;
+ fEnumeration = numBase.fEnumeration;
+ }
+ // inherit maxExclusive
+ if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) &&
+ !((fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) && !((fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0)) {
+ fFacetsDefined |= FACET_MAXEXCLUSIVE;
+ fMaxExclusive = numBase.fMaxExclusive;
+ }
+ // inherit maxInclusive
+ if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0) &&
+ !((fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) && !((fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0)) {
+ fFacetsDefined |= FACET_MAXINCLUSIVE;
+ fMaxInclusive = numBase.fMaxInclusive;
+ }
+ // inherit minExclusive
+ if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0) &&
+ !((fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0) && !((fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0)) {
+ fFacetsDefined |= FACET_MINEXCLUSIVE;
+ fMinExclusive = numBase.fMinExclusive;
+ }
+ // inherit minExclusive
+ if ((( numBase.fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0) &&
+ !((fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0) && !((fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0)) {
+ fFacetsDefined |= FACET_MININCLUSIVE;
+ fMinInclusive = numBase.fMinInclusive;
+ }
- inheritAdditionalFacets();
+ inheritAdditionalFacets();
- //inherit fixed values
- fFlags |= numBase.fFlags;
+ //inherit fixed values
+ fFlags |= numBase.fFlags;
- // check 4.3.5.c0 must: enumeration values from the value space of base
- if ((fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) != 0) {
- if (enumeration != null) {
- try {
- setEnumeration(enumeration);
- }
- catch (Exception idve) {
- throw new InvalidDatatypeFacetException( idve.getMessage());
+ // check 4.3.5.c0 must: enumeration values from the value space of base
+ if ((fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) != 0) {
+ if (enumeration != null) {
+ try {
+ setEnumeration(enumeration);
+ }
+ catch (Exception idve) {
+ throw new InvalidDatatypeFacetException( idve.getMessage());
+ }
}
- }
+ }
}
+ }//End of Facet setup
+ }
+ catch (Exception e) {
+ if (fErrorReporter == null) {
+ throw new RuntimeException("InternalDatatype error ANFV.");
}
- }//End of Facet setup
+ fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
+ "DatatypeFacetError", new Object [] { ((Exception)e).getMessage()},
+ XMLErrorReporter.SEVERITY_ERROR);
+ }
}
1.3 +7 -5 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/AbstractNumericValidator.java
Index: AbstractNumericValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/AbstractNumericValidator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractNumericValidator.java 2001/09/19 18:16:07 1.2
+++ AbstractNumericValidator.java 2001/10/11 15:13:33 1.3
@@ -66,24 +66,26 @@
import org.apache.xerces.impl.v2.SchemaSymbols;
import org.apache.xerces.impl.v2.util.regex.RegularExpression;
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
/**
* AbstractNumericValidator is a base class of decimal, double, and float
* schema datatypes
*
* @author Elena Litani
- * @version $Id: AbstractNumericValidator.java,v 1.2 2001/09/19 18:16:07 neilg Exp $
+ * @version $Id: AbstractNumericValidator.java,v 1.3 2001/10/11 15:13:33 elena Exp $
*/
public abstract class AbstractNumericValidator extends AbstractNumericFacetValidator {
- public AbstractNumericValidator () throws InvalidDatatypeFacetException {
- super( null, null, false ); // Native, No Facets defined, Restriction
+ public AbstractNumericValidator () {
+ super( null, null, false , null); // Native, No Facets defined, Restriction
}
public AbstractNumericValidator ( DatatypeValidator base,
Hashtable facets,
- boolean derivedByList) throws InvalidDatatypeFacetException {
- super (base, facets, derivedByList);
+ boolean derivedByList, XMLErrorReporter reporter) {
+ super (base, facets, derivedByList, reporter);
}
1.7 +228 -211 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/AbstractStringValidator.java
Index: AbstractStringValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/AbstractStringValidator.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AbstractStringValidator.java 2001/09/21 16:22:30 1.6
+++ AbstractStringValidator.java 2001/10/11 15:13:33 1.7
@@ -66,12 +66,16 @@
import org.apache.xerces.impl.v2.util.regex.RegularExpression;
import org.apache.xerces.util.XMLChar;
+
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
+
/**
* AbstractStringValidator is a base class for anyURI, string,
* hexBinary, base64Binary, QName and Notation datatypes.
*
* @author Elena Litani
- * @version $Id: AbstractStringValidator.java,v 1.6 2001/09/21 16:22:30 sandygao Exp $
+ * @version $Id: AbstractStringValidator.java,v 1.7 2001/10/11 15:13:33 elena Exp $
*/
public abstract class AbstractStringValidator extends AbstractDatatypeValidator {
@@ -94,241 +98,253 @@
protected String fTokenType = SPECIAL_TOKEN_NONE; //flags special token parser
- public AbstractStringValidator () throws InvalidDatatypeFacetException{
- this( null, null, false ); // Native, No Facets defined, Restriction
+ public AbstractStringValidator () {
+ this( null, null, false, null ); // Native, No Facets defined, Restriction
}
public AbstractStringValidator ( DatatypeValidator base, Hashtable facets,
- boolean derivedByList ) throws InvalidDatatypeFacetException {
+ boolean derivedByList, XMLErrorReporter reporter) {
// Set base type
fBaseValidator = base;
+ fErrorReporter = reporter;
+ try {
- if ( derivationList(derivedByList) )
- return;
- // Set Facets if any defined
- if ( facets != null ) {
- for ( Enumeration e = facets.keys(); e.hasMoreElements(); ) {
- String key = (String) e.nextElement();
-
- if ( key.equals(SchemaSymbols.ELT_LENGTH) ) {
- fFacetsDefined |= DatatypeValidator.FACET_LENGTH;
- String lengthValue = (String)facets.get(key);
- try {
- fLength = Integer.parseInt( lengthValue );
- }
- catch ( NumberFormatException nfe ) {
- throw new InvalidDatatypeFacetException("Length value '"+lengthValue+"' is invalid.");
- }
- // check 4.3.1.c0 must: length >= 0
- if ( fLength < 0 )
- throw new InvalidDatatypeFacetException("Length value '"+lengthValue+"' must be a nonNegativeInteger.");
-
- }
- else if ( key.equals(SchemaSymbols.ELT_MINLENGTH) ) {
- fFacetsDefined |= DatatypeValidator.FACET_MINLENGTH;
- String minLengthValue = (String)facets.get(key);
- try {
- fMinLength = Integer.parseInt( minLengthValue );
- }
- catch ( NumberFormatException nfe ) {
- throw new InvalidDatatypeFacetException("minLength value '"+minLengthValue+"' is invalid.");
- }
- // check 4.3.2.c0 must: minLength >= 0
- if ( fMinLength < 0 )
- throw new InvalidDatatypeFacetException("minLength value '"+minLengthValue+"' must be a nonNegativeInteger.");
+ if (derivationList(derivedByList))
+ return;
+ // Set Facets if any defined
+ if (facets != null) {
+ for (Enumeration e = facets.keys(); e.hasMoreElements();) {
+ String key = (String) e.nextElement();
- }
- else if ( key.equals(SchemaSymbols.ELT_MAXLENGTH) ) {
- fFacetsDefined |= DatatypeValidator.FACET_MAXLENGTH;
- String maxLengthValue = (String)facets.get(key);
- try {
- fMaxLength = Integer.parseInt( maxLengthValue );
- }
- catch ( NumberFormatException nfe ) {
- throw new InvalidDatatypeFacetException("maxLength value '"+maxLengthValue+"' is invalid.");
- }
- // check 4.3.3.c0 must: maxLength >= 0
- if ( fMaxLength < 0 )
- throw new InvalidDatatypeFacetException("maxLength value '"+maxLengthValue+"' must be a nonNegativeInteger.");
- }
- else if ( key.equals(SchemaSymbols.ELT_PATTERN) ) {
- fFacetsDefined |= DatatypeValidator.FACET_PATTERN;
- fPattern = (String)facets.get(key);
- if ( fPattern != null )
- fRegex = new RegularExpression(fPattern, "X");
- }
- else if ( key.equals(SchemaSymbols.ELT_ENUMERATION) ) {
- fEnumeration = (Vector)facets.get(key);
- fFacetsDefined |= DatatypeValidator.FACET_ENUMERATION;
- }
- else if ( key.equals(DatatypeValidator.FACET_FIXED) ) {// fixed flags
- fFlags = ((Short)facets.get(key)).shortValue();
- }
- else if ( key == FACET_SPECIAL_TOKEN ) {// special token parser
- setTokenType((String)facets.get(key));
- }
- else {
- assignAdditionalFacets(key, facets);
- }
- }
+ if (key.equals(SchemaSymbols.ELT_LENGTH)) {
+ fFacetsDefined |= DatatypeValidator.FACET_LENGTH;
+ String lengthValue = (String)facets.get(key);
+ try {
+ fLength = Integer.parseInt( lengthValue );
+ }
+ catch (NumberFormatException nfe) {
+ throw new InvalidDatatypeFacetException("Length value '"+lengthValue+"' is invalid.");
+ }
+ // check 4.3.1.c0 must: length >= 0
+ if (fLength < 0)
+ throw new InvalidDatatypeFacetException("Length value '"+lengthValue+"' must be a nonNegativeInteger.");
- if ( base != null ) {
- // check 4.3.5.c0 must: enumeration values from the value space of base
- //REVISIT: we should try either to delay it till validate() or
- // store enumeration values in _value_space
- // otherwise we end up creating and throwing objects
- if ( (fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) != 0 &&
- (fEnumeration != null) ) {
- int i = 0;
- try {
- for ( ; i < fEnumeration.size(); i++ ) {
- ((AbstractStringValidator)base).checkContent ((String)fEnumeration.elementAt(i), null, false);
- }
- }
- catch ( Exception idve ) {
- throw new InvalidDatatypeFacetException( "Value of enumeration = '" + fEnumeration.elementAt(i) +
- "' must be from the value space of base.");
}
- }
- }
+ else if (key.equals(SchemaSymbols.ELT_MINLENGTH)) {
+ fFacetsDefined |= DatatypeValidator.FACET_MINLENGTH;
+ String minLengthValue = (String)facets.get(key);
+ try {
+ fMinLength = Integer.parseInt( minLengthValue );
+ }
+ catch (NumberFormatException nfe) {
+ throw new InvalidDatatypeFacetException("minLength value '"+minLengthValue+"' is invalid.");
+ }
+ // check 4.3.2.c0 must: minLength >= 0
+ if (fMinLength < 0)
+ throw new InvalidDatatypeFacetException("minLength value '"+minLengthValue+"' must be a nonNegativeInteger.");
- // check 4.3.1.c1 error: length & (maxLength | minLength)
- if ( ((fFacetsDefined & DatatypeValidator.FACET_LENGTH ) != 0 ) ) {
- if ( ((fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH ) != 0 ) ) {
- throw new InvalidDatatypeFacetException("It is an error for both length and maxLength to be members of facets." );
- }
- else if ( ((fFacetsDefined & DatatypeValidator.FACET_MINLENGTH ) != 0 ) ) {
- throw new InvalidDatatypeFacetException("It is an error for both length and minLength to be members of facets." );
+ }
+ else if (key.equals(SchemaSymbols.ELT_MAXLENGTH)) {
+ fFacetsDefined |= DatatypeValidator.FACET_MAXLENGTH;
+ String maxLengthValue = (String)facets.get(key);
+ try {
+ fMaxLength = Integer.parseInt( maxLengthValue );
+ }
+ catch (NumberFormatException nfe) {
+ throw new InvalidDatatypeFacetException("maxLength value '"+maxLengthValue+"' is invalid.");
+ }
+ // check 4.3.3.c0 must: maxLength >= 0
+ if (fMaxLength < 0)
+ throw new InvalidDatatypeFacetException("maxLength value '"+maxLengthValue+"' must be a nonNegativeInteger.");
+ }
+ else if (key.equals(SchemaSymbols.ELT_PATTERN)) {
+ fFacetsDefined |= DatatypeValidator.FACET_PATTERN;
+ fPattern = (String)facets.get(key);
+ if (fPattern != null)
+ fRegex = new RegularExpression(fPattern, "X");
+ }
+ else if (key.equals(SchemaSymbols.ELT_ENUMERATION)) {
+ fEnumeration = (Vector)facets.get(key);
+ fFacetsDefined |= DatatypeValidator.FACET_ENUMERATION;
+ }
+ else if (key.equals(DatatypeValidator.FACET_FIXED)) {// fixed flags
+ fFlags = ((Short)facets.get(key)).shortValue();
+ }
+ else if (key == FACET_SPECIAL_TOKEN) {// special token parser
+ setTokenType((String)facets.get(key));
+ }
+ else {
+ assignAdditionalFacets(key, facets);
+ }
}
- }
- // check 4.3.2.c1 must: minLength <= maxLength
- if ( ( (fFacetsDefined & ( DatatypeValidator.FACET_MINLENGTH |
- DatatypeValidator.FACET_MAXLENGTH) ) != 0 ) ) {
- if ( fMinLength > fMaxLength ) {
- throw new InvalidDatatypeFacetException( "Value of minLength = '" + fMinLength +
- "'must be <= the value of maxLength = '" + fMaxLength + "'.");
+ if (base != null) {
+ // check 4.3.5.c0 must: enumeration values from the value space of base
+ //REVISIT: we should try either to delay it till validate() or
+ // store enumeration values in _value_space
+ // otherwise we end up creating and throwing objects
+ if ((fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) != 0 &&
+ (fEnumeration != null)) {
+ int i = 0;
+ try {
+ for (; i < fEnumeration.size(); i++) {
+ ((AbstractStringValidator)base).checkContent ((String)fEnumeration.elementAt(i), null, false);
+ }
+ }
+ catch (Exception idve) {
+ throw new InvalidDatatypeFacetException( "Value of enumeration = '" + fEnumeration.elementAt(i) +
+ "' must be from the value space of base.");
+ }
+ }
}
- }
- // if base type is string, check facets against base.facets, and inherit facets from base
- if ( base != null ) {
- AbstractStringValidator strBase = (AbstractStringValidator)base;
-
- // check 4.3.1.c1 error: length & (base.maxLength | base.minLength)
- if ( ((fFacetsDefined & DatatypeValidator.FACET_LENGTH ) != 0 ) ) {
- if ( ((strBase.fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH ) != 0 ) ) {
+ // check 4.3.1.c1 error: length & (maxLength | minLength)
+ if (((fFacetsDefined & DatatypeValidator.FACET_LENGTH ) != 0 )) {
+ if (((fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH ) != 0 )) {
throw new InvalidDatatypeFacetException("It is an error for both length and maxLength to be members of facets." );
}
- else if ( ((strBase.fFacetsDefined & DatatypeValidator.FACET_MINLENGTH ) != 0 ) ) {
+ else if (((fFacetsDefined & DatatypeValidator.FACET_MINLENGTH ) != 0 )) {
throw new InvalidDatatypeFacetException("It is an error for both length and minLength to be members of facets." );
}
- else if ( (strBase.fFacetsDefined & DatatypeValidator.FACET_LENGTH) != 0 ) {
- // check 4.3.1.c2 error: length != base.length
- if ( fLength != strBase.fLength )
- throw new InvalidDatatypeFacetException( "Value of length = '" + fLength +
- "' must be = the value of base.length = '" + strBase.fLength + "'.");
- }
}
- // check 4.3.1.c1 error: base.length & (maxLength | minLength)
- if ( ((strBase.fFacetsDefined & DatatypeValidator.FACET_LENGTH ) != 0 ) ) {
- if ( ((fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH ) != 0 ) ) {
- throw new InvalidDatatypeFacetException("It is an error for both length and maxLength to be members of facets." );
- }
- else if ( ((fFacetsDefined & DatatypeValidator.FACET_MINLENGTH ) != 0 ) ) {
- throw new InvalidDatatypeFacetException("It is an error for both length and minLength to be members of facets." );
+ // check 4.3.2.c1 must: minLength <= maxLength
+ if (( (fFacetsDefined & ( DatatypeValidator.FACET_MINLENGTH |
+ DatatypeValidator.FACET_MAXLENGTH) ) != 0 )) {
+ if (fMinLength > fMaxLength) {
+ throw new InvalidDatatypeFacetException( "Value of minLength = '" + fMinLength +
+ "'must be <= the value of maxLength = '" + fMaxLength + "'.");
}
}
- // check 4.3.2.c1 must: minLength <= base.maxLength
- if ( ((fFacetsDefined & DatatypeValidator.FACET_MINLENGTH ) != 0 ) ) {
- if ( (strBase.fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH ) != 0 ) {
- if ( fMinLength > strBase.fMaxLength ) {
- throw new InvalidDatatypeFacetException( "Value of minLength = '" + fMinLength +
- "'must be <= the value of maxLength = '" + fMaxLength + "'.");
+ // if base type is string, check facets against base.facets, and inherit facets from base
+ if (base != null) {
+ AbstractStringValidator strBase = (AbstractStringValidator)base;
+
+ // check 4.3.1.c1 error: length & (base.maxLength | base.minLength)
+ if (((fFacetsDefined & DatatypeValidator.FACET_LENGTH ) != 0 )) {
+ if (((strBase.fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH ) != 0 )) {
+ throw new InvalidDatatypeFacetException("It is an error for both length and maxLength to be members of facets." );
}
- }
- else if ( (strBase.fFacetsDefined & DatatypeValidator.FACET_MINLENGTH) != 0 ) {
- if ( (strBase.fFlags & DatatypeValidator.FACET_MINLENGTH) != 0 &&
- fMinLength != strBase.fMinLength ) {
- throw new InvalidDatatypeFacetException( "minLength value = '" + fMinLength +
- "' must be equal to base.minLength value = '" +
- strBase.fMinLength + "' with attribute {fixed} = true" );
+ else if (((strBase.fFacetsDefined & DatatypeValidator.FACET_MINLENGTH ) != 0 )) {
+ throw new InvalidDatatypeFacetException("It is an error for both length and minLength to be members of facets." );
}
- // check 4.3.2.c2 error: minLength < base.minLength
- if ( fMinLength < strBase.fMinLength ) {
- throw new InvalidDatatypeFacetException( "Value of minLength = '" + fMinLength +
- "' must be >= the value of base.minLength = '" + strBase.fMinLength + "'.");
+ else if ((strBase.fFacetsDefined & DatatypeValidator.FACET_LENGTH) != 0) {
+ // check 4.3.1.c2 error: length != base.length
+ if (fLength != strBase.fLength)
+ throw new InvalidDatatypeFacetException( "Value of length = '" + fLength +
+ "' must be = the value of base.length = '" + strBase.fLength + "'.");
}
}
- }
+ // check 4.3.1.c1 error: base.length & (maxLength | minLength)
+ if (((strBase.fFacetsDefined & DatatypeValidator.FACET_LENGTH ) != 0 )) {
+ if (((fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH ) != 0 )) {
+ throw new InvalidDatatypeFacetException("It is an error for both length and maxLength to be members of facets." );
+ }
+ else if (((fFacetsDefined & DatatypeValidator.FACET_MINLENGTH ) != 0 )) {
+ throw new InvalidDatatypeFacetException("It is an error for both length and minLength to be members of facets." );
+ }
+ }
- // check 4.3.2.c1 must: base.minLength <= maxLength
- if ( ((strBase.fFacetsDefined & DatatypeValidator.FACET_MINLENGTH ) != 0 ) &&
- ((fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH ) != 0 ) ) {
- if ( strBase.fMinLength > fMaxLength ) {
- throw new InvalidDatatypeFacetException( "Value of minLength = '" + fMinLength +
- "'must be <= the value of maxLength = '" + fMaxLength + "'.");
+ // check 4.3.2.c1 must: minLength <= base.maxLength
+ if (((fFacetsDefined & DatatypeValidator.FACET_MINLENGTH ) != 0 )) {
+ if ((strBase.fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH ) != 0) {
+ if (fMinLength > strBase.fMaxLength) {
+ throw new InvalidDatatypeFacetException( "Value of minLength = '" + fMinLength +
+ "'must be <= the value of maxLength = '" + fMaxLength + "'.");
+ }
+ }
+ else if ((strBase.fFacetsDefined & DatatypeValidator.FACET_MINLENGTH) != 0) {
+ if ((strBase.fFlags & DatatypeValidator.FACET_MINLENGTH) != 0 &&
+ fMinLength != strBase.fMinLength) {
+ throw new InvalidDatatypeFacetException( "minLength value = '" + fMinLength +
+ "' must be equal to base.minLength value = '" +
+ strBase.fMinLength + "' with attribute {fixed} = true" );
+ }
+ // check 4.3.2.c2 error: minLength < base.minLength
+ if (fMinLength < strBase.fMinLength) {
+ throw new InvalidDatatypeFacetException( "Value of minLength = '" + fMinLength +
+ "' must be >= the value of base.minLength = '" + strBase.fMinLength + "'.");
+ }
+ }
}
- }
+
- // check 4.3.3.c1 error: maxLength > base.maxLength
- if ( (fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH) != 0 ) {
- if ( (strBase.fFlags & DatatypeValidator.FACET_MAXLENGTH) != 0 &&
- fMaxLength != strBase.fMaxLength ) {
- throw new InvalidDatatypeFacetException( "maxLength value = '" + fMaxLength +
- "' must be equal to base.maxLength value = '" +
- strBase.fMaxLength + "' with attribute {fixed} = true" );
+ // check 4.3.2.c1 must: base.minLength <= maxLength
+ if (((strBase.fFacetsDefined & DatatypeValidator.FACET_MINLENGTH ) != 0 ) &&
+ ((fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH ) != 0 )) {
+ if (strBase.fMinLength > fMaxLength) {
+ throw new InvalidDatatypeFacetException( "Value of minLength = '" + fMinLength +
+ "'must be <= the value of maxLength = '" + fMaxLength + "'.");
+ }
}
- if ( (strBase.fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH) != 0 ) {
- if ( fMaxLength > strBase.fMaxLength ) {
+
+ // check 4.3.3.c1 error: maxLength > base.maxLength
+ if ((fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH) != 0) {
+ if ((strBase.fFlags & DatatypeValidator.FACET_MAXLENGTH) != 0 &&
+ fMaxLength != strBase.fMaxLength) {
+ throw new InvalidDatatypeFacetException( "maxLength value = '" + fMaxLength +
+ "' must be equal to base.maxLength value = '" +
+ strBase.fMaxLength + "' with attribute {fixed} = true" );
+ }
+ if ((strBase.fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH) != 0) {
+ if (fMaxLength > strBase.fMaxLength) {
- throw new InvalidDatatypeFacetException( "Value of maxLength = '" + fMaxLength +
- "' must be <= the value of base.maxLength = '" + strBase.fMaxLength + "'.");
+ throw new InvalidDatatypeFacetException( "Value of maxLength = '" + fMaxLength +
+ "' must be <= the value of base.maxLength = '" + strBase.fMaxLength + "'.");
+ }
}
}
- }
- checkBaseFacetConstraints();
+ checkBaseFacetConstraints();
- // inherit length
- if ( (strBase.fFacetsDefined & DatatypeValidator.FACET_LENGTH) != 0 ) {
- if ( (fFacetsDefined & DatatypeValidator.FACET_LENGTH) == 0 ) {
- fFacetsDefined |= DatatypeValidator.FACET_LENGTH;
- fLength = strBase.fLength;
+ // inherit length
+ if ((strBase.fFacetsDefined & DatatypeValidator.FACET_LENGTH) != 0) {
+ if ((fFacetsDefined & DatatypeValidator.FACET_LENGTH) == 0) {
+ fFacetsDefined |= DatatypeValidator.FACET_LENGTH;
+ fLength = strBase.fLength;
+ }
}
- }
- // inherit minLength
- if ( (strBase.fFacetsDefined & DatatypeValidator.FACET_MINLENGTH) != 0 ) {
- if ( (fFacetsDefined & DatatypeValidator.FACET_MINLENGTH) == 0 ) {
- fFacetsDefined |= DatatypeValidator.FACET_MINLENGTH;
- fMinLength = strBase.fMinLength;
+ // inherit minLength
+ if ((strBase.fFacetsDefined & DatatypeValidator.FACET_MINLENGTH) != 0) {
+ if ((fFacetsDefined & DatatypeValidator.FACET_MINLENGTH) == 0) {
+ fFacetsDefined |= DatatypeValidator.FACET_MINLENGTH;
+ fMinLength = strBase.fMinLength;
+ }
}
- }
- // inherit maxLength
- if ( (strBase.fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH) != 0 ) {
- if ( (fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH) == 0 ) {
- fFacetsDefined |= DatatypeValidator.FACET_MAXLENGTH;
- fMaxLength = strBase.fMaxLength;
+ // inherit maxLength
+ if ((strBase.fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH) != 0) {
+ if ((fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH) == 0) {
+ fFacetsDefined |= DatatypeValidator.FACET_MAXLENGTH;
+ fMaxLength = strBase.fMaxLength;
+ }
}
- }
- // inherit enumeration
- if ( (fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) == 0 &&
- (strBase.fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) != 0 ) {
- fFacetsDefined |= DatatypeValidator.FACET_ENUMERATION;
- fEnumeration = strBase.fEnumeration;
+ // inherit enumeration
+ if ((fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) == 0 &&
+ (strBase.fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) != 0) {
+ fFacetsDefined |= DatatypeValidator.FACET_ENUMERATION;
+ fEnumeration = strBase.fEnumeration;
+ }
+ inheritAdditionalFacets();
+
+ //inherit fixed values
+ fFlags |= strBase.fFlags;
}
- inheritAdditionalFacets();
+ }// End of Facets Setting
+ }
+ catch (Exception e) {
- //inherit fixed values
- fFlags |= strBase.fFlags;
+ if (fErrorReporter == null) {
+ throw new RuntimeException("InternalDatatype error ASV.");
}
- }// End of Facets Setting
+ fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
+ "DatatypeFacetError", new Object [] { ((Exception)e).getMessage()},
+ XMLErrorReporter.SEVERITY_ERROR);
+ }
}
//
@@ -373,14 +389,14 @@
private void checkContent( String content, Object state, boolean asBase )
throws InvalidDatatypeValueException {
// validate against parent type if any
- if ( fBaseValidator instanceof AbstractStringValidator ) {
+ if (fBaseValidator instanceof AbstractStringValidator) {
// validate content as a base type
((AbstractStringValidator)fBaseValidator).checkContent(content, state, true);
}
// we check pattern first
- if ( (fFacetsDefined & DatatypeValidator.FACET_PATTERN ) != 0 ) {
- if ( fRegex == null || fRegex.matches( content) == false )
+ if ((fFacetsDefined & DatatypeValidator.FACET_PATTERN ) != 0) {
+ if (fRegex == null || fRegex.matches( content) == false)
throw new InvalidDatatypeValueException("Value '"+content+
"' does not match regular expression facet '" + fPattern + "'." );
}
@@ -392,38 +408,38 @@
// if this is a base validator, we only need to check pattern facet
// all other facet were inherited by the derived type
- if ( asBase )
+ if (asBase)
return;
checkValueSpace (content);
int length = getLength(content);
- if ( (fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH) != 0 ) {
- if ( length > fMaxLength ) {
+ if ((fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH) != 0) {
+ if (length > fMaxLength) {
throw new InvalidDatatypeValueException("Value '"+content+
"' with length '"+length+
"' exceeds maximum length facet of '"+fMaxLength+"'.");
}
}
- if ( (fFacetsDefined & DatatypeValidator.FACET_MINLENGTH) != 0 ) {
- if ( length < fMinLength ) {
+ if ((fFacetsDefined & DatatypeValidator.FACET_MINLENGTH) != 0) {
+ if (length < fMinLength) {
throw new InvalidDatatypeValueException("Value '"+content+
"' with length '"+length+
"' is less than minimum length facet of '"+fMinLength+"'." );
}
}
- if ( (fFacetsDefined & DatatypeValidator.FACET_LENGTH) != 0 ) {
- if ( length != fLength ) {
+ if ((fFacetsDefined & DatatypeValidator.FACET_LENGTH) != 0) {
+ if (length != fLength) {
throw new InvalidDatatypeValueException("Value '"+content+
"' with length '"+length+
"' is not equal to length facet '"+fLength+"'.");
}
}
- if ( (fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) != 0 &&
- (fEnumeration != null) ) {
- if ( fEnumeration.contains( content ) == false )
+ if ((fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) != 0 &&
+ (fEnumeration != null)) {
+ if (fEnumeration.contains( content ) == false)
throw new InvalidDatatypeValueException("Value '"+content+"' must be one of "+fEnumeration);
}
}
@@ -452,7 +468,7 @@
int len;
if (content == null || (len = content.length()) == 0) {
throw new InvalidDatatypeValueException(
- "The length of the content must be greater than 0");
+ "The length of the content must be greater than 0");
}
boolean seenErr = false;
if (tokenType == SPECIAL_TOKEN_NMTOKEN) {
@@ -460,21 +476,22 @@
seenErr = !XMLChar.isValidNmtoken(content);
}
else if (tokenType == SPECIAL_TOKEN_NAME ||
- tokenType == SPECIAL_TOKEN_IDNAME ||
- tokenType == SPECIAL_TOKEN_IDREFNAME) {
+ tokenType == SPECIAL_TOKEN_IDNAME ||
+ tokenType == SPECIAL_TOKEN_IDREFNAME) {
// PATTERN "\\i\\c*"
seenErr = !XMLChar.isValidName(content);
- } else if (tokenType == SPECIAL_TOKEN_NCNAME ||
- tokenType == SPECIAL_TOKEN_IDNCNAME ||
- tokenType == SPECIAL_TOKEN_IDREFNCNAME ||
- tokenType == SPECIAL_TOKEN_ENTITY) {
+ }
+ else if (tokenType == SPECIAL_TOKEN_NCNAME ||
+ tokenType == SPECIAL_TOKEN_IDNCNAME ||
+ tokenType == SPECIAL_TOKEN_IDREFNCNAME ||
+ tokenType == SPECIAL_TOKEN_ENTITY) {
// PATTERN "[\\i-[:]][\\c-[:]]*"
// REVISIT: !!!NOT IMPLEMENTED in XMLChar
seenErr = !XMLChar.isValidNCName(content);
}
if (seenErr) {
throw new InvalidDatatypeValueException(
- "Value '"+content+"' is not a valid " + tokenType);
+ "Value '"+content+"' is not a valid " + tokenType);
}
}
}
1.2 +20 -10 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/AnySimpleType.java
Index: AnySimpleType.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/AnySimpleType.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AnySimpleType.java 2001/08/24 22:26:29 1.1
+++ AnySimpleType.java 2001/10/11 15:13:33 1.2
@@ -59,31 +59,41 @@
import java.util.Hashtable;
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
+
/**
* AnySimpleType is the base of all simple types.
* @author Sandy Gao
- * @version $Id: AnySimpleType.java,v 1.1 2001/08/24 22:26:29 elena Exp $
+ * @version $Id: AnySimpleType.java,v 1.2 2001/10/11 15:13:33 elena Exp $
*/
public class AnySimpleType extends AbstractDatatypeValidator {
- public AnySimpleType() throws InvalidDatatypeFacetException{
+ public AnySimpleType() {
}
- public AnySimpleType(DatatypeValidator base, Hashtable facets, boolean derivedByList)
- throws InvalidDatatypeFacetException {
+ public AnySimpleType(DatatypeValidator base, Hashtable facets, boolean derivedByList,
+ XMLErrorReporter reporter) {
fBaseValidator = base;
+ fErrorReporter = reporter;
if (facets != null && facets.size() != 0) {
String msg = getErrorString(
- DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.ILLEGAL_ANYSIMPLETYPE_FACET],
- new Object[] { facets.toString() });
- throw new InvalidDatatypeFacetException(msg);
-
+ DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.ILLEGAL_ANYSIMPLETYPE_FACET],
+ new Object[] { facets.toString()});
+
+ if (fErrorReporter == null) {
+ throw new RuntimeException("InternalDatatype error AST.");
+ }
+ fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
+ "DatatypeFacetError", new Object[]{msg},
+ XMLErrorReporter.SEVERITY_ERROR);
+
}
}
public Object validate(String content, Object state )
- throws InvalidDatatypeValueException {
+ throws InvalidDatatypeValueException {
return null;
}
@@ -96,7 +106,7 @@
throw new CloneNotSupportedException("clone() is not supported in "+this.getClass().getName());
}
- public short getWSFacet (){
+ public short getWSFacet () {
return DatatypeValidator.PRESERVE;
}
}
1.2 +7 -5 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/AnyURIDatatypeValidator.java
Index: AnyURIDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/AnyURIDatatypeValidator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AnyURIDatatypeValidator.java 2001/08/24 22:26:29 1.1
+++ AnyURIDatatypeValidator.java 2001/10/11 15:13:33 1.2
@@ -60,6 +60,8 @@
import java.util.Hashtable;
import org.apache.xerces.util.URI;
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
/**
* URIValidator validates that XML content is a W3C uri type,
@@ -70,18 +72,18 @@
* @author Mark Swinkles - List Validation refactoring
* @see RFC 2396
* @see Tim Berners-Lee, et. al. RFC 2396: Uniform Resource Identifiers (URI): Generic Syntax.. 1998 Available at: http://www.ietf.org/rfc/rfc2396.txt
- * @version $Id: AnyURIDatatypeValidator.java,v 1.1 2001/08/24 22:26:29 elena Exp $
+ * @version $Id: AnyURIDatatypeValidator.java,v 1.2 2001/10/11 15:13:33 elena Exp $
*/
public class AnyURIDatatypeValidator extends AbstractStringValidator {
private URI fTempURI = null;
- public AnyURIDatatypeValidator () throws InvalidDatatypeFacetException{
- super ( null, null, false ); // Native, No Facets defined, Restriction
+ public AnyURIDatatypeValidator () {
+ super ( null, null, false, null ); // Native, No Facets defined, Restriction
}
public AnyURIDatatypeValidator ( DatatypeValidator base, Hashtable facets,
- boolean derivedByList ) throws InvalidDatatypeFacetException {
- super (base, facets, derivedByList);
+ boolean derivedByList, XMLErrorReporter reporter) {
+ super (base, facets, derivedByList, reporter);
}
protected void assignAdditionalFacets(String key, Hashtable facets) throws InvalidDatatypeFacetException{
1.3 +7 -5 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/Base64BinaryDatatypeValidator.java
Index: Base64BinaryDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/Base64BinaryDatatypeValidator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Base64BinaryDatatypeValidator.java 2001/09/19 18:16:07 1.2
+++ Base64BinaryDatatypeValidator.java 2001/10/11 15:13:33 1.3
@@ -65,27 +65,29 @@
import org.apache.xerces.impl.v2.util.regex.RegularExpression;
import org.apache.xerces.impl.v2.util.Base64;
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
/**
* Base64BinaryValidator validates that XML content is a W3C string type.
* @author Ted Leung
* @author Kito D. Mann, Virtua Communications Corp.
* @author Jeffrey Rodriguez
* @author Mark Swinkles - List Validation refactoring
- * @version $Id: Base64BinaryDatatypeValidator.java,v 1.2 2001/09/19 18:16:07 neilg Exp $
+ * @version $Id: Base64BinaryDatatypeValidator.java,v 1.3 2001/10/11 15:13:33 elena Exp $
*/
public class Base64BinaryDatatypeValidator extends AbstractStringValidator{
- public Base64BinaryDatatypeValidator () throws InvalidDatatypeFacetException{
- super( null, null, false ); // Native, No Facets defined, Restriction
+ public Base64BinaryDatatypeValidator () {
+ super( null, null, false , null); // Native, No Facets defined, Restriction
}
public Base64BinaryDatatypeValidator ( DatatypeValidator base, Hashtable facets,
- boolean derivedByList ) throws InvalidDatatypeFacetException {
+ boolean derivedByList, XMLErrorReporter reporter) {
- super (base, facets, derivedByList);
+ super (base, facets, derivedByList, reporter);
}
protected void assignAdditionalFacets(String key, Hashtable facets) throws InvalidDatatypeFacetException{
1.4 +38 -27 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/BooleanDatatypeValidator.java
Index: BooleanDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/BooleanDatatypeValidator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BooleanDatatypeValidator.java 2001/10/04 19:57:48 1.3
+++ BooleanDatatypeValidator.java 2001/10/11 15:13:33 1.4
@@ -62,6 +62,9 @@
import org.apache.xerces.impl.v2.SchemaSymbols;
import org.apache.xerces.impl.v2.util.regex.RegularExpression;
import org.apache.xerces.impl.v2.SchemaSymbols;
+
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
/**
*
* BooleanValidator validates that content satisfies the W3C XML Datatype for Boolean
@@ -69,40 +72,48 @@
* @author Ted Leung
* @author Jeffrey Rodriguez
* @author Mark Swinkles - List Validation refactoring
- * @version $Id: BooleanDatatypeValidator.java,v 1.3 2001/10/04 19:57:48 elena Exp $
+ * @version $Id: BooleanDatatypeValidator.java,v 1.4 2001/10/11 15:13:33 elena Exp $
*/
public class BooleanDatatypeValidator extends AbstractDatatypeValidator {
-
+
private static final String fValueSpace[] = { "false", "true", "0", "1"};
- public BooleanDatatypeValidator () throws InvalidDatatypeFacetException {
- this( null, null, false ); // Native, No Facets defined, Restriction
+ public BooleanDatatypeValidator () {
+ this( null, null, false, null ); // Native, No Facets defined, Restriction
}
public BooleanDatatypeValidator ( DatatypeValidator base, Hashtable facets,
- boolean derivedByList ) throws InvalidDatatypeFacetException {
+ boolean derivedByList, XMLErrorReporter reporter) {
+ fErrorReporter = reporter;
fBaseValidator = base; // Set base type
// list types are handled by ListDatatypeValidator, we do nothing here.
- if ( derivedByList )
+ if (derivedByList)
return;
// Set Facets if any defined
- if ( facets != null ) {
+ if (facets != null) {
for (Enumeration e = facets.keys(); e.hasMoreElements();) {
String key = (String) e.nextElement();
if (key.equals(SchemaSymbols.ELT_PATTERN)) {
fFacetsDefined |= DatatypeValidator.FACET_PATTERN;
fPattern = (String)facets.get(key);
- if( fPattern != null )
- fRegex = new RegularExpression(fPattern, "X" );
- } else {
+ if (fPattern != null)
+ fRegex = new RegularExpression(fPattern, "X" );
+ }
+ else {
String msg = getErrorString(
- DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.ILLEGAL_BOOLEAN_FACET],
- new Object[] { key });
- throw new InvalidDatatypeFacetException(msg);
+ DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.ILLEGAL_BOOLEAN_FACET],
+ new Object[] { key});
+
+ if (fErrorReporter == null) {
+ throw new RuntimeException("InternalDatatype error BDV.");
+ }
+ fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
+ "DatatypeFacetError", new Object [] { msg},
+ XMLErrorReporter.SEVERITY_ERROR);
}
}
}// End of facet setting
@@ -129,14 +140,14 @@
* @param content2
* @return 0 if equal, 1 if not equal
*/
- public int compare( String content1, String content2){
+ public int compare( String content1, String content2) {
if (content1.equals(content2)) {
return 0;
}
Boolean b1 = Boolean.valueOf(content1);
Boolean b2 = Boolean.valueOf(content2);
- return (b1.equals(b2))?0:1;
+ return(b1.equals(b2))?0:1;
}
/**
@@ -145,15 +156,15 @@
* @return Hashtable
*/
- public Hashtable getFacets(){
+ public Hashtable getFacets() {
return null;
}
//Begin private method definitions
- /**
- * Returns a copy of this object.
- */
+ /**
+ * Returns a copy of this object.
+ */
public Object clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException("clone() is not supported in "+this.getClass().getName());
}
@@ -169,14 +180,14 @@
throws InvalidDatatypeValueException {
// validate against parent type if any
// REVISIT: fast fix to avoid class cast exception
- if ( this.fBaseValidator != null && !(fBaseValidator instanceof AnySimpleType)) {
+ if (this.fBaseValidator != null && !(fBaseValidator instanceof AnySimpleType)) {
// validate content as a base type
- ((BooleanDatatypeValidator)fBaseValidator).checkContent(content, true);
+ ((BooleanDatatypeValidator)fBaseValidator).checkContent(content, true);
}
// we check pattern first
- if ( (fFacetsDefined & DatatypeValidator.FACET_PATTERN ) != 0 ) {
- if ( fRegex == null || fRegex.matches( content) == false )
+ if ((fFacetsDefined & DatatypeValidator.FACET_PATTERN ) != 0) {
+ if (fRegex == null || fRegex.matches( content) == false)
throw new InvalidDatatypeValueException("Value'"+content+
"does not match regular expression facet" + fPattern );
}
@@ -187,14 +198,14 @@
return;
boolean isContentInDomain = false;
- for ( int i = 0;i<fValueSpace.length;i++ ) {
- if ( content.equals(fValueSpace[i] ) )
+ for (int i = 0;i<fValueSpace.length;i++) {
+ if (content.equals(fValueSpace[i] ))
isContentInDomain = true;
}
if (isContentInDomain == false) {
String msg = getErrorString(
- DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.NOT_BOOLEAN],
- new Object[] { content });
+ DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.NOT_BOOLEAN],
+ new Object[] { content});
throw new InvalidDatatypeValueException(msg);
}
}
1.2 +15 -20 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/DatatypeValidatorFactoryImpl.java
Index: DatatypeValidatorFactoryImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/DatatypeValidatorFactoryImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DatatypeValidatorFactoryImpl.java 2001/08/24 22:26:29 1.1
+++ DatatypeValidatorFactoryImpl.java 2001/10/11 15:13:33 1.2
@@ -89,7 +89,7 @@
* @author Elena Litani
* @author Jeffrey Rodriguez
* @author Mark Swinkles - List Validation refactoring
- * @version $Id: DatatypeValidatorFactoryImpl.java,v 1.1 2001/08/24 22:26:29 elena Exp $
+ * @version $Id: DatatypeValidatorFactoryImpl.java,v 1.2 2001/10/11 15:13:33 elena Exp $
*/
public class DatatypeValidatorFactoryImpl implements DatatypeValidatorFactory {
@@ -126,7 +126,6 @@
//Register Primitive Datatypes
if ( fRegistryExpanded == 0 ) { //Core datatypes shared by DTD attributes and Schema
- try {
fDTDDatatypeRegistry.put("string", new StringDatatypeValidator() );
fDTDDatatypeRegistry.put("ID", new IDDatatypeValidator());
fDTDDatatypeRegistry.put("IDREF", new IDREFDatatypeValidator());
@@ -148,12 +147,9 @@
createDTDDatatypeValidator("NMTOKENS", getDatatypeValidator( "NMTOKEN" ), null, true );
fRegistryExpanded = 1;
- }
- catch ( InvalidDatatypeFacetException ex ) {
- ex.printStackTrace();
- }
}
}
+
/**
@@ -166,7 +162,6 @@
//Register Primitive Datatypes
if ( fRegistryExpanded != 2 ) {
DatatypeValidator v;
- try {
//REVISIT: we want to create datatypes lazily
// esspecially for the types that are not often used
//
@@ -297,11 +292,8 @@
fRegistryExpanded = 2;
}
- catch ( InvalidDatatypeFacetException ex ) {
- ex.printStackTrace();
- }
- }
}
+
/**
* An optimization option that we should write in the future is to separate the static list
@@ -316,7 +308,7 @@
}
public DatatypeValidator createDatatypeValidator(String typeName,
- DatatypeValidator base, Hashtable facets, boolean list ) throws InvalidDatatypeFacetException {
+ DatatypeValidator base, Hashtable facets, boolean list ) {
if ( base == null ) {
return null;
}
@@ -364,25 +356,26 @@
private DatatypeValidator createSchemaDatatypeValidator(String typeName,
- DatatypeValidator base, Hashtable facets, boolean list ) throws InvalidDatatypeFacetException {
+ DatatypeValidator base, Hashtable facets, boolean list ) {
DatatypeValidator primitive = createSchemaValidator(typeName, base, facets, list);
registerSchemaValidator(typeName, primitive);
return primitive;
}
private DatatypeValidator createDTDDatatypeValidator(String typeName,
- DatatypeValidator base, Hashtable facets, boolean list ) throws InvalidDatatypeFacetException {
+ DatatypeValidator base, Hashtable facets, boolean list ) {
DatatypeValidator primitive = createSchemaValidator(typeName, base, facets, list);
registerDTDValidator(typeName, primitive);
return primitive;
}
private DatatypeValidator createSchemaValidator (String typeName,
- DatatypeValidator base, Hashtable facets, boolean list ) throws InvalidDatatypeFacetException{
+ DatatypeValidator base, Hashtable facets, boolean list ) {
DatatypeValidator simpleType = null;
if ( list ) {
- simpleType = new ListDatatypeValidator(base, facets, list);
+ // REVISIT: set error handler
+ simpleType = new ListDatatypeValidator(base, facets, list, null);
}
else {
try {
@@ -392,8 +385,9 @@
if ( value != null && !(base instanceof StringDatatypeValidator) ) {
if ( !value.equals(SchemaSymbols.ATTVAL_COLLAPSE) )
- throw new InvalidDatatypeFacetException( "whiteSpace value '" + value +
- "' for this type must be 'collapse'.");
+ // REVISIT report error
+ // "DatatypeFacetError", new Object [] { "whiteSpace value '" + value +
+ // "' for this type must be 'collapse'."},
facets.remove(SchemaSymbols.ELT_WHITESPACE);
}
@@ -435,7 +429,7 @@
private static Object createDatatypeValidator(Constructor validatorConstructor,
- Object[] arguments) throws InvalidDatatypeFacetException {
+ Object[] arguments) {
Object validator = null;
try {
validator = validatorConstructor.newInstance(arguments);
@@ -461,7 +455,8 @@
e.getTargetException().printStackTrace();
}
else {
- throw new InvalidDatatypeFacetException( e.getTargetException().getMessage() );
+ // report errro
+ //throw new InvalidDatatypeFacetException( e.getTargetException().getMessage() );
}
}
1.2 +6 -5 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/DateDatatypeValidator.java
Index: DateDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/DateDatatypeValidator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DateDatatypeValidator.java 2001/08/24 22:26:29 1.1
+++ DateDatatypeValidator.java 2001/10/11 15:13:33 1.2
@@ -59,23 +59,24 @@
package org.apache.xerces.impl.v2.datatypes;
import java.util.Hashtable;
-
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
/**
* Validator for <date> datatype (W3C Schema datatypes)
*
* @author Elena Litani
- * @version $Id: DateDatatypeValidator.java,v 1.1 2001/08/24 22:26:29 elena Exp $
+ * @version $Id: DateDatatypeValidator.java,v 1.2 2001/10/11 15:13:33 elena Exp $
*/
public class DateDatatypeValidator extends DateTimeValidator {
- public DateDatatypeValidator() throws InvalidDatatypeFacetException{
+ public DateDatatypeValidator() {
super();
}
public DateDatatypeValidator ( DatatypeValidator base, Hashtable facets,
- boolean derivedByList ) throws InvalidDatatypeFacetException {
- super (base, facets, derivedByList);
+ boolean derivedByList, XMLErrorReporter reporter) {
+ super (base, facets, derivedByList, reporter);
}
/**
1.2 +6 -4 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/DateTimeDatatypeValidator.java
Index: DateTimeDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/DateTimeDatatypeValidator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DateTimeDatatypeValidator.java 2001/08/24 22:26:29 1.1
+++ DateTimeDatatypeValidator.java 2001/10/11 15:13:33 1.2
@@ -58,24 +58,26 @@
package org.apache.xerces.impl.v2.datatypes;
import java.util.Hashtable;
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
/**
* Validator for <dateTime> datatype (W3C Schema Datatypes)
*
* @author Elena Litani
- * @version $Id: DateTimeDatatypeValidator.java,v 1.1 2001/08/24 22:26:29 elena Exp $
+ * @version $Id: DateTimeDatatypeValidator.java,v 1.2 2001/10/11 15:13:33 elena Exp $
*/
public class DateTimeDatatypeValidator extends DateTimeValidator {
- public DateTimeDatatypeValidator() throws InvalidDatatypeFacetException{
+ public DateTimeDatatypeValidator() {
super();
}
public DateTimeDatatypeValidator ( DatatypeValidator base, Hashtable facets,
- boolean derivedByList ) throws InvalidDatatypeFacetException {
- super (base, facets, derivedByList);
+ boolean derivedByList, XMLErrorReporter reporter) {
+ super (base, facets, derivedByList, reporter);
}
/**
1.4 +9 -7 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/DateTimeValidator.java
Index: DateTimeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/DateTimeValidator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DateTimeValidator.java 2001/10/08 17:07:44 1.3
+++ DateTimeValidator.java 2001/10/11 15:13:33 1.4
@@ -62,6 +62,8 @@
import java.util.Hashtable;
import org.apache.xerces.impl.v2.util.regex.RegularExpression;
import org.apache.xerces.impl.v2.SchemaSymbols;
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
/**
@@ -72,7 +74,7 @@
* @author Elena Litani
* @author Len Berman
*
- * @version $Id: DateTimeValidator.java,v 1.3 2001/10/08 17:07:44 elena Exp $
+ * @version $Id: DateTimeValidator.java,v 1.4 2001/10/11 15:13:33 elena Exp $
*/
public abstract class DateTimeValidator extends AbstractNumericFacetValidator {
@@ -134,14 +136,14 @@
//default constractor
- public DateTimeValidator () throws InvalidDatatypeFacetException {
- super( null, null, false ); // Native, No Facets defined, Restriction
+ public DateTimeValidator () {
+ super( null, null, false , null); // Native, No Facets defined, Restriction
}
- public DateTimeValidator (DatatypeValidator base, Hashtable facets, boolean derivedByList )
- throws InvalidDatatypeFacetException {
- super (base, facets, derivedByList);
+ public DateTimeValidator (DatatypeValidator base, Hashtable facets, boolean derivedByList, XMLErrorReporter reporter )
+ {
+ super (base, facets, derivedByList, reporter);
}
protected void initializeValues(){
@@ -683,7 +685,7 @@
}
//validate days
- if ( data[D]>maxDayInMonthFor(data[CY], data[M]) ) {
+ if ( data[D]>maxDayInMonthFor(data[CY], data[M]) || data[D]==0) {
throw new RuntimeException("The day must have values 1 to 31");
}
1.2 +6 -4 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/DayDatatypeValidator.java
Index: DayDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/DayDatatypeValidator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DayDatatypeValidator.java 2001/08/24 22:26:29 1.1
+++ DayDatatypeValidator.java 2001/10/11 15:13:33 1.2
@@ -59,12 +59,14 @@
package org.apache.xerces.impl.v2.datatypes;
import java.util.Hashtable;
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
/**
* Validator for <gDay> datatype (W3C Schema datatypes)
*
* @author Elena Litani
- * @version $Id: DayDatatypeValidator.java,v 1.1 2001/08/24 22:26:29 elena Exp $
+ * @version $Id: DayDatatypeValidator.java,v 1.2 2001/10/11 15:13:33 elena Exp $
*/
public class DayDatatypeValidator extends DateTimeValidator {
@@ -72,13 +74,13 @@
//size without time zone: ---09
private final static int DAY_SIZE=5;
- public DayDatatypeValidator() throws InvalidDatatypeFacetException{
+ public DayDatatypeValidator() {
super();
}
public DayDatatypeValidator ( DatatypeValidator base, Hashtable facets,
- boolean derivedByList ) throws InvalidDatatypeFacetException {
- super(base, facets, derivedByList);
+ boolean derivedByList, XMLErrorReporter reporter) {
+ super(base, facets, derivedByList, reporter);
}
/**
1.4 +7 -5 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/DecimalDatatypeValidator.java
Index: DecimalDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/DecimalDatatypeValidator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DecimalDatatypeValidator.java 2001/09/19 18:16:07 1.3
+++ DecimalDatatypeValidator.java 2001/10/11 15:13:33 1.4
@@ -64,6 +64,8 @@
import java.io.IOException;
import org.apache.xerces.impl.v2.SchemaSymbols;
import org.apache.xerces.impl.v2.util.regex.RegularExpression;
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
/**
*
@@ -73,7 +75,7 @@
* @author Ted Leung
* @author Jeffrey Rodriguez
* @author Mark Swinkles - List Validation refactoring
- * @version $Id: DecimalDatatypeValidator.java,v 1.3 2001/09/19 18:16:07 neilg Exp $
+ * @version $Id: DecimalDatatypeValidator.java,v 1.4 2001/10/11 15:13:33 elena Exp $
*/
public class DecimalDatatypeValidator extends AbstractNumericValidator {
@@ -81,13 +83,13 @@
protected int fTotalDigits;
protected int fFractionDigits;
- public DecimalDatatypeValidator () throws InvalidDatatypeFacetException {
- this( null, null, false ); // Native, No Facets defined, Restriction
+ public DecimalDatatypeValidator () {
+ this( null, null, false, null ); // Native, No Facets defined, Restriction
}
public DecimalDatatypeValidator ( DatatypeValidator base, Hashtable facets,
- boolean derivedByList ) throws InvalidDatatypeFacetException {
- super (base, facets, derivedByList);
+ boolean derivedByList, XMLErrorReporter reporter) {
+ super (base, facets, derivedByList, reporter);
}
public int compare( String value1, String value2) {
1.4 +7 -5 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/DoubleDatatypeValidator.java
Index: DoubleDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/DoubleDatatypeValidator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DoubleDatatypeValidator.java 2001/10/08 17:07:44 1.3
+++ DoubleDatatypeValidator.java 2001/10/11 15:13:33 1.4
@@ -62,24 +62,26 @@
import java.util.Vector;
import org.apache.xerces.impl.v2.SchemaSymbols;
import org.apache.xerces.impl.v2.util.regex.RegularExpression;
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
/**
* @author Elena Litani
* @author Ted Leung
* @author Jeffrey Rodriguez
* @author Mark Swinkles - List Validation refactoring
- * @version $Id: DoubleDatatypeValidator.java,v 1.3 2001/10/08 17:07:44 elena Exp $
+ * @version $Id: DoubleDatatypeValidator.java,v 1.4 2001/10/11 15:13:33 elena Exp $
*/
public class DoubleDatatypeValidator extends AbstractNumericValidator {
- public DoubleDatatypeValidator () throws InvalidDatatypeFacetException {
- this( null, null, false ); // Native, No Facets defined, Restriction
+ public DoubleDatatypeValidator () {
+ this( null, null, false, null ); // Native, No Facets defined, Restriction
}
public DoubleDatatypeValidator ( DatatypeValidator base, Hashtable facets,
- boolean derivedByList ) throws InvalidDatatypeFacetException {
- super(base, facets, derivedByList);
+ boolean derivedByList, XMLErrorReporter reporter) {
+ super(base, facets, derivedByList, reporter);
}
public int compare( String value1, String value2) {
1.2 +6 -4 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/DurationDatatypeValidator.java
Index: DurationDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/DurationDatatypeValidator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DurationDatatypeValidator.java 2001/08/24 22:26:29 1.1
+++ DurationDatatypeValidator.java 2001/10/11 15:13:33 1.2
@@ -58,12 +58,14 @@
package org.apache.xerces.impl.v2.datatypes;
import java.util.Hashtable;
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
/**
* Validator for <duration> datatype (W3C Schema Datatypes)
*
* @author Elena Litani
- * @version $Id: DurationDatatypeValidator.java,v 1.1 2001/08/24 22:26:29 elena Exp $
+ * @version $Id: DurationDatatypeValidator.java,v 1.2 2001/10/11 15:13:33 elena Exp $
*/
public class DurationDatatypeValidator extends DateTimeValidator {
@@ -83,13 +85,13 @@
private int[][] fDuration = null;
- public DurationDatatypeValidator() throws InvalidDatatypeFacetException{
+ public DurationDatatypeValidator() {
super();
}
public DurationDatatypeValidator ( DatatypeValidator base, Hashtable facets,
- boolean derivedByList ) throws InvalidDatatypeFacetException {
+ boolean derivedByList, XMLErrorReporter reporter) {
- super(base, facets, derivedByList);
+ super(base, facets, derivedByList, reporter);
}
1.4 +8 -5 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/FloatDatatypeValidator.java
Index: FloatDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/FloatDatatypeValidator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FloatDatatypeValidator.java 2001/10/08 17:07:44 1.3
+++ FloatDatatypeValidator.java 2001/10/11 15:13:33 1.4
@@ -65,25 +65,28 @@
import java.util.StringTokenizer;
import java.util.NoSuchElementException;
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
+
/**
*
* @author Elena Litani
* @author Ted Leung
* @author Jeffrey Rodriguez
* @author Mark Swinkles - List Validation refactoring
- * @version $Id: FloatDatatypeValidator.java,v 1.3 2001/10/08 17:07:44 elena Exp $
+ * @version $Id: FloatDatatypeValidator.java,v 1.4 2001/10/11 15:13:33 elena Exp $
*/
public class FloatDatatypeValidator extends AbstractNumericValidator {
- public FloatDatatypeValidator () throws InvalidDatatypeFacetException{
- this( null, null, false ); // Native, No Facets defined, Restriction
+ public FloatDatatypeValidator () {
+ this( null, null, false, null ); // Native, No Facets defined, Restriction
}
public FloatDatatypeValidator ( DatatypeValidator base, Hashtable facets,
- boolean derivedByList ) throws InvalidDatatypeFacetException {
+ boolean derivedByList, XMLErrorReporter reporter) {
// Set base type
- super (base, facets, derivedByList);
+ super (base, facets, derivedByList, reporter);
}
public int compare( String value1, String value2) {
1.3 +7 -9 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/HexBinaryDatatypeValidator.java
Index: HexBinaryDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/HexBinaryDatatypeValidator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HexBinaryDatatypeValidator.java 2001/09/19 18:16:07 1.2
+++ HexBinaryDatatypeValidator.java 2001/10/11 15:13:33 1.3
@@ -64,6 +64,8 @@
import org.apache.xerces.impl.v2.SchemaSymbols;
import org.apache.xerces.impl.v2.util.regex.RegularExpression;
import org.apache.xerces.impl.v2.util.HexBin;
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
/**
* HexBinaryValidator validates that XML content is a W3C string type.
@@ -71,20 +73,20 @@
* @author Kito D. Mann, Virtua Communications Corp.
* @author Jeffrey Rodriguez
* @author Mark Swinkles - List Validation refactoring
- * @version $Id: HexBinaryDatatypeValidator.java,v 1.2 2001/09/19 18:16:07 neilg Exp $
+ * @version $Id: HexBinaryDatatypeValidator.java,v 1.3 2001/10/11 15:13:33 elena Exp $
*/
public class HexBinaryDatatypeValidator extends AbstractStringValidator{
- public HexBinaryDatatypeValidator () throws InvalidDatatypeFacetException{
- super ( null, null, false ); // Native, No Facets defined, Restriction
+ public HexBinaryDatatypeValidator () {
+ super ( null, null, false, null ); // Native, No Facets defined, Restriction
}
public HexBinaryDatatypeValidator ( DatatypeValidator base, Hashtable facets,
- boolean derivedByList ) throws InvalidDatatypeFacetException {
+ boolean derivedByList, XMLErrorReporter reporter) {
- super (base, facets, derivedByList);
+ super (base, facets, derivedByList, reporter);
}
protected void assignAdditionalFacets(String key, Hashtable facets) throws InvalidDatatypeFacetException{
@@ -116,7 +118,6 @@
public Object clone() throws CloneNotSupportedException {
HexBinaryDatatypeValidator newObj = null;
- try {
newObj = new HexBinaryDatatypeValidator();
newObj.fLocale = fLocale;
@@ -128,9 +129,6 @@
newObj.fRegex = fRegex;
newObj.fEnumeration = fEnumeration;
newObj.fFacetsDefined = fFacetsDefined;
- } catch ( InvalidDatatypeFacetException ex) {
- ex.printStackTrace();
- }
return newObj;
}
1.4 +7 -5 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/IDDatatypeValidator.java
Index: IDDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/IDDatatypeValidator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- IDDatatypeValidator.java 2001/09/05 21:16:03 1.3
+++ IDDatatypeValidator.java 2001/10/11 15:13:33 1.4
@@ -63,6 +63,8 @@
import org.apache.xerces.util.XMLChar;
import org.apache.xerces.impl.v2.msg.XMLMessages;
import org.apache.xerces.impl.v2.SchemaSymbols;
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
/**
* DataTypeValidator defines the interface that data type validators must obey.
@@ -70,20 +72,20 @@
* standalone code as well as plugins to the validator architecture.
* @author Jeffrey Rodriguez
* @author Mark Swinkles - List Validation refactoring
- * @version $Id: IDDatatypeValidator.java,v 1.3 2001/09/05 21:16:03 sandygao Exp $
+ * @version $Id: IDDatatypeValidator.java,v 1.4 2001/10/11 15:13:33 elena Exp $
*/
public class IDDatatypeValidator extends StringDatatypeValidator {
private static Object fNullValue = new Object();
- public IDDatatypeValidator () throws InvalidDatatypeFacetException {
- this( null, null, false ); // Native, No Facets defined, Restriction
+ public IDDatatypeValidator () {
+ this( null, null, false, null ); // Native, No Facets defined, Restriction
}
public IDDatatypeValidator ( DatatypeValidator base, Hashtable facets,
- boolean derivedByList ) throws InvalidDatatypeFacetException {
+ boolean derivedByList, XMLErrorReporter reporter) {
// all facets are handled in StringDatatypeValidator
- super (base, facets, derivedByList);
+ super (base, facets, derivedByList, reporter);
// list types are handled by ListDatatypeValidator, we do nothing here.
if ( derivedByList )
1.5 +7 -5 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/IDREFDatatypeValidator.java
Index: IDREFDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/IDREFDatatypeValidator.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- IDREFDatatypeValidator.java 2001/09/21 16:22:30 1.4
+++ IDREFDatatypeValidator.java 2001/10/11 15:13:33 1.5
@@ -63,6 +63,8 @@
import org.apache.xerces.util.XMLChar;
import org.apache.xerces.impl.v2.msg.XMLMessages;
import org.apache.xerces.impl.v2.SchemaSymbols;
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
/**
* IDREFValidator defines the interface that data type validators must obey.
@@ -71,7 +73,7 @@
*
* @author Jeffrey Rodriguez-
* @author Mark Swinkles - List Validation refactoring
- * @version $Id: IDREFDatatypeValidator.java,v 1.4 2001/09/21 16:22:30 sandygao Exp $
+ * @version $Id: IDREFDatatypeValidator.java,v 1.5 2001/10/11 15:13:33 elena Exp $
*/
public class IDREFDatatypeValidator extends StringDatatypeValidator {
private static Object fNullValue = new Object();
@@ -79,15 +81,15 @@
public static final int IDREF_VALIDATE = 0;
public static final int IDREF_CHECKID = 1;
- public IDREFDatatypeValidator () throws InvalidDatatypeFacetException {
- this( null, null, false ); // Native, No Facets defined, Restriction
+ public IDREFDatatypeValidator () {
+ this( null, null, false, null ); // Native, No Facets defined, Restriction
}
public IDREFDatatypeValidator ( DatatypeValidator base, Hashtable facets,
- boolean derivedByList ) throws InvalidDatatypeFacetException {
+ boolean derivedByList, XMLErrorReporter reporter) {
// all facets are handled in StringDatatypeValidator
- super (base, facets, derivedByList);
+ super (base, facets, derivedByList, reporter);
// list types are handled by ListDatatypeValidator, we do nothing here.
if ( derivedByList )
1.3 +168 -147 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/ListDatatypeValidator.java
Index: ListDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/ListDatatypeValidator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ListDatatypeValidator.java 2001/09/19 18:16:07 1.2
+++ ListDatatypeValidator.java 2001/10/11 15:13:33 1.3
@@ -65,116 +65,134 @@
import org.apache.xerces.impl.v2.SchemaSymbols;
import org.apache.xerces.impl.v2.util.regex.RegularExpression;
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
/**
* StringValidator validates that XML content is a W3C string type.
* @author Elena Litani
* @author Jeffrey Rodriguez
* @author Mark Swinkles - List Validation refactoring
- * @version $Id: ListDatatypeValidator.java,v 1.2 2001/09/19 18:16:07 neilg Exp $
+ * @version $Id: ListDatatypeValidator.java,v 1.3 2001/10/11 15:13:33 elena Exp $
*/
-public class ListDatatypeValidator extends AbstractDatatypeValidator{
-
+public class ListDatatypeValidator extends AbstractDatatypeValidator {
+
private int fLength = 0;
private int fMaxLength = Integer.MAX_VALUE;
private int fMinLength = 0;
private Vector fEnumeration = null;
- public ListDatatypeValidator () throws InvalidDatatypeFacetException{
- this( null, null, false ); // Native, No Facets defined, Restriction
+ public ListDatatypeValidator () {
+ this( null, null, false, null ); // Native, No Facets defined, Restriction
}
public ListDatatypeValidator ( DatatypeValidator base, Hashtable facets,
- boolean derivedByList ) throws InvalidDatatypeFacetException {
-
+ boolean derivedByList, XMLErrorReporter reporter) {
+ fErrorReporter = reporter;
fBaseValidator = base; // Set base type
+ try {
- if ( facets != null ){
- for (Enumeration e = facets.keys(); e.hasMoreElements();) {
- String key = (String) e.nextElement();
- if ( key.equals(SchemaSymbols.ELT_LENGTH) ) {
- fFacetsDefined |= DatatypeValidator.FACET_LENGTH;
- String lengthValue = (String)facets.get(key);
- try {
- fLength = Integer.parseInt( lengthValue );
- } catch (NumberFormatException nfe) {
- throw new InvalidDatatypeFacetException("Length value '"+lengthValue+"' is invalid.");
- }
- if ( fLength < 0 )
- throw new InvalidDatatypeFacetException("Length value '"+lengthValue+"' must be a nonNegativeInteger.");
-
- }
- else if (key.equals(SchemaSymbols.ELT_MINLENGTH) ) {
- fFacetsDefined |= DatatypeValidator.FACET_MINLENGTH;
- String minLengthValue = (String)facets.get(key);
- try {
- fMinLength = Integer.parseInt( minLengthValue );
- } catch (NumberFormatException nfe) {
- throw new InvalidDatatypeFacetException("maxLength value '"+minLengthValue+"' is invalid.");
- }
- }
- else if (key.equals(SchemaSymbols.ELT_MAXLENGTH) ) {
- fFacetsDefined |= DatatypeValidator.FACET_MAXLENGTH;
- String maxLengthValue = (String)facets.get(key);
- try {
- fMaxLength = Integer.parseInt( maxLengthValue );
- } catch (NumberFormatException nfe) {
- throw new InvalidDatatypeFacetException("maxLength value '"+maxLengthValue+"' is invalid.");
- }
- }
- else if (key.equals(SchemaSymbols.ELT_ENUMERATION)) {
- fFacetsDefined |= DatatypeValidator.FACET_ENUMERATION;
- fEnumeration = (Vector)facets.get(key);
- }
- else if ( key.equals(SchemaSymbols.ELT_PATTERN) ) {
- fFacetsDefined |= DatatypeValidator.FACET_PATTERN;
- fPattern = (String)facets.get(key);
- if ( fPattern != null )
- fRegex = new RegularExpression(fPattern, "X");
- }
- else {
- String msg = getErrorString(
- DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.ILLEGAL_LIST_FACET],
- new Object[] { key });
- throw new InvalidDatatypeFacetException();
- }
- }
- if (((fFacetsDefined & DatatypeValidator.FACET_LENGTH ) != 0 ) ) {
- if (((fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH ) != 0 ) ) {
- throw new InvalidDatatypeFacetException(
- "It is an error for both length and maxLength to be members of facets." );
- } else if (((fFacetsDefined & DatatypeValidator.FACET_MINLENGTH ) != 0 ) ) {
- throw new InvalidDatatypeFacetException(
- "It is an error for both length and minLength to be members of facets." );
+ if (facets != null) {
+ for (Enumeration e = facets.keys(); e.hasMoreElements();) {
+ String key = (String) e.nextElement();
+ if (key.equals(SchemaSymbols.ELT_LENGTH)) {
+ fFacetsDefined |= DatatypeValidator.FACET_LENGTH;
+ String lengthValue = (String)facets.get(key);
+ try {
+ fLength = Integer.parseInt( lengthValue );
+ }
+ catch (NumberFormatException nfe) {
+ throw new InvalidDatatypeFacetException("Length value '"+lengthValue+"' is invalid.");
+ }
+ if (fLength < 0)
+ throw new InvalidDatatypeFacetException("Length value '"+lengthValue+"' must be a nonNegativeInteger.");
+
+ }
+ else if (key.equals(SchemaSymbols.ELT_MINLENGTH)) {
+ fFacetsDefined |= DatatypeValidator.FACET_MINLENGTH;
+ String minLengthValue = (String)facets.get(key);
+ try {
+ fMinLength = Integer.parseInt( minLengthValue );
+ }
+ catch (NumberFormatException nfe) {
+ throw new InvalidDatatypeFacetException("maxLength value '"+minLengthValue+"' is invalid.");
+ }
+ }
+ else if (key.equals(SchemaSymbols.ELT_MAXLENGTH)) {
+ fFacetsDefined |= DatatypeValidator.FACET_MAXLENGTH;
+ String maxLengthValue = (String)facets.get(key);
+ try {
+ fMaxLength = Integer.parseInt( maxLengthValue );
+ }
+ catch (NumberFormatException nfe) {
+ throw new InvalidDatatypeFacetException("maxLength value '"+maxLengthValue+"' is invalid.");
+ }
+ }
+ else if (key.equals(SchemaSymbols.ELT_ENUMERATION)) {
+ fFacetsDefined |= DatatypeValidator.FACET_ENUMERATION;
+ fEnumeration = (Vector)facets.get(key);
+ }
+ else if (key.equals(SchemaSymbols.ELT_PATTERN)) {
+ fFacetsDefined |= DatatypeValidator.FACET_PATTERN;
+ fPattern = (String)facets.get(key);
+ if (fPattern != null)
+ fRegex = new RegularExpression(fPattern, "X");
+ }
+ else {
+ String msg = getErrorString(
+ DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.ILLEGAL_LIST_FACET],
+ new Object[] { key});
+ throw new InvalidDatatypeFacetException();
+ }
}
- }
+ if (((fFacetsDefined & DatatypeValidator.FACET_LENGTH ) != 0 )) {
+ if (((fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH ) != 0 )) {
+ throw new InvalidDatatypeFacetException(
+ "It is an error for both length and maxLength to be members of facets." );
+ }
+ else if (((fFacetsDefined & DatatypeValidator.FACET_MINLENGTH ) != 0 )) {
+ throw new InvalidDatatypeFacetException(
+ "It is an error for both length and minLength to be members of facets." );
+ }
+ }
- if ( ( (fFacetsDefined & ( DatatypeValidator.FACET_MINLENGTH |
- DatatypeValidator.FACET_MAXLENGTH) ) != 0 ) ) {
- if ( fMinLength > fMaxLength ) {
- throw new InvalidDatatypeFacetException( "Value of minLength = " + fMinLength +
- "must be greater that the value of maxLength" + fMaxLength );
+ if (( (fFacetsDefined & ( DatatypeValidator.FACET_MINLENGTH |
+ DatatypeValidator.FACET_MAXLENGTH) ) != 0 )) {
+ if (fMinLength > fMaxLength) {
+ throw new InvalidDatatypeFacetException( "Value of minLength = " + fMinLength +
+ "must be greater that the value of maxLength" + fMaxLength );
+ }
}
- }
- // check 4.3.5.c0 must: enumeration values from the value space of base
- //REVISIT: we should try either to delay it till validate() or
- // store enumeration values in _value_space
- // otherwise we end up creating and throwing objects
- if ( base != null &&
- (fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) != 0 &&
- (fEnumeration != null) ) {
- int i = 0;
- try {
- for (; i < fEnumeration.size(); i++) {
- base.validate ((String)fEnumeration.elementAt(i), null);
- }
- } catch ( Exception idve ){
- throw new InvalidDatatypeFacetException( "Value of enumeration = '" + fEnumeration.elementAt(i) +
- "' must be from the value space of base.");
+ // check 4.3.5.c0 must: enumeration values from the value space of base
+ //REVISIT: we should try either to delay it till validate() or
+ // store enumeration values in _value_space
+ // otherwise we end up creating and throwing objects
+ if (base != null &&
+ (fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) != 0 &&
+ (fEnumeration != null)) {
+ int i = 0;
+ try {
+ for (; i < fEnumeration.size(); i++) {
+ base.validate ((String)fEnumeration.elementAt(i), null);
+ }
+ }
+ catch (Exception idve) {
+ throw new InvalidDatatypeFacetException( "Value of enumeration = '" + fEnumeration.elementAt(i) +
+ "' must be from the value space of base.");
+ }
}
+ }// End of Facets Setting
+ }
+ catch (Exception e) {
+
+ if (fErrorReporter == null) {
+ throw new RuntimeException("InternalDatatype error LDV.");
}
- }// End of Facets Setting
+ fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
+ "DatatypeFacetError", new Object [] { ((Exception)e).getMessage()},
+ XMLErrorReporter.SEVERITY_ERROR);
+ }
}
@@ -191,10 +209,11 @@
*/
public Object validate(String content, Object state) throws InvalidDatatypeValueException
{
- if ( content == null && state != null ) {
+ if (content == null && state != null) {
this.fBaseValidator.validate( content, state );//Passthrough setup information
- //for state validators
- } else {
+ //for state validators
+ }
+ else {
checkContentEnum( content, state , null);
}
return null;
@@ -206,13 +225,13 @@
* @return A Hashtable containing the facets
* for this datatype.
*/
- public Hashtable getFacets(){
+ public Hashtable getFacets() {
return null;
}
- public int compare( String value1, String value2 ){
+ public int compare( String value1, String value2 ) {
if (fBaseValidator instanceof ListDatatypeValidator) { //derived by restriction
- return ((ListDatatypeValidator)this.fBaseValidator).compare( value1, value2 );
+ return((ListDatatypeValidator)this.fBaseValidator).compare( value1, value2 );
}
// <list> datatype
StringTokenizer pList1 = new StringTokenizer( value1 );
@@ -226,14 +245,14 @@
}
else { //compare each token
int i=0;
- while(i++<numberOfTokens) {
- if ( this.fBaseValidator != null ) {
+ while (i++<numberOfTokens) {
+ if (this.fBaseValidator != null) {
int returnValue = this.fBaseValidator.compare( pList1.nextToken(), pList2.nextToken());
if (returnValue!=0) {
return returnValue; //REVISIT: does it make sense to return -1 or +1..?
}
}
-
+
}
return 0;
}
@@ -244,20 +263,16 @@
*/
public Object clone() throws CloneNotSupportedException {
ListDatatypeValidator newObj = null;
- try {
- newObj = new ListDatatypeValidator();
+ newObj = new ListDatatypeValidator();
- newObj.fLocale = this.fLocale;
- newObj.fBaseValidator = this.fBaseValidator;
- newObj.fLength = this.fLength;
- newObj.fMaxLength = this.fMaxLength;
- newObj.fMinLength = this.fMinLength;
- newObj.fPattern = this.fPattern;
- newObj.fEnumeration = this.fEnumeration;
- newObj.fFacetsDefined = this.fFacetsDefined;
- } catch ( InvalidDatatypeFacetException ex) {
- ex.printStackTrace();
- }
+ newObj.fLocale = this.fLocale;
+ newObj.fBaseValidator = this.fBaseValidator;
+ newObj.fLength = this.fLength;
+ newObj.fMaxLength = this.fMaxLength;
+ newObj.fMinLength = this.fMinLength;
+ newObj.fPattern = this.fPattern;
+ newObj.fEnumeration = this.fEnumeration;
+ newObj.fFacetsDefined = this.fFacetsDefined;
return newObj;
}
@@ -270,61 +285,63 @@
* @exception throws InvalidDatatypeException if the content is not valid
* @exception InvalidDatatypeValueException
*/
- protected void checkContentEnum( String content, Object state, Vector enumeration )
- throws InvalidDatatypeValueException {
-
- //REVISIT: attemt to make enumeration to be validated against value space.
- //a redesign of Datatypes might help to reduce complexity of this validation
-
- StringTokenizer parsedList = new StringTokenizer( content );
- int numberOfTokens = parsedList.countTokens();
- if (fBaseValidator instanceof ListDatatypeValidator) {
+ protected void checkContentEnum( String content, Object state, Vector enumeration )
+ throws InvalidDatatypeValueException {
+
+ //REVISIT: attemt to make enumeration to be validated against value space.
+ //a redesign of Datatypes might help to reduce complexity of this validation
+
+ StringTokenizer parsedList = new StringTokenizer( content );
+ int numberOfTokens = parsedList.countTokens();
+ if (fBaseValidator instanceof ListDatatypeValidator) {
//<simpleType name="fRestriction"><restriction base="fList">...</restriction></simpleType>
try {
- if ( (fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH) != 0 ) {
- if ( numberOfTokens > fMaxLength ) {
+ if ((fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH) != 0) {
+ if (numberOfTokens > fMaxLength) {
throw new InvalidDatatypeValueException("Value '"+content+
- "' with length ='"+ numberOfTokens + "' tokens"+
- "' exceeds maximum length facet of '"+fMaxLength+"' tokens.");
+ "' with length ='"+ numberOfTokens + "' tokens"+
+ "' exceeds maximum length facet of '"+fMaxLength+"' tokens.");
}
}
- if ( (fFacetsDefined & DatatypeValidator.FACET_MINLENGTH) != 0 ) {
- if ( numberOfTokens < fMinLength ) {
+ if ((fFacetsDefined & DatatypeValidator.FACET_MINLENGTH) != 0) {
+ if (numberOfTokens < fMinLength) {
throw new InvalidDatatypeValueException("Value '"+content+
- "' with length ='"+ numberOfTokens+ "' tokens" +
- "' is less than minimum length facet of '"+fMinLength+"' tokens." );
+ "' with length ='"+ numberOfTokens+ "' tokens" +
+ "' is less than minimum length facet of '"+fMinLength+"' tokens." );
}
}
- if ( (fFacetsDefined & DatatypeValidator.FACET_LENGTH) != 0 ) {
- if ( numberOfTokens != fLength ) {
+ if ((fFacetsDefined & DatatypeValidator.FACET_LENGTH) != 0) {
+ if (numberOfTokens != fLength) {
throw new InvalidDatatypeValueException("Value '"+content+
- "' with length ='"+ numberOfTokens+ "' tokens" +
- "' is not equal to length facet of '"+fLength+"' tokens.");
+ "' with length ='"+ numberOfTokens+ "' tokens" +
+ "' is not equal to length facet of '"+fLength+"' tokens.");
}
}
if (enumeration!=null) {
if (!verifyEnum(enumeration)) {
String msg = getErrorString(
- DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.NOT_ENUM_VALUE],
- new Object [] { enumeration });
+ DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.NOT_ENUM_VALUE],
+ new Object [] { enumeration});
throw new InvalidDatatypeValueException(msg);
}
- }else {
+ }
+ else {
enumeration = (fEnumeration!=null) ? fEnumeration : null;
}
-
+
// enumeration must be passed till we know what "itemType" is
// to be able to validate against value space
((ListDatatypeValidator)this.fBaseValidator).checkContentEnum( content, state, enumeration );
- } catch ( NoSuchElementException e ) {
+ }
+ catch (NoSuchElementException e) {
e.printStackTrace();
}
- }
- else {
+ }
+ else {
//the case:
//<simpleType name="fList"><list itemType="float"/></simpleType>
-
+
if (enumeration !=null) {
StringTokenizer eTokens = null; //temporary list of enumeration tokens
StringTokenizer cTokens = null; //list of content tokens
@@ -336,24 +353,25 @@
Vector enumTemp = new Vector(); //temporary vector to store enumeration token
enumTemp.setSize(1);
String currentEnumeration = null; //enum value: <enumeration value="1 2 3"/>
-
+
for (int i=0;i<eSize;i++) { //loop through each enumeration
currentEnumeration = (String)enumeration.elementAt(i);
eTokens = new StringTokenizer (currentEnumeration);
valid = true;
cTokens = (i==0)?parsedList:new StringTokenizer( content );
-
+
if (numberOfTokens == eTokens.countTokens()) {
try {
//try string comparison first
if (currentEnumeration.equals(content)) {
for (int k=0; k<numberOfTokens;k++) { //validate against base type each token
- if ( this.fBaseValidator != null ) {
+ if (this.fBaseValidator != null) {
this.fBaseValidator.validate( cTokens.nextToken(), state );
}
}
- } else { //content="1.0 2" ; enumeration = "1 2"
+ }
+ else { //content="1.0 2" ; enumeration = "1 2"
for (int j=0;j<numberOfTokens;j++) {
token = cTokens.nextToken();
eToken = eTokens.nextToken();
@@ -361,7 +379,8 @@
//REVISIT: date/time enumeration support
if (fBaseValidator instanceof AbstractNumericValidator) {
((AbstractNumericValidator)fBaseValidator).checkContentEnum(token, state, enumTemp);
- } else {
+ }
+ else {
if (!token.equals(eToken)) { //validate enumeration for all other types
throw new InvalidDatatypeValueException("Value '"+content+ "' must be one of "+enumeration);
}
@@ -369,10 +388,12 @@
}
}
}
- } catch (InvalidDatatypeValueException e) {
+ }
+ catch (InvalidDatatypeValueException e) {
valid = false;
}
- } else //numOfTokens in enumeration != numOfTokens in content
+ }
+ else //numOfTokens in enumeration != numOfTokens in content
valid = false;
if (valid) break;
} //end for loop
@@ -382,7 +403,7 @@
}//enumeration != null
else { //no enumeration
for (int k=0; k<numberOfTokens;k++) {
- if ( this.fBaseValidator != null ) {//validate against parent type if any
+ if (this.fBaseValidator != null) {//validate against parent type if any
this.fBaseValidator.validate( parsedList.nextToken(), state );
}
}
@@ -404,7 +425,7 @@
*
* @returns true if enumeration is subset of fEnumeration, false otherwise
*/
- private boolean verifyEnum (Vector enum){
+ private boolean verifyEnum (Vector enum) {
/* REVISIT: won't work for list datatypes in some cases: */
if ((fFacetsDefined & DatatypeValidator.FACET_ENUMERATION ) != 0) {
1.2 +6 -4 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/MonthDatatypeValidator.java
Index: MonthDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/MonthDatatypeValidator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MonthDatatypeValidator.java 2001/08/24 22:26:29 1.1
+++ MonthDatatypeValidator.java 2001/10/11 15:13:33 1.2
@@ -58,23 +58,25 @@
package org.apache.xerces.impl.v2.datatypes;
import java.util.Hashtable;
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
/**
* Validator for <gMonth> datatype (W3C Schema Datatypes)
*
* @author Elena Litani
- * @version $Id: MonthDatatypeValidator.java,v 1.1 2001/08/24 22:26:29 elena Exp $
+ * @version $Id: MonthDatatypeValidator.java,v 1.2 2001/10/11 15:13:33 elena Exp $
*/
public class MonthDatatypeValidator extends DateTimeValidator {
- public MonthDatatypeValidator() throws InvalidDatatypeFacetException{
+ public MonthDatatypeValidator() {
super();
}
public MonthDatatypeValidator ( DatatypeValidator base, Hashtable facets,
- boolean derivedByList ) throws InvalidDatatypeFacetException {
- super(base, facets, derivedByList);
+ boolean derivedByList, XMLErrorReporter reporter) {
+ super(base, facets, derivedByList, reporter);
}
/**
1.2 +6 -4 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/MonthDayDatatypeValidator.java
Index: MonthDayDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/MonthDayDatatypeValidator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MonthDayDatatypeValidator.java 2001/08/24 22:26:29 1.1
+++ MonthDayDatatypeValidator.java 2001/10/11 15:13:33 1.2
@@ -59,12 +59,14 @@
package org.apache.xerces.impl.v2.datatypes;
import java.util.Hashtable;
+ import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
/**
* Validator for <gMonthDay> datatype (W3C Schema Datatypes)
*
* @author Elena Litani
- * @version $Id: MonthDayDatatypeValidator.java,v 1.1 2001/08/24 22:26:29 elena Exp $
+ * @version $Id: MonthDayDatatypeValidator.java,v 1.2 2001/10/11 15:13:33 elena Exp $
*/
public class MonthDayDatatypeValidator extends DateTimeValidator {
@@ -72,13 +74,13 @@
//size without time zone: --MM-DD
private final static int MONTHDAY_SIZE = 7;
- public MonthDayDatatypeValidator() throws InvalidDatatypeFacetException{
+ public MonthDayDatatypeValidator() {
super();
}
public MonthDayDatatypeValidator ( DatatypeValidator base, Hashtable facets,
- boolean derivedByList ) throws InvalidDatatypeFacetException {
- super(base, facets, derivedByList);
+ boolean derivedByList, XMLErrorReporter reporter) {
+ super(base, facets, derivedByList, reporter);
}
/**
1.2 +8 -5 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/NOTATIONDatatypeValidator.java
Index: NOTATIONDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/NOTATIONDatatypeValidator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NOTATIONDatatypeValidator.java 2001/08/24 22:26:29 1.1
+++ NOTATIONDatatypeValidator.java 2001/10/11 15:13:33 1.2
@@ -59,7 +59,10 @@
import java.util.Hashtable;
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
+
/**
* NOTATIONValidator defines the interface that data type validators must obey.
* These validators can be supplied by the application writer and may be useful as
@@ -68,7 +71,7 @@
* @author Elena Litani
* @author Jeffrey Rodriguez-
* @author Mark Swinkles - List Validation refactoring
- * @version $Id: NOTATIONDatatypeValidator.java,v 1.1 2001/08/24 22:26:29 elena Exp $
+ * @version $Id: NOTATIONDatatypeValidator.java,v 1.2 2001/10/11 15:13:33 elena Exp $
*/
public class NOTATIONDatatypeValidator extends AbstractStringValidator {
@@ -79,14 +82,14 @@
private static AnyURIDatatypeValidator fgURIValidator = null;
*/
- public NOTATIONDatatypeValidator () throws InvalidDatatypeFacetException {
- this ( null, null, false ); // Native, No Facets defined, Restriction
+ public NOTATIONDatatypeValidator () {
+ this ( null, null, false, null ); // Native, No Facets defined, Restriction
}
public NOTATIONDatatypeValidator ( DatatypeValidator base, Hashtable facets,
- boolean derivedByList ) throws InvalidDatatypeFacetException {
+ boolean derivedByList, XMLErrorReporter reporter) {
- super (base, facets, derivedByList);
+ super (base, facets, derivedByList, reporter);
// make a string validator for NCName and anyURI
// REVISIT: do we really need to validate against value space..?
1.3 +7 -5 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/QNameDatatypeValidator.java
Index: QNameDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/QNameDatatypeValidator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- QNameDatatypeValidator.java 2001/09/05 21:16:03 1.2
+++ QNameDatatypeValidator.java 2001/10/11 15:13:33 1.3
@@ -61,6 +61,8 @@
import java.util.Locale;
import java.text.Collator;
import org.apache.xerces.impl.v2.SchemaSymbols;
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
/**
* QName Validator validates a QName type.
@@ -74,7 +76,7 @@
*
* @author Jeffrey Rodriguez
* @author Mark Swinkles - List Validation refactoring
- * @version $Id: QNameDatatypeValidator.java,v 1.2 2001/09/05 21:16:03 sandygao Exp $
+ * @version $Id: QNameDatatypeValidator.java,v 1.3 2001/10/11 15:13:33 elena Exp $
*/
public class QNameDatatypeValidator extends AbstractStringValidator {
@@ -83,14 +85,14 @@
// REVISIT: synch issues?
private static DatatypeValidator fgStrValidator = null;
- public QNameDatatypeValidator () throws InvalidDatatypeFacetException {
- this ( null, null, false ); // Native, No Facets defined, Restriction
+ public QNameDatatypeValidator () {
+ this ( null, null, false, null ); // Native, No Facets defined, Restriction
}
public QNameDatatypeValidator ( DatatypeValidator base, Hashtable facets,
- boolean derivedByList ) throws InvalidDatatypeFacetException {
+ boolean derivedByList, XMLErrorReporter reporter) {
- super (base, facets, derivedByList);
+ super (base, facets, derivedByList, reporter);
}
protected void assignAdditionalFacets(String key, Hashtable facets) throws InvalidDatatypeFacetException{
1.3 +9 -10 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/StringDatatypeValidator.java
Index: StringDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/StringDatatypeValidator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- StringDatatypeValidator.java 2001/09/19 18:16:07 1.2
+++ StringDatatypeValidator.java 2001/10/11 15:13:33 1.3
@@ -64,27 +64,30 @@
import java.text.Collator;
import org.apache.xerces.impl.v2.SchemaSymbols;
import org.apache.xerces.impl.v2.util.regex.RegularExpression;
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
+
/**
* StringValidator validates that XML content is a W3C string type.
* @author Ted Leung
* @author Kito D. Mann, Virtua Communications Corp.
* @author Jeffrey Rodriguez
* @author Mark Swinkles - List Validation refactoring
- * @version $Id: StringDatatypeValidator.java,v 1.2 2001/09/19 18:16:07 neilg Exp $
+ * @version $Id: StringDatatypeValidator.java,v 1.3 2001/10/11 15:13:33 elena Exp $
*/
public class StringDatatypeValidator extends AbstractStringValidator {
private short fWhiteSpace;
- public StringDatatypeValidator () throws InvalidDatatypeFacetException{
- this ( null, null, false ); // Native, No Facets defined, Restriction
+ public StringDatatypeValidator () {
+ this ( null, null, false, null ); // Native, No Facets defined, Restriction
}
public StringDatatypeValidator ( DatatypeValidator base, Hashtable facets,
- boolean derivedByList ) throws InvalidDatatypeFacetException {
+ boolean derivedByList, XMLErrorReporter reporter) {
- super (base, facets, derivedByList);
+ super (base, facets, derivedByList, reporter);
}
@@ -181,7 +184,6 @@
*/
public Object clone() throws CloneNotSupportedException {
StringDatatypeValidator newObj = null;
- try {
newObj = new StringDatatypeValidator();
newObj.fLocale = this.fLocale;
@@ -193,10 +195,7 @@
newObj.fWhiteSpace = this.fWhiteSpace;
newObj.fEnumeration = this.fEnumeration;
newObj.fFacetsDefined = this.fFacetsDefined;
- }
- catch ( InvalidDatatypeFacetException ex ) {
- ex.printStackTrace();
- }
+
return newObj;
}
1.2 +6 -4 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/TimeDatatypeValidator.java
Index: TimeDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/TimeDatatypeValidator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TimeDatatypeValidator.java 2001/08/24 22:26:29 1.1
+++ TimeDatatypeValidator.java 2001/10/11 15:13:33 1.2
@@ -59,23 +59,25 @@
package org.apache.xerces.impl.v2.datatypes;
import java.util.Hashtable;
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
/**
* Validator for <time> datatype (W3C Schema Datatypes)
*
* @author Elena Litani
- * @version $Id: TimeDatatypeValidator.java,v 1.1 2001/08/24 22:26:29 elena Exp $
+ * @version $Id: TimeDatatypeValidator.java,v 1.2 2001/10/11 15:13:33 elena Exp $
*/
public class TimeDatatypeValidator extends DateTimeValidator {
- public TimeDatatypeValidator() throws InvalidDatatypeFacetException{
+ public TimeDatatypeValidator() {
super();
}
public TimeDatatypeValidator ( DatatypeValidator base, Hashtable facets,
- boolean derivedByList ) throws InvalidDatatypeFacetException {
- super (base, facets, derivedByList);
+ boolean derivedByList, XMLErrorReporter reporter) {
+ super (base, facets, derivedByList, reporter);
}
/**
1.3 +17 -10 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/UnionDatatypeValidator.java
Index: UnionDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/UnionDatatypeValidator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- UnionDatatypeValidator.java 2001/09/19 18:16:07 1.2
+++ UnionDatatypeValidator.java 2001/10/11 15:13:33 1.3
@@ -64,6 +64,8 @@
import java.util.NoSuchElementException;
import org.apache.xerces.impl.v2.SchemaSymbols;
import org.apache.xerces.impl.v2.util.regex.RegularExpression;
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
@@ -81,15 +83,19 @@
private StringBuffer errorMsg = null;
- public UnionDatatypeValidator () throws InvalidDatatypeFacetException{
- this( null, null, false ); // Native, No Facets defined, Restriction
+ public UnionDatatypeValidator () {
+ this( null, null, false, null ); // Native, No Facets defined, Restriction
}
- public UnionDatatypeValidator ( DatatypeValidator base, Hashtable facets, boolean derivedBy ) throws InvalidDatatypeFacetException {
+ public UnionDatatypeValidator ( DatatypeValidator base, Hashtable facets,
+ boolean derivedBy, XMLErrorReporter reporter ) {
+ fErrorReporter = reporter;
fBaseValidator = base;
//facets allowed are: pattern & enumeration
+ try{
+
if ( facets != null ) {
for ( Enumeration e = facets.keys(); e.hasMoreElements(); ) {
String key = (String) e.nextElement();
@@ -126,11 +132,16 @@
}
}
}// End of Facets Setting
+ } catch (Exception e){
+ fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
+ "DatatypeFacetError", new Object [] { ((Exception)e).getMessage()},
+ XMLErrorReporter.SEVERITY_ERROR);
+ }
}
-
- public UnionDatatypeValidator ( Vector base) {
+ public UnionDatatypeValidator ( Vector base, XMLErrorReporter reporter) {
+ fErrorReporter = reporter;
if ( base !=null ) {
fValidatorsSize = base.size();
fBaseValidators = new Vector(fValidatorsSize);
@@ -195,7 +206,6 @@
*/
public Object clone() throws CloneNotSupportedException {
UnionDatatypeValidator newObj = null;
- try {
newObj = new UnionDatatypeValidator();
newObj.fLocale = this.fLocale;
newObj.fBaseValidator = this.fBaseValidator;
@@ -203,10 +213,7 @@
newObj.fPattern = this.fPattern;
newObj.fEnumeration = this.fEnumeration;
newObj.fFacetsDefined = this.fFacetsDefined;
- }
- catch ( InvalidDatatypeFacetException ex ) {
- ex.printStackTrace();
- }
+
return(newObj);
}
1.2 +6 -5 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/YearDatatypeValidator.java
Index: YearDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/YearDatatypeValidator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- YearDatatypeValidator.java 2001/08/24 22:26:29 1.1
+++ YearDatatypeValidator.java 2001/10/11 15:13:33 1.2
@@ -61,24 +61,25 @@
package org.apache.xerces.impl.v2.datatypes;
import java.util.Hashtable;
-
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
/**
* Validator for <gYear> datatype (W3C Schema Datatypes)
*
* @author Elena Litani
- * @version $Id: YearDatatypeValidator.java,v 1.1 2001/08/24 22:26:29 elena Exp $
+ * @version $Id: YearDatatypeValidator.java,v 1.2 2001/10/11 15:13:33 elena Exp $
*/
public class YearDatatypeValidator extends DateTimeValidator {
- public YearDatatypeValidator() throws InvalidDatatypeFacetException{
+ public YearDatatypeValidator() {
super();
}
public YearDatatypeValidator ( DatatypeValidator base, Hashtable facets,
- boolean derivedByList ) throws InvalidDatatypeFacetException {
- super (base, facets, derivedByList);
+ boolean derivedByList, XMLErrorReporter reporter) {
+ super (base, facets, derivedByList, reporter);
}
/**
1.2 +6 -5 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/YearMonthDatatypeValidator.java
Index: YearMonthDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/YearMonthDatatypeValidator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- YearMonthDatatypeValidator.java 2001/08/24 22:26:29 1.1
+++ YearMonthDatatypeValidator.java 2001/10/11 15:13:33 1.2
@@ -58,24 +58,25 @@
package org.apache.xerces.impl.v2.datatypes;
import java.util.Hashtable;
-
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.v2.XSMessageFormatter;
/**
* Validator for <gYearMonth> datatype (W3C Schema Datatypes)
*
* @author Elena Litani
- * @version $Id: YearMonthDatatypeValidator.java,v 1.1 2001/08/24 22:26:29 elena Exp $
+ * @version $Id: YearMonthDatatypeValidator.java,v 1.2 2001/10/11 15:13:33 elena Exp $
*/
public class YearMonthDatatypeValidator extends DateTimeValidator {
- public YearMonthDatatypeValidator() throws InvalidDatatypeFacetException{
+ public YearMonthDatatypeValidator() {
super();
}
public YearMonthDatatypeValidator ( DatatypeValidator base, Hashtable facets,
- boolean derivedByList ) throws InvalidDatatypeFacetException {
- super (base, facets, derivedByList);
+ boolean derivedByList, XMLErrorReporter reporter) {
+ super (base, facets, derivedByList, reporter);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org