You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by sa...@apache.org on 2001/10/19 20:22:01 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes AbstractNumericFacetValidator.java DateTimeValidator.java DecimalDatatypeValidator.java IDDatatypeValidator.java IDREFDatatypeValidator.java
sandygao 01/10/19 11:22:01
Modified: java/src/org/apache/xerces/impl/v2 XSAttributeChecker.java
XSDComplexTypeTraverser.java XSDGroupTraverser.java
XSDHandler.java
java/src/org/apache/xerces/impl/v2/datatypes
AbstractNumericFacetValidator.java
DateTimeValidator.java
DecimalDatatypeValidator.java
IDDatatypeValidator.java
IDREFDatatypeValidator.java
Log:
various bug fixes: especially NPEs.
And ID/IDREF DVs were modified so that we can use Ant to compile them.
Revision Changes Path
1.31 +7 -5 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.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- XSAttributeChecker.java 2001/10/17 23:07:14 1.30
+++ XSAttributeChecker.java 2001/10/19 18:22:00 1.31
@@ -89,7 +89,7 @@
* - use symbol table instead of many hashtables
*
* @author Sandy Gao, IBM
- * @version $Id: XSAttributeChecker.java,v 1.30 2001/10/17 23:07:14 sandygao Exp $
+ * @version $Id: XSAttributeChecker.java,v 1.31 2001/10/19 18:22:00 sandygao Exp $
*/
public class XSAttributeChecker {
@@ -1299,7 +1299,7 @@
StringTokenizer t = new StringTokenizer (value, " ");
while (t.hasMoreTokens()) {
String token = t.nextToken ();
- retValue = fExtraDVs[DT_QNAME].validate(token, null);
+ retValue = fExtraDVs[DT_QNAME].validate(token, schemaDoc.fValidationContext);
// REVISIT: should have the datatype validators return
// the object representation of the value.
retValue = resolveQName(token, schemaDoc);
@@ -1354,7 +1354,7 @@
} else {
// we have found namespace URI here
// need to add it to the symbol table
- fExtraDVs[DT_ANYURI].validate(token, null);
+ fExtraDVs[DT_ANYURI].validate(token, schemaDoc.fValidationContext);
tempNamespace = fSymbolTable.addSymbol(token);
}
@@ -1399,7 +1399,7 @@
case DT_PUBLIC:
// public = A public identifier, per ISO 8879
// REVISIT: how to validate "public"???
- fExtraDVs[DT_TOKEN].validate(value, null);
+ fExtraDVs[DT_TOKEN].validate(value, schemaDoc.fValidationContext);
break;
case DT_USE:
// use = (optional | prohibited | required)
@@ -1469,7 +1469,9 @@
attrVal = normalize((String)values.elementAt(i+1), dv.getWSFacet());
try {
// and validate it using the DatatypeValidator
- dv.validate(attrVal,null);
+ // REVISIT: what would be the proper validation context?
+ // guess we need to save that in the vectors too.
+ dv.validate(attrVal, null);
} catch(InvalidDatatypeValueException ide) {
reportSchemaError ("s4s-att-invalid-value",
new Object[] {elName, attrName, ide.getLocalizedMessage()});
1.29 +4 -1 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.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- XSDComplexTypeTraverser.java 2001/10/18 18:41:18 1.28
+++ XSDComplexTypeTraverser.java 2001/10/19 18:22:00 1.29
@@ -80,7 +80,7 @@
* ((group | all | choice | sequence)?,
* ((attribute | attributeGroup)*, anyAttribute?))))
* </complexType>
- * @version $Id: XSDComplexTypeTraverser.java,v 1.28 2001/10/18 18:41:18 sandygao Exp $
+ * @version $Id: XSDComplexTypeTraverser.java,v 1.29 2001/10/19 18:22:00 sandygao Exp $
*/
class XSDComplexTypeTraverser extends XSDAbstractParticleTraverser {
@@ -755,6 +755,9 @@
private boolean isAttrOrAttrGroup(Element e)
{
+ if (e == null)
+ return false;
+
String elementName = DOMUtil.getLocalName(e);
if (elementName.equals(SchemaSymbols.ELT_ATTRIBUTE) ||
1.15 +5 -3 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDGroupTraverser.java
Index: XSDGroupTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDGroupTraverser.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- XSDGroupTraverser.java 2001/10/11 21:20:28 1.14
+++ XSDGroupTraverser.java 2001/10/19 18:22:00 1.15
@@ -73,7 +73,7 @@
* @author Rahul Srivastava, Sun Microsystems Inc.
* @author Elena Litani, IBM
* @author Lisa Martin, IBM
- * @version $Id: XSDGroupTraverser.java,v 1.14 2001/10/11 21:20:28 lmartin Exp $
+ * @version $Id: XSDGroupTraverser.java,v 1.15 2001/10/19 18:22:00 sandygao Exp $
*/
class XSDGroupTraverser extends XSDAbstractParticleTraverser {
@@ -164,7 +164,8 @@
if (childName.equals(SchemaSymbols.ELT_ANNOTATION)) {
traverseAnnotationDecl(l_elmChild, attrValues, true, schemaDoc);
l_elmChild = DOMUtil.getNextSiblingElement(l_elmChild);
- childName = l_elmChild.getLocalName();
+ if (l_elmChild != null)
+ childName = l_elmChild.getLocalName();
}
if (l_elmChild == null) {
@@ -183,7 +184,8 @@
XMLErrorReporter.SEVERITY_ERROR);
}
- if (DOMUtil.getNextSiblingElement(l_elmChild) != null) {
+ if (l_elmChild != null &&
+ DOMUtil.getNextSiblingElement(l_elmChild) != null) {
Object[] args = new Object [] { "group", childName};
fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
"GroupContentRestricted",
1.48 +12 -5 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDHandler.java
Index: XSDHandler.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDHandler.java,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- XSDHandler.java 2001/10/19 17:46:04 1.47
+++ XSDHandler.java 2001/10/19 18:22:00 1.48
@@ -97,7 +97,7 @@
* schema, other grammars may be constructed as a side-effect.
*
* @author Neil Graham, IBM
- * @version $Id: XSDHandler.java,v 1.47 2001/10/19 17:46:04 elena Exp $
+ * @version $Id: XSDHandler.java,v 1.48 2001/10/19 18:22:00 sandygao Exp $
*/
class XSDHandler {
@@ -303,15 +303,22 @@
// third phase: call traversers
traverseSchemas();
- // fourth: handle local element decls
+ // fourth: handle substitution group declarations
+ // we defer substitution group handling for circular substitution
+ // REVISIT: wait until we are sure that such circular referencence
+ // is allowed.
+ //fElementTraverser.resolveSubstitutionGroup();
+
+ // fifth phase: handle local element decls
traverseLocalElements();
- // fifth phase: handle Keyrefs
+ // sixth phase: handle Keyrefs
resolveKeyRefs();
- // sixth phase: handle derivation constraint checking
+ // seventh phase: handle derivation constraint checking
// and UPA, and validate attribute of non-schema namespaces
- fAttributeChecker.checkNonSchemaAttributes(fGrammarResolver);
+ // REVISIT: skip this for now. we reall don't want to do it.
+ //fAttributeChecker.checkNonSchemaAttributes(fGrammarResolver);
// and return.
return fGrammarResolver.getGrammar(fRoot.fTargetNamespace);
1.5 +27 -26 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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AbstractNumericFacetValidator.java 2001/10/16 17:21:39 1.4
+++ AbstractNumericFacetValidator.java 2001/10/19 18:22:00 1.5
@@ -70,11 +70,11 @@
/**
* AbstractNumericFacetValidator is a base class for decimal, double, float,
- * and all date/time datatype validators. It implements evaluation of common facets -
+ * and all date/time datatype validators. It implements evaluation of common facets -
* minInclusive, maxInclusive, minExclusive, maxExclusive according to schema specs.
- *
+ *
* @author Elena Litani
- * @version $Id: AbstractNumericFacetValidator.java,v 1.4 2001/10/16 17:21:39 elena Exp $
+ * @version $Id: AbstractNumericFacetValidator.java,v 1.5 2001/10/19 18:22:00 sandygao Exp $
*/
public abstract class AbstractNumericFacetValidator extends AbstractDatatypeValidator {
@@ -91,8 +91,8 @@
this( null, null, false, null ); // Native, No Facets defined, Restriction
}
- public AbstractNumericFacetValidator ( DatatypeValidator base,
- Hashtable facets,
+ public AbstractNumericFacetValidator ( DatatypeValidator base,
+ Hashtable facets,
boolean derivedByList, XMLErrorReporter reporter) {
fBaseValidator = base;
fErrorReporter = reporter;
@@ -112,10 +112,11 @@
String value = null;
if (key.equals(SchemaSymbols.ELT_PATTERN)) {
- fFacetsDefined |= DatatypeValidator.FACET_PATTERN;
fPattern = (String) facets.get(key);
if (fPattern != null)
fRegex = new RegularExpression(fPattern, "X" );
+ if (fRegex != null)
+ fFacetsDefined |= DatatypeValidator.FACET_PATTERN;
}
else if (key.equals(SchemaSymbols.ELT_ENUMERATION)) {
enumeration = (Vector)facets.get(key);
@@ -123,23 +124,23 @@
}
else if (key.equals(SchemaSymbols.ELT_MAXINCLUSIVE)) {
value = ((String) facets.get(key ));
- fFacetsDefined |= DatatypeValidator.FACET_MAXINCLUSIVE;
setMaxInclusive(value);
+ fFacetsDefined |= DatatypeValidator.FACET_MAXINCLUSIVE;
}
else if (key.equals(SchemaSymbols.ELT_MAXEXCLUSIVE)) {
value = ((String) facets.get(key ));
- fFacetsDefined |= DatatypeValidator.FACET_MAXEXCLUSIVE;
setMaxExclusive(value);
+ fFacetsDefined |= DatatypeValidator.FACET_MAXEXCLUSIVE;
}
else if (key.equals(SchemaSymbols.ELT_MININCLUSIVE)) {
value = ((String) facets.get(key ));
- fFacetsDefined |= DatatypeValidator.FACET_MININCLUSIVE;
setMinInclusive(value);
+ fFacetsDefined |= DatatypeValidator.FACET_MININCLUSIVE;
}
else if (key.equals(SchemaSymbols.ELT_MINEXCLUSIVE)) {
value = ((String) facets.get(key ));
- fFacetsDefined |= DatatypeValidator.FACET_MINEXCLUSIVE;
setMinExclusive(value);
+ fFacetsDefined |= DatatypeValidator.FACET_MINEXCLUSIVE;
}
else if (key.equals(DatatypeValidator.FACET_FIXED)) {// fixed flags
fFlags = ((Short)facets.get(key)).shortValue();
@@ -153,18 +154,18 @@
if (fFacetsDefined != 0) {
// check 4.3.8.c1 error: maxInclusive + maxExclusive
- if (((fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) &&
+ 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) &&
+ 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) &&
+ if (((fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0) &&
((fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0)) {
result = compareValues(fMinInclusive, fMaxInclusive);
if (result == 1 || result == INDETERMINATE)
@@ -173,7 +174,7 @@
}
// 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);
+ result =compareValues(fMinExclusive, fMaxExclusive);
if (result == 1 || result == INDETERMINATE)
throw new InvalidDatatypeFacetException( "minExclusive value ='" + getMinExclusive(false) + "'must be <= maxExclusive value ='" +
getMaxExclusive(false) + "'. " );
@@ -206,10 +207,10 @@
if (((fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0)) {
if (((numBase.fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0)) {
- result = compareValues(fMaxInclusive, numBase.fMaxInclusive);
+ result = compareValues(fMaxInclusive, numBase.fMaxInclusive);
if ((numBase.fFlags & DatatypeValidator.FACET_MAXINCLUSIVE) != 0 &&
result != 0) {
- throw new InvalidDatatypeFacetException( "maxInclusive value = '" + getMaxInclusive(false) +
+ throw new InvalidDatatypeFacetException( "maxInclusive value = '" + getMaxInclusive(false) +
"' must be equal to base.maxInclusive value = '" +
getMaxInclusive(true) + "' with attribute {fixed} = true" );
}
@@ -247,7 +248,7 @@
result= compareValues(fMaxExclusive, numBase.fMaxExclusive);
if ((numBase.fFlags & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0 &&
result != 0) {
- throw new InvalidDatatypeFacetException( "maxExclusive value = '" + getMaxExclusive(false) +
+ throw new InvalidDatatypeFacetException( "maxExclusive value = '" + getMaxExclusive(false) +
"' must be equal to base.maxExclusive value = '" +
getMaxExclusive(true) + "' with attribute {fixed} = true" );
}
@@ -283,7 +284,7 @@
result= compareValues(fMinExclusive, numBase.fMinExclusive);
if ((numBase.fFlags & DatatypeValidator.FACET_MINEXCLUSIVE) != 0 &&
result != 0) {
- throw new InvalidDatatypeFacetException( "minExclusive value = '" + getMinExclusive(false) +
+ throw new InvalidDatatypeFacetException( "minExclusive value = '" + getMinExclusive(false) +
"' must be equal to base.minExclusive value = '" +
getMinExclusive(true) + "' with attribute {fixed} = true" );
}
@@ -321,10 +322,10 @@
// minInclusive >= base.maxExclusive
if (((fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0)) {
if (((numBase.fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0)) {
- result = compareValues(fMinInclusive, numBase.fMinInclusive);
+ result = compareValues(fMinInclusive, numBase.fMinInclusive);
if ((numBase.fFlags & DatatypeValidator.FACET_MININCLUSIVE) != 0 &&
result != 0) {
- throw new InvalidDatatypeFacetException( "minInclusive value = '" + getMinInclusive(false) +
+ throw new InvalidDatatypeFacetException( "minInclusive value = '" + getMinInclusive(false) +
"' must be equal to base.minInclusive value = '" +
getMinInclusive(true) + "' with attribute {fixed} = true" );
}
@@ -413,15 +414,15 @@
}
fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
"DatatypeFacetError", new Object [] { ((Exception)e).getMessage()},
- XMLErrorReporter.SEVERITY_ERROR);
+ XMLErrorReporter.SEVERITY_ERROR);
}
}
//
- // Compares values in value space of give datatype
+ // Compares values in value space of give datatype
//
- abstract protected int compareValues (Object value1, Object value2);
+ abstract protected int compareValues (Object value1, Object value2);
//
// set* functions used to set facets values
@@ -429,8 +430,8 @@
abstract protected void setMaxInclusive (String value);
abstract protected void setMinInclusive (String value);
abstract protected void setMaxExclusive (String value);
- abstract protected void setMinExclusive (String value);
- abstract protected void setEnumeration (Vector enumeration)
+ abstract protected void setMinExclusive (String value);
+ abstract protected void setEnumeration (Vector enumeration)
throws InvalidDatatypeValueException;
//
@@ -451,7 +452,7 @@
// decimal has fractionDigits and totalDigits facets
// all other datatypes will throw InvalidDatatypeFacetException
//
- abstract protected void assignAdditionalFacets(String key, Hashtable facets)
+ abstract protected void assignAdditionalFacets(String key, Hashtable facets)
throws InvalidDatatypeFacetException;
//
1.8 +100 -97 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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DateTimeValidator.java 2001/10/16 17:21:39 1.7
+++ DateTimeValidator.java 2001/10/19 18:22:00 1.8
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights
+ * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,7 +18,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
@@ -26,7 +26,7 @@
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -71,22 +71,22 @@
* This is the base class of all date/time datatype validators.
* It implements common code for parsing, validating and comparing datatypes.
* Classes that extend this class, must implement parse() method.
- *
+ *
* @author Elena Litani
- * @author Len Berman
+ * @author Len Berman
*
- * @version $Id: DateTimeValidator.java,v 1.7 2001/10/16 17:21:39 elena Exp $
+ * @version $Id: DateTimeValidator.java,v 1.8 2001/10/19 18:22:00 sandygao Exp $
*/
public abstract class DateTimeValidator extends AbstractNumericFacetValidator {
- //debugging
+ //debugging
private static final boolean DEBUG=false;
-
+
//define shared variables for date/time
//define constants
- protected final static int CY = 0, M = 1, D = 2, h = 3,
+ protected final static int CY = 0, M = 1, D = 2, h = 3,
m = 4, s = 5, ms = 6, utc=7, hh=0, mm=1;
//comparison
@@ -94,17 +94,17 @@
protected static final short EQUAL=0;
protected static final short GREATER_THAN=1;
- //size for all objects must have the same fields:
+ //size for all objects must have the same fields:
//CCYY, MM, DD, h, m, s, ms + timeZone
protected final static int TOTAL_SIZE = 8;
//date obj size for gMonth datatype (without time zone): --09--
- protected final static int MONTH_SIZE = 6;
+ protected final static int MONTH_SIZE = 6;
//date obj must have at least 6 chars after year (without time zone): "-MM-DD"
private final static int YEARMONTH_SIZE = 7;
- //define constants to be used in assigning default values for
+ //define constants to be used in assigning default values for
//all date/time excluding duration
protected final static int YEAR=2000;
protected final static int MONTH=01;
@@ -117,11 +117,11 @@
protected int fEnumSize;
//size of string buffer
- protected int fEnd;
+ protected int fEnd;
protected int fStart;
- //storage for string value of date/time object
- protected StringBuffer fBuffer;
+ //storage for string value of date/time object
+ protected StringBuffer fBuffer;
//obj to store all date/time objects with fields:
// {CY, M, D, h, m, s, ms, utc}
@@ -142,7 +142,7 @@
}
- public DateTimeValidator (DatatypeValidator base, Hashtable facets, boolean derivedByList, XMLErrorReporter reporter )
+ public DateTimeValidator (DatatypeValidator base, Hashtable facets, boolean derivedByList, XMLErrorReporter reporter )
{
super (base, facets, derivedByList, reporter);
}
@@ -150,18 +150,18 @@
protected void initializeValues(){
fDateValue = new int[TOTAL_SIZE];
fTempDate = new int[TOTAL_SIZE];
- fEnd = 30;
+ fEnd = 30;
fStart = 0;
message = new StringBuffer(TOTAL_SIZE);
fBuffer = new StringBuffer(fEnd);
timeZone = new int[2];
}
- protected void assignAdditionalFacets(String key, Hashtable facets ) throws InvalidDatatypeFacetException{
+ protected void assignAdditionalFacets(String key, Hashtable facets ) throws InvalidDatatypeFacetException{
String msg = "date/time datatypes, facet "+key+" with value "+(String)facets.get(key);
throw new InvalidDatatypeFacetException(msg);
}
-
+
protected int compareValues (Object value1, Object value2) {
return compareDates((int[])value1, (int[])value2, true);
}
@@ -172,7 +172,7 @@
protected void setMinInclusive (String value) {
fMinInclusive = parse(value, null);
}
-
+
protected void setMaxExclusive (String value) {
fMaxExclusive = parse(value, null);
@@ -182,16 +182,19 @@
}
protected void setEnumeration (Vector enumeration) throws InvalidDatatypeValueException{
-
+
if ( enumeration != null ) {
-
+
fEnumSize = enumeration.size();
fEnumeration = new int[fEnumSize][];
+ int j = 0;
for ( int i=0; i<fEnumSize; i++ ) {
try {
- fEnumeration[i] = parse((String)enumeration.elementAt(i), null);
+ fEnumeration[j] = parse((String)enumeration.elementAt(i), null);
+ j++;
}
catch ( RuntimeException e ) {
+ fEnumSize = j;
throw new InvalidDatatypeValueException(e.getMessage());
}
}
@@ -223,7 +226,7 @@
/**
* Implemented by each subtype, calling appropriate function to parse
* given date/time
- *
+ *
* @param content String value of the date/time
* @param date Storage to represent date/time object.
* If null - new object will be created, otherwise
@@ -235,10 +238,10 @@
/**
* Validate that a string is a W3C date/time type
- *
+ *
* @param content string value of date/time
* @param state
- * @return
+ * @return
* @exception InvalidDatatypeValueException
*/
public Object validate(String content, ValidationContext state) throws InvalidDatatypeValueException{
@@ -257,7 +260,7 @@
/**
* Validates date object against facet and base datatype
- *
+ *
* @param date represents date/time obj
* @param content lexical representation of date/time obj
* @exception InvalidDatatypeValueException
@@ -271,7 +274,7 @@
"' does not match regular expression facet " + fRegex.getPattern() );
}
//validate against base type
- if (!(fBaseValidator instanceof AnySimpleType)) {
+ if (!(fBaseValidator instanceof AnySimpleType)) {
((DateTimeValidator)this.fBaseValidator).validateDate( date, content);
}
if ( (fFacetsDefined & DatatypeValidator.FACET_ENUMERATION ) != 0 ) {
@@ -293,7 +296,7 @@
// REVISIT: output values for facets in error message
short c;
if ( fMinInclusive != null ) {
-
+
c = compareDates(date, (int[])fMinInclusive, false);
if ( c == LESS_THAN || c == INDETERMINATE ) {
throw new InvalidDatatypeValueException("Value '"+content+
@@ -332,7 +335,7 @@
}
public int compare( String content1, String content2) {
//implement compareDates using the compare() method
- try{
+ try{
parse(content1, fDateValue);
parse(content2,fTempDate);
int result = compareDates(fDateValue, fTempDate, true);
@@ -340,7 +343,7 @@
}
catch ( RuntimeException e ) {
return -1;
-
+
}
}
@@ -354,7 +357,7 @@
/**
* Compare algorithm described in dateDime (3.2.7).
* Duration datatype overwrites this method
- *
+ *
* @param date1 normalized date representation of the first value
* @param date2 normalized date representation of the second value
* @param strict
@@ -362,7 +365,7 @@
*/
protected short compareDates(int[] date1, int[] date2, boolean strict) {
if ( date1[utc]==date2[utc] ) {
- return compareOrder(date1, date2);
+ return compareOrder(date1, date2);
}
short c1, c2;
@@ -388,14 +391,14 @@
if ( (c1==LESS_THAN && c2==GREATER_THAN) ||
(c1==GREATER_THAN && c2==LESS_THAN) ) {
- return INDETERMINATE;
+ return INDETERMINATE;
}
//REVISIT: wait for clarification on this case from schema
return(c1!=INDETERMINATE)?c1:c2;
}
else if ( date2[utc]=='Z' ) {
- //compare (date1 with time zone -14)<=date2
+ //compare (date1 with time zone -14)<=date2
//
cloneDate(date1); //clones date1 value to global temporary storage: fTempDate
timeZone[hh]=14;
@@ -411,7 +414,7 @@
System.out.println("date=" + dateToString(date2));
System.out.println("fTempDate=" + dateToString(fTempDate));
}
- //compare (date1 with time zone +14)<=date2
+ //compare (date1 with time zone +14)<=date2
//
cloneDate(date1); //clones date1 value to global temporary storage: fTempDate
timeZone[hh]=14;
@@ -424,7 +427,7 @@
}
if ( (c1==LESS_THAN && c2==GREATER_THAN) ||
(c1==GREATER_THAN && c2==LESS_THAN) ) {
- return INDETERMINATE;
+ return INDETERMINATE;
}
//REVISIT: wait for clarification on this case from schema
return(c1!=INDETERMINATE)?c1:c2;
@@ -437,13 +440,13 @@
/**
* Given normalized values, determines order-relation
* between give date/time objects.
- *
+ *
* @param date1 date/time object
* @param date2 date/time object
- * @return
+ * @return
*/
protected short compareOrder (int[] date1, int[] date2) {
-
+
for ( int i=0;i<TOTAL_SIZE;i++ ) {
if ( date1[i]<date2[i] ) {
return LESS_THAN;
@@ -458,17 +461,17 @@
/**
* Parses time hh:mm:ss.sss and time zone if any
- *
+ *
* @param start
* @param end
* @param data
- * @return
+ * @return
* @exception Exception
*/
protected void getTime (int start, int end, int[] data) throws RuntimeException{
-
+
int stop = start+2;
-
+
//get hours (hh)
data[h]=parseInt(start,stop);
@@ -486,7 +489,7 @@
throw new RuntimeException("Error in parsing time zone" );
}
start = stop;
- stop = stop+2;
+ stop = stop+2;
data[s]=parseInt(start,stop);
//get miliseconds (ms)
@@ -495,12 +498,12 @@
//find UTC sign if any
int sign = findUTCSign((milisec!=-1)?milisec:start, end);
- //parse miliseconds
+ //parse miliseconds
if ( milisec != -1 ) {
if ( sign<0 ) {
- //get all digits after "."
+ //get all digits after "."
data[ms]=parseInt(milisec+1,fEnd);
}
else {
@@ -511,7 +514,7 @@
}
- //parse UTC time zone (hh:mm)
+ //parse UTC time zone (hh:mm)
if ( sign>0 ) {
getTimeZone(data,sign);
}
@@ -520,11 +523,11 @@
/**
* Parses date CCYY-MM-DD
- *
+ *
* @param start
* @param end
* @param data
- * @return
+ * @return
* @exception Exception
*/
protected void getDate (int start, int end, int[] date) throws RuntimeException{
@@ -541,11 +544,11 @@
/**
* Parses date CCYY-MM
- *
+ *
* @param start
* @param end
* @param data
- * @return
+ * @return
* @exception Exception
*/
protected void getYearMonth (int start, int end, int[] date) throws RuntimeException{
@@ -580,16 +583,16 @@
/**
* Shared code from Date and YearMonth datatypes.
* Finds if time zone sign is present
- *
+ *
* @param end
* @param date
- * @return
+ * @return
* @exception Exception
*/
protected void parseTimeZone (int end, int[] date) throws RuntimeException{
//fStart points right after the date
-
+
if ( fStart<fEnd ) {
int sign = findUTCSign(fStart, fEnd);
if ( sign<0 ) {
@@ -603,10 +606,10 @@
/**
* Parses time zone: 'Z' or {+,-} followed by hh:mm
- *
+ *
* @param data
* @param sign
- * @return
+ * @return
*/
protected void getTimeZone (int[] data, int sign) throws RuntimeException{
data[utc]=fBuffer.charAt(sign);
@@ -618,21 +621,21 @@
return;
}
if ( sign<=(fEnd-6) ) {
-
+
//parse [hh]
int stop = ++sign+2;
timeZone[hh]=parseInt(sign, stop);
if (fBuffer.charAt(stop++)!=':') {
throw new RuntimeException("Error in parsing time zone" );
- }
-
+ }
+
//parse [ss]
timeZone[mm]=parseInt(stop, stop+2);
-
+
if ( stop+2!=fEnd ) {
throw new RuntimeException("Error in parsing time zone");
}
-
+
}
else {
throw new RuntimeException("Error in parsing time zone");
@@ -646,7 +649,7 @@
/**
* Computes index of given char within StringBuffer
- *
+ *
* @param start
* @param end
* @param ch character to look for in StringBuffer
@@ -663,16 +666,16 @@
/**
- * Validates given date/time object accoring to W3C PR Schema
+ * Validates given date/time object accoring to W3C PR Schema
* [D.1 ISO 8601 Conventions]
- *
+ *
* @param data
- * @return
+ * @return
*/
protected void validateDateTime (int[] data) {
//REVISIT: should we throw an exception for not valid dates
- // or reporting an error message should be sufficient?
+ // or reporting an error message should be sufficient?
if ( data[CY]==0 ) {
throw new RuntimeException("The year \"0000\" is an illegal year value");
@@ -718,10 +721,10 @@
/**
* Return index of UTC char: 'Z', '+', '-'
- *
+ *
* @param start
* @param end
- * @return
+ * @return
*/
protected int findUTCSign (int start, int end) {
int c;
@@ -738,14 +741,14 @@
/**
* Given start and end position, parses string value
- *
+ *
* @param value string to parse
* @param start Start position
* @param end end position
* @return return integer representation of characters
*/
- protected int parseInt (int start, int end)
- throws NumberFormatException{
+ protected int parseInt (int start, int end)
+ throws NumberFormatException{
//REVISIT: more testing on this parsing needs to be done.
int radix=10;
int result = 0;
@@ -779,8 +782,8 @@
negative = true;
limit = Integer.MIN_VALUE;
i++;
-
- }
+
+ }
else{
limit = -Integer.MAX_VALUE;
}
@@ -808,7 +811,7 @@
/**
* If timezone present - normalize dateTime [E Adding durations to dateTimes]
- *
+ *
* @param date CCYY-MM-DDThh:mm:ss+03
* @return CCYY-MM-DDThh:mm:ssZ
*/
@@ -830,7 +833,7 @@
int temp = date[m] + negate*timeZone[mm];
int carry = fQuotient (temp, 60);
date[m]= mod(temp, 60, carry);
-
+
if ( DEBUG ) {
System.out.println("==>carry: " + carry);
}
@@ -862,14 +865,14 @@
date[M]=modulo(temp, 1, 13);
date[CY]=date[CY]+fQuotient(temp, 1, 13);
}
- date[utc]='Z';
+ date[utc]='Z';
}
/**
- * Resets fBuffer to store string representation of
+ * Resets fBuffer to store string representation of
* date/time
- *
+ *
* @param str Lexical representation of date/time
*/
protected void resetBuffer (String str) {
@@ -878,13 +881,13 @@
timeZone[hh]=timeZone[mm]=0;
fBuffer.append(str);
fEnd = fBuffer.length();
-
+
}
/**
* Resets object representation of date/time
- *
+ *
* @param data date/time object
*/
protected void resetDateObj (int[] data) {
@@ -895,12 +898,12 @@
/**
- * Given {year,month} computes maximum
+ * Given {year,month} computes maximum
* number of days for given month
- *
+ *
* @param year
* @param month
- * @return
+ * @return
*/
protected int maxDayInMonthFor(int year, int month) {
//validate days
@@ -923,32 +926,32 @@
private boolean isLeapYear(int year) {
- //REVISIT: should we take care about Julian calendar?
- return((year%4 == 0) && ((year%100 != 0) || (year%400 == 0)));
+ //REVISIT: should we take care about Julian calendar?
+ return((year%4 == 0) && ((year%100 != 0) || (year%400 == 0)));
}
//
// help function described in W3C PR Schema [E Adding durations to dateTimes]
- //
+ //
protected int mod (int a, int b, int quotient) {
- //modulo(a, b) = a - fQuotient(a,b)*b
+ //modulo(a, b) = a - fQuotient(a,b)*b
return (a - quotient*b) ;
}
-
+
//
// help function described in W3C PR Schema [E Adding durations to dateTimes]
//
protected int fQuotient (int a, int b) {
-
- //fQuotient(a, b) = the greatest integer less than or equal to a/b
+
+ //fQuotient(a, b) = the greatest integer less than or equal to a/b
return (int)Math.floor((float)a/b);
}
//
// help function described in W3C PR Schema [E Adding durations to dateTimes]
- //
+ //
protected int modulo (int temp, int low, int high) {
- //modulo(a - low, high - low) + low
+ //modulo(a - low, high - low) + low
int a = temp - low;
int b = high - low;
return (mod (a, b, fQuotient(a, b)) + low) ;
@@ -958,8 +961,8 @@
// help function described in W3C PR Schema [E Adding durations to dateTimes]
//
protected int fQuotient (int temp, int low, int high) {
- //fQuotient(a - low, high - low)
-
+ //fQuotient(a - low, high - low)
+
return fQuotient(temp - low, high - low);
}
@@ -986,7 +989,7 @@
/**
* Use this function to report errors in constructor
- *
+ *
* @param msg
* @param value
*/
1.7 +6 -6 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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DecimalDatatypeValidator.java 2001/10/16 17:21:39 1.6
+++ DecimalDatatypeValidator.java 2001/10/19 18:22:00 1.7
@@ -76,7 +76,7 @@
* @author Ted Leung
* @author Jeffrey Rodriguez
* @author Mark Swinkles - List Validation refactoring
- * @version $Id: DecimalDatatypeValidator.java,v 1.6 2001/10/16 17:21:39 elena Exp $
+ * @version $Id: DecimalDatatypeValidator.java,v 1.7 2001/10/19 18:22:00 sandygao Exp $
*/
public class DecimalDatatypeValidator extends AbstractNumericValidator {
@@ -267,7 +267,7 @@
// we check pattern first
if ((fFacetsDefined & DatatypeValidator.FACET_PATTERN ) != 0) {
- if (fRegex == null || fRegex.matches( content) == false)
+ if (fRegex == null || !fRegex.matches( content))
throw new InvalidDatatypeValueException("Value'"+content+
"' does not match regular expression facet " + fRegex.getPattern() );
}
@@ -308,8 +308,8 @@
if (d.scale() > fFractionDigits) {
String msg = getErrorString(
DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.FRACTION_EXCEEDED],
- new Object[] {
- "'" + content + "'" + " with fractionDigits = '"+ d.scale() +"'",
+ new Object[] {
+ "'" + content + "'" + " with fractionDigits = '"+ d.scale() +"'",
"'" + fFractionDigits + "'"
});
throw new InvalidDatatypeValueException(msg);
@@ -322,8 +322,8 @@
String msg = getErrorString(
DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.TOTALDIGITS_EXCEEDED],
- new Object[] {
- "'" + content + "'" + " with totalDigits = '"+ totalDigits +"'",
+ new Object[] {
+ "'" + content + "'" + " with totalDigits = '"+ totalDigits +"'",
"'" + fTotalDigits + "'"
});
throw new InvalidDatatypeValueException(msg);
1.8 +3 -4 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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- IDDatatypeValidator.java 2001/10/19 17:21:55 1.7
+++ IDDatatypeValidator.java 2001/10/19 18:22:00 1.8
@@ -61,7 +61,6 @@
import java.util.Enumeration;
import java.util.Vector;
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;
@@ -73,7 +72,7 @@
* 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.7 2001/10/19 17:21:55 elena Exp $
+ * @version $Id: IDDatatypeValidator.java,v 1.8 2001/10/19 18:22:00 sandygao Exp $
*/
public class IDDatatypeValidator extends StringDatatypeValidator {
@@ -108,7 +107,7 @@
/**
* Make sure that ID is unique in the document
- *
+ *
* @param content Id value
* @param state a structure that stores id's
* @return content
@@ -152,7 +151,7 @@
return content;
-
+
}
1.9 +2 -3 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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- IDREFDatatypeValidator.java 2001/10/19 17:21:55 1.8
+++ IDREFDatatypeValidator.java 2001/10/19 18:22:00 1.9
@@ -61,7 +61,6 @@
import java.util.Enumeration;
import java.util.Vector;
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;
@@ -74,7 +73,7 @@
*
* @author Jeffrey Rodriguez-
* @author Mark Swinkles - List Validation refactoring
- * @version $Id: IDREFDatatypeValidator.java,v 1.8 2001/10/19 17:21:55 elena Exp $
+ * @version $Id: IDREFDatatypeValidator.java,v 1.9 2001/10/19 18:22:00 sandygao Exp $
*/
public class IDREFDatatypeValidator extends StringDatatypeValidator {
private static Object fNullValue = new Object();
@@ -128,7 +127,7 @@
* @see org.apache.xerces.validators.datatype.InvalidDatatypeValueException
*/
public Object validate(String content, ValidationContext state ) throws InvalidDatatypeValueException{
-
+
return checkContent (content, state, false);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org