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 2002/04/19 19:20:24 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/dv/xs XSSimpleTypeDecl.java SchemaDVFactoryImpl.java
sandygao 02/04/19 10:20:24
Modified: java/src/org/apache/xerces/impl/dv/xs XSSimpleTypeDecl.java
SchemaDVFactoryImpl.java
Log:
"integer" and integer-derived types doesn't allow decimal point in the lexical
representation. A special pattern will be added to "integer" (an erratum to be
published).
Handling pattern is too expansive, so we use the same way as how we
handled NMToken/NCName/Name: use some special handling code.
Revision Changes Path
1.8 +33 -28 xml-xerces/java/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java
Index: XSSimpleTypeDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XSSimpleTypeDecl.java 3 Apr 2002 23:48:26 -0000 1.7
+++ XSSimpleTypeDecl.java 19 Apr 2002 17:20:23 -0000 1.8
@@ -80,7 +80,7 @@
* @author Sandy Gao, IBM
* @author Neeraj Bajaj, Sun Microsystems, inc.
*
- * @version $Id: XSSimpleTypeDecl.java,v 1.7 2002/04/03 23:48:26 elena Exp $
+ * @version $Id: XSSimpleTypeDecl.java,v 1.8 2002/04/19 17:20:23 sandygao Exp $
*/
public class XSSimpleTypeDecl implements XSAtomicSimpleType, XSListSimpleType, XSUnionSimpleType {
@@ -139,13 +139,14 @@
new UnionDV()
};
- static final short SPECIAL_TOKEN_NONE = 0;
- static final short SPECIAL_TOKEN_NMTOKEN = 1;
- static final short SPECIAL_TOKEN_NAME = 2;
- static final short SPECIAL_TOKEN_NCNAME = 3;
+ static final short SPECIAL_PATTERN_NONE = 0;
+ static final short SPECIAL_PATTERN_NMTOKEN = 1;
+ static final short SPECIAL_PATTERN_NAME = 2;
+ static final short SPECIAL_PATTERN_NCNAME = 3;
+ static final short SPECIAL_PATTERN_INTEGER = 4;
- static final String[] SPECIAL_TOKEN_STRING = {
- "NONE", "NMTOKEN", "Name", "NCName",
+ static final String[] SPECIAL_PATTERN_STRING = {
+ "NONE", "NMTOKEN", "Name", "NCName", "integer"
};
static final String[] WS_FACET_STRING = {
@@ -179,7 +180,7 @@
private Object fMinExclusive;
private Object fMinInclusive;
- private short fTokenType = SPECIAL_TOKEN_NONE;
+ private short fPatternType = SPECIAL_PATTERN_NONE;
// for fundamental facets
private short fOrdered;
@@ -243,7 +244,7 @@
fMinInclusive = fBase.fMinInclusive;
fTotalDigits = fBase.fTotalDigits;
fFractionDigits = fBase.fFractionDigits;
- fTokenType = fBase.fTokenType;
+ fPatternType = fBase.fPatternType;
fFixedFacet = fBase.fFixedFacet;
fFacetsDefined = fBase.fFacetsDefined;
@@ -324,7 +325,7 @@
fMinInclusive = fBase.fMinInclusive;
fTotalDigits = fBase.fTotalDigits;
fFractionDigits = fBase.fFractionDigits;
- fTokenType = fBase.fTokenType;
+ fPatternType = fBase.fPatternType;
fFixedFacet = fBase.fFixedFacet;
fFacetsDefined = fBase.fFacetsDefined;
@@ -471,7 +472,7 @@
*/
public void applyFacets(XSFacets facets, short presentFacet, short fixedFacet, ValidationContext context)
throws InvalidDatatypeFacetException {
- applyFacets(facets, presentFacet, fixedFacet, (short)0, context);
+ applyFacets(facets, presentFacet, fixedFacet, SPECIAL_PATTERN_NONE, context);
}
/**
@@ -480,7 +481,7 @@
void applyFacets1(XSFacets facets, short presentFacet, short fixedFacet) {
try {
- applyFacets(facets, presentFacet, fixedFacet, (short)0, fDummyContext);
+ applyFacets(facets, presentFacet, fixedFacet, SPECIAL_PATTERN_NONE, fDummyContext);
} catch (InvalidDatatypeFacetException e) {
// should never gets here, internel error
throw new RuntimeException("internal error");
@@ -490,10 +491,10 @@
/**
* built-in derived types by restriction
*/
- void applyFacets1(XSFacets facets, short presentFacet, short fixedFacet, short tokenType) {
+ void applyFacets1(XSFacets facets, short presentFacet, short fixedFacet, short patternType) {
try {
- applyFacets(facets, presentFacet, fixedFacet, tokenType, fDummyContext);
+ applyFacets(facets, presentFacet, fixedFacet, patternType, fDummyContext);
} catch (InvalidDatatypeFacetException e) {
// should never gets here, internel error
throw new RuntimeException("internal error");
@@ -503,7 +504,7 @@
/**
* If <restriction> is chosen, or built-in derived types by restriction
*/
- void applyFacets(XSFacets facets, short presentFacet, short fixedFacet, short tokenType, ValidationContext context)
+ void applyFacets(XSFacets facets, short presentFacet, short fixedFacet, short patternType, ValidationContext context)
throws InvalidDatatypeFacetException {
ValidatedInfo tempInfo = new ValidatedInfo();
@@ -772,8 +773,8 @@
}
// token type: internal use, so do less checking
- if (tokenType != SPECIAL_TOKEN_NONE) {
- fTokenType = tokenType;
+ if (patternType != SPECIAL_PATTERN_NONE) {
+ fPatternType = patternType;
}
// step 2: check facets against each other: length, bounds
@@ -1086,7 +1087,7 @@
fFacetsDefined |= FACET_MAXLENGTH;
fMaxLength = fBase.fMaxLength;
}
- // inherit pattern //???
+ // inherit pattern
if ( (fBase.fFacetsDefined & FACET_PATTERN) != 0 ) {
if ((fFacetsDefined & FACET_PATTERN) == 0) {
fPattern = new Vector();
@@ -1094,7 +1095,6 @@
}
for (int i = fBase.fPattern.size()-1; i >= 0; i--)
fPattern.addElement(fBase.fPattern.elementAt(i));
-
}
// inherit whiteSpace
if ( (fFacetsDefined & FACET_WHITESPACE) == 0 && (fBase.fFacetsDefined & FACET_WHITESPACE) != 0 ) {
@@ -1143,8 +1143,8 @@
fFractionDigits = fBase.fFractionDigits;
}
//inherit tokeytype
- if ((fTokenType == SPECIAL_TOKEN_NONE ) && (fBase.fTokenType != SPECIAL_TOKEN_NONE)) {
- fTokenType = fBase.fTokenType ;
+ if ((fPatternType == SPECIAL_PATTERN_NONE ) && (fBase.fPatternType != SPECIAL_PATTERN_NONE)) {
+ fPatternType = fBase.fPatternType ;
}
// step 5: mark fixed values
@@ -1348,25 +1348,30 @@
}
// validate special kinds of token, in place of old pattern matching
- if (fTokenType != SPECIAL_TOKEN_NONE) {
+ if (fPatternType != SPECIAL_PATTERN_NONE) {
boolean seenErr = false;
- if (fTokenType == SPECIAL_TOKEN_NMTOKEN) {
+ if (fPatternType == SPECIAL_PATTERN_NMTOKEN) {
// PATTERN "\\c+"
seenErr = !XMLChar.isValidNmtoken(nvalue);
}
- else if (fTokenType == SPECIAL_TOKEN_NAME) {
+ else if (fPatternType == SPECIAL_PATTERN_NAME) {
// PATTERN "\\i\\c*"
seenErr = !XMLChar.isValidName(nvalue);
}
- else if (fTokenType == SPECIAL_TOKEN_NCNAME) {
+ else if (fPatternType == SPECIAL_PATTERN_NCNAME) {
// PATTERN "[\\i-[:]][\\c-[:]]*"
- // REVISIT: !!!NOT IMPLEMENTED in XMLChar
seenErr = !XMLChar.isValidNCName(nvalue);
}
+ else if (fPatternType == SPECIAL_PATTERN_INTEGER) {
+ // REVISIT: the pattern is not published yet
+ // we only need to worry about the period '.'
+ // other parts are taken care of by the DecimalDV
+ seenErr = nvalue.indexOf('.') >= 0;
+ }
if (seenErr) {
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1",
- new Object[]{nvalue, SPECIAL_TOKEN_STRING[fTokenType]});
+ new Object[]{nvalue, SPECIAL_PATTERN_STRING[fPatternType]});
}
}
@@ -1919,7 +1924,7 @@
fMinExclusive = null;
fMinInclusive = null;
- fTokenType = SPECIAL_TOKEN_NONE;
+ fPatternType = SPECIAL_PATTERN_NONE;
// REVISIT: reset for fundamental facets
}
1.5 +5 -5 xml-xerces/java/src/org/apache/xerces/impl/dv/xs/SchemaDVFactoryImpl.java
Index: SchemaDVFactoryImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/SchemaDVFactoryImpl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SchemaDVFactoryImpl.java 3 Apr 2002 23:48:26 -0000 1.4
+++ SchemaDVFactoryImpl.java 19 Apr 2002 17:20:23 -0000 1.5
@@ -73,7 +73,7 @@
* @author Neeraj Bajaj, Sun Microsystems, inc.
* @author Sandy Gao, IBM
*
- * @version $Id: SchemaDVFactoryImpl.java,v 1.4 2002/04/03 23:48:26 elena Exp $
+ * @version $Id: SchemaDVFactoryImpl.java,v 1.5 2002/04/19 17:20:23 sandygao Exp $
*/
public class SchemaDVFactoryImpl extends SchemaDVFactory {
@@ -263,7 +263,7 @@
facets.fractionDigits = 0;
XSSimpleTypeDecl integerDV = new XSSimpleTypeDecl(decimalDV, INTEGER, URI_SCHEMAFORSCHEMA, (short)0);
- integerDV.applyFacets1(facets , XSSimpleType.FACET_FRACTIONDIGITS, (short)0);
+ integerDV.applyFacets1(facets , XSSimpleType.FACET_FRACTIONDIGITS, (short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_INTEGER);
types.put(INTEGER, integerDV);
facets.maxInclusive = "0";
@@ -357,12 +357,12 @@
facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
XSSimpleTypeDecl nameDV = new XSSimpleTypeDecl(tokenDV, NAME , URI_SCHEMAFORSCHEMA, (short)0);
- nameDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_TOKEN_NAME);
+ nameDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_NAME);
types.put(NAME, nameDV);
facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
XSSimpleTypeDecl ncnameDV = new XSSimpleTypeDecl(nameDV, NCNAME , URI_SCHEMAFORSCHEMA, (short)0) ;
- ncnameDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_TOKEN_NCNAME);
+ ncnameDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_NCNAME);
types.put(NCNAME, ncnameDV);
types.put(QNAME, new XSSimpleTypeDecl(anySimpleType, QNAME, XSSimpleTypeDecl.DV_QNAME, XSSimpleType.ORDERED_FALSE, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false));
@@ -389,7 +389,7 @@
facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
XSSimpleTypeDecl nmtokenDV = new XSSimpleTypeDecl(tokenDV, NMTOKEN, URI_SCHEMAFORSCHEMA, (short)0);
- nmtokenDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_TOKEN_NMTOKEN);
+ nmtokenDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_NMTOKEN);
types.put(NMTOKEN, nmtokenDV);
facets.minLength = 1;
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org