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/11/09 01:30:38 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes UnionDV.java SchemaDVFactoryImpl.java SchemaDateTimeException.java NewDVInterfaces.java ListDV.java IDREFDV.java IDDV.java EntityDV.java DurationDV.java DateDV.java DatatypeMessageProvider.java BooleanDV.java AnyURIDV.java AnySimpleDV.java YearMonthDV.java YearDV.java XSSimpleTypeDecl.java TypeValidator.java TimeDV.java StringDV.java QNameDV.java MonthDV.java MonthDayDV.java HexBinaryDV.java FloatDV.java DoubleDV.java DecimalDV.java DayDV.java DateTimeDV.java Base64BinaryDV.java AbstractDateTimeDV.java AbstractStringDV.java AbstractNumericDV.java

sandygao    01/11/08 16:30:38

  Modified:    java/src/org/apache/xerces/impl/v2/new_datatypes
                        YearMonthDV.java YearDV.java XSSimpleTypeDecl.java
                        TypeValidator.java TimeDV.java StringDV.java
                        QNameDV.java MonthDV.java MonthDayDV.java
                        HexBinaryDV.java FloatDV.java DoubleDV.java
                        DecimalDV.java DayDV.java DateTimeDV.java
                        Base64BinaryDV.java AbstractDateTimeDV.java
  Added:       java/src/org/apache/xerces/impl/v2/new_datatypes
                        UnionDV.java SchemaDVFactoryImpl.java
                        SchemaDateTimeException.java NewDVInterfaces.java
                        ListDV.java IDREFDV.java IDDV.java EntityDV.java
                        DurationDV.java DateDV.java
                        DatatypeMessageProvider.java BooleanDV.java
                        AnyURIDV.java AnySimpleDV.java
  Removed:     java/src/org/apache/xerces/impl/v2/new_datatypes
                        AbstractStringDV.java AbstractNumericDV.java
  Log:
  Making the new simple type design conform to a new set of interfaces.
  Not complete yet. And there are still open issues about the interfaces.
  
  Revision  Changes    Path
  1.2       +21 -32    xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/YearMonthDV.java
  
  Index: YearMonthDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/YearMonthDV.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- YearMonthDV.java	2001/10/04 21:02:50	1.1
  +++ YearMonthDV.java	2001/11/09 00:30:37	1.2
  @@ -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",
  @@ -57,43 +57,33 @@
   
   package org.apache.xerces.impl.v2.new_datatypes;
   
  -import org.apache.xerces.impl.v2.datatypes.InvalidDatatypeValueException;
  -import org.apache.xerces.impl.v2.datatypes.SchemaDateTimeException;
  -
   /**
    * Validator for <gYearMonth> datatype (W3C Schema Datatypes)
  - * 
  + *
    * @author Elena Litani
    * @author Gopal Sharma, SUN Microsystem Inc.
  + *
  + * @version $Id: YearMonthDV.java,v 1.2 2001/11/09 00:30:37 sandygao Exp $
    */
  -
   public class YearMonthDV extends AbstractDateTimeDV{
   
       /**
  -     @return Index of YearMonthDV
  -	*/
  -	public short getPrimitiveDV(){
  -		return XSSimpleTypeDecl.DV_GYEARMONTH;
  -    }
  -
  -    /**
        * Convert a string to a compiled form
  -	 * 
  -	 * @param  content The lexical representation of gYearMonth
  -	 * @return a valid and normalized gYearMonth object
  -	 */
  -	public Object  getCompiledValue(String content) throws InvalidDatatypeValueException{
  -			int[] date=null;
  -			try{
  -					date= parse(content, null);
  -			}catch(Exception ex){
  -			}
  -			return date;
  -	}
  +     *
  +     * @param  content The lexical representation of gYearMonth
  +     * @return a valid and normalized gYearMonth object
  +     */
  +    public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException{
  +        try{
  +            return parse(content, null);
  +        } catch(Exception ex){
  +            throw new InvalidDatatypeValueException("not a valid yearMonth");
  +        }
  +    }
   
       /**
        * Parses, validates and computes normalized version of gYearMonth object
  -     * 
  +     *
        * @param str    The lexical representation of gYearMonth object CCYY-MM
        *               with possible time zone Z or (-),(+)hh:mm
        * @param date   uninitialized date object
  @@ -114,15 +104,14 @@
           parseTimeZone (fEnd, date);
   
           //validate and normalize
  -        
  +
           validateDateTime(date);
  -        
  +
           if ( date[utc]!=0 && date[utc]!='Z' ) {
               normalize(date);
           }
           return date;
       }
  -
   
   }
   
  
  
  
  1.2       +23 -33    xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/YearDV.java
  
  Index: YearDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/YearDV.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- YearDV.java	2001/10/04 21:02:50	1.1
  +++ YearDV.java	2001/11/09 00:30:37	1.2
  @@ -5,7 +5,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
  @@ -13,7 +13,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
  @@ -21,7 +21,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,
  @@ -29,7 +29,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",
  @@ -60,44 +60,34 @@
   
   package org.apache.xerces.impl.v2.new_datatypes;
   
  -import org.apache.xerces.impl.v2.datatypes.InvalidDatatypeValueException;
  -import org.apache.xerces.impl.v2.datatypes.SchemaDateTimeException;
  -
   /**
    * Validator for <gYear> datatype (W3C Schema Datatypes)
  - * 
  + *
    * @author Elena Litani
    * @author Gopal Sharma, SUN Microsystem Inc.
  + *
  + * @version $Id: YearDV.java,v 1.2 2001/11/09 00:30:37 sandygao Exp $
    */
   
   public class YearDV extends AbstractDateTimeDV {
   
       /**
  -     @return Index of YearDV
  -	*/
  -
  -	public short getPrimitiveDV(){
  -		return XSSimpleTypeDecl.DV_GYEAR;
  +     * Convert a string to a compiled form
  +     *
  +     * @param  content The lexical representation of time
  +     * @return a valid and normalized time object
  +     */
  +    public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException{
  +        try{
  +            return parse(content, null);
  +        } catch(Exception ex){
  +            throw new InvalidDatatypeValueException("not a valid year");
  +        }
       }
   
  -	/**
  -     * Convert a string to a compiled form
  -	 * 
  -	 * @param  content The lexical representation of time
  -	 * @return a valid and normalized time object
  -	 */
  -	
  -	public Object  getCompiledValue(String content) throws InvalidDatatypeValueException{
  -			int[] date=null;
  -			try{
  -					date= parse(content, null);
  -			}catch(Exception ex){
  -			}
  -			return date;
  -	}
       /**
        * Parses, validates and computes normalized version of gYear object
  -     * 
  +     *
        * @param str    The lexical representation of year object CCYY
        *               with possible time zone Z or (-),(+)hh:mm
        * @param date   uninitialized date object
  @@ -127,13 +117,13 @@
               getTimeZone (date, sign);
           }
   
  -        //initialize values 
  +        //initialize values
           date[M]=MONTH;
           date[D]=1;
   
           //validate and normalize
  -        validateDateTime(date);                       
  -        
  +        validateDateTime(date);
  +
           if ( date[utc]!=0 && date[utc]!='Z' ) {
               normalize(date);
           }
  @@ -142,7 +132,7 @@
   
       /**
        * Converts year object representation to String
  -     * 
  +     *
        * @param date   year object
        * @return lexical representation of month: CCYY with optional time zone sign
        */
  
  
  
  1.5       +843 -1027 xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/XSSimpleTypeDecl.java
  
  Index: XSSimpleTypeDecl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/XSSimpleTypeDecl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XSSimpleTypeDecl.java	2001/10/25 20:36:00	1.4
  +++ XSSimpleTypeDecl.java	2001/11/09 00:30:37	1.5
  @@ -57,101 +57,52 @@
   
   package org.apache.xerces.impl.v2.new_datatypes;
   
  -import org.apache.xerces.impl.v2.XSTypeDecl;
  -import org.apache.xerces.impl.v2.datatypes.InvalidDatatypeValueException;
  -import org.apache.xerces.impl.v2.datatypes.DatatypeMessageProvider;
  -import org.apache.xerces.impl.v2.SchemaSymbols;
  -import org.apache.xerces.impl.v2.msg.XMLMessages;
  +import org.apache.xerces.impl.xs.XSTypeDecl;
   import org.apache.xerces.util.XMLChar;
  -import org.apache.xerces.impl.xs.util.XIntPool;
   import org.apache.xerces.impl.xs.util.XInt;
  -import org.apache.xerces.impl.v2.util.regex.RegularExpression;
  +import org.apache.xerces.impl.xpath.regex.RegularExpression;
   
  -import java.util.Hashtable;
   import java.util.Vector;
   import java.util.StringTokenizer;
  -import java.util.Enumeration;
  -import java.util.Locale;
   
  -
  -
   /**
  - * @version $Id: XSSimpleTypeDecl.java,v 1.4 2001/10/25 20:36:00 elena Exp $
  + * @author Sandy Gao, IBM
  + * @author Neeraj Bajaj, Sun Microsystems, inc.
  + *
  + * @version $Id: XSSimpleTypeDecl.java,v 1.5 2001/11/09 00:30:37 sandygao Exp $
    */
  -public class XSSimpleTypeDecl implements XSTypeDecl {
  +class XSSimpleTypeDecl implements XSAtomicSimpleType, XSListSimpleType, XSUnionSimpleType {
   
  -    public static final short INDEX_LENGTH         = 0;
  -    public static final short INDEX_MINLENGTH      = 1;
  -    public static final short INDEX_MAXLENGTH      = 2;
  -    public static final short INDEX_PATTERN        = 3;
  -    public static final short INDEX_ENUMERATION    = 4;
  -    public static final short INDEX_WHITESPACE     = 5;
  -    public static final short INDEX_MAXINCLUSIVE   = 6;
  -    public static final short INDEX_MAXEXCLUSIVE   = 7;
  -    public static final short INDEX_MINEXCLUSIVE   = 8;
  -    public static final short INDEX_MININCLUSIVE   = 9;
  -    public static final short INDEX_TOTALDIGITS    = 10;
  -    public static final short INDEX_FRACTIONDIGITS = 11;
  -    public static final short INDEX_TOKENTYPE      = 12;
  -
  -    public static final short FACET_PARAM_SIZE     = 13;
  -
  -    public static final short DEFINED_LENGTH         = 1<<0;
  -    public static final short DEFINED_MINLENGTH      = 1<<1;
  -    public static final short DEFINED_MAXLENGTH      = 1<<2;
  -    public static final short DEFINED_PATTERN        = 1<<3;
  -    public static final short DEFINED_ENUMERATION    = 1<<4;
  -    public static final short DEFINED_WHITESPACE     = 1<<5;
  -    public static final short DEFINED_MAXINCLUSIVE   = 1<<6;
  -    public static final short DEFINED_MAXEXCLUSIVE   = 1<<7;
  -    public static final short DEFINED_MINEXCLUSIVE   = 1<<8;
  -    public static final short DEFINED_MININCLUSIVE   = 1<<9;
  -    public static final short DEFINED_TOTALDIGITS    = 1<<10;
  -    public static final short DEFINED_FRACTIONDIGITS = 1<<11;
  -    public static final short DEFINED_TOKENTYPE      = 1<<12;
  -
  -    public static final short VARIETY_NON    = 0;
  -    public static final short VARIETY_ATOMIC = 1;
  -    public static final short VARIETY_LIST   = 2;
  -    public static final short VARIETY_UNION  = 3;
  -
  -    //REVISIT: trying to compile
  -    public static final short PRESERVE  = 0;
  -    public static final short COLLAPSE = 1;
  -    public static final short REPLACE = 2;
  -
  -    public static final short DV_ANYSIMPLETYPE = 0;
  -    public static final short DV_STRING        = 1;
  -    public static final short DV_BOOLEAN       = 2;
  -    public static final short DV_DECIMAL       = 3;
  -    public static final short DV_FLOAT         = 4;
  -    public static final short DV_DOUBLE        = 5;
  -    public static final short DV_DURATION      = 6;
  -    public static final short DV_DATETIME      = 7;
  -    public static final short DV_TIME          = 8;
  -    public static final short DV_DATE          = 9;
  -    public static final short DV_GYEARMONTH    = 10;
  -    public static final short DV_GYEAR         = 11;
  -    public static final short DV_GMONTHDAY     = 12;
  -    public static final short DV_GDAY          = 13;
  -    public static final short DV_GMONTH        = 14;
  -    public static final short DV_HEXBINARY     = 15;
  -    public static final short DV_BASE64BINARY  = 16;
  -    public static final short DV_ANYURI        = 17;
  -    public static final short DV_QNAME         = 18;
  -    public static final short DV_NOTATION      = 19;
  -    public static final short DV_ID            = 19;
  -    public static final short DV_IDREF         = 20;
  -    public static final short DV_ENTITY        = 21;
  -    public static final short DV_LIST          = 22;
  -    public static final short DV_UNION         = 23;
  +    static final String URI_SCHEMAFORSCHEMA = "http://www.w3.org/2001/XMLSchema";
   
  -    //REVISIT: check if it's required.
  -    protected static final short INDETERMINATE=2;
  +    static final short DV_ANYSIMPLETYPE = 0;
  +    static final short DV_STRING        = 1;
  +    static final short DV_BOOLEAN       = 2;
  +    static final short DV_DECIMAL       = 3;
  +    static final short DV_FLOAT         = 4;
  +    static final short DV_DOUBLE        = 5;
  +    static final short DV_DURATION      = 6;
  +    static final short DV_DATETIME      = 7;
  +    static final short DV_TIME          = 8;
  +    static final short DV_DATE          = 9;
  +    static final short DV_GYEARMONTH    = 10;
  +    static final short DV_GYEAR         = 11;
  +    static final short DV_GMONTHDAY     = 12;
  +    static final short DV_GDAY          = 13;
  +    static final short DV_GMONTH        = 14;
  +    static final short DV_HEXBINARY     = 15;
  +    static final short DV_BASE64BINARY  = 16;
  +    static final short DV_ANYURI        = 17;
  +    static final short DV_QNAME         = 18;
  +    static final short DV_NOTATION      = 18;   // notation use the same one as qname
  +    static final short DV_ID            = 19;
  +    static final short DV_IDREF         = 20;
  +    static final short DV_ENTITY        = 21;
  +    static final short DV_LIST          = 22;
  +    static final short DV_UNION         = 23;
   
       static final TypeValidator[] fDVs = {
  -/*
  -        new AnySimpleTypeDV(),
  +        new AnySimpleDV(),
           new StringDV(),
           new BooleanDV(),
           new DecimalDV(),
  @@ -170,980 +121,906 @@
           new Base64BinaryDV(),
           new AnyURIDV(),
           new QNameDV(),
  -        new NotationDV(),
  -        new IdDV(),
  -        new IdRefDV(),
  +        new IDDV(),
  +        new IDREFDV(),
           new EntityDV(),
           new ListDV(),
  -        new UnionDV(),
  -*/
  +        new UnionDV()
       };
  -
  -    //REVISIT: usage
  -    static XIntPool xIntPool = new XIntPool();
  -
  -    public static final XInt TOKEN_NONE        = xIntPool.getXInt(0);
  -    public static final XInt TOKEN_NAME        = xIntPool.getXInt(1);
  -    public static final XInt TOKEN_NCNAME      = xIntPool.getXInt(2);
  -    public static final XInt TOKEN_IDNAME      = xIntPool.getXInt(3);
  -    public static final XInt TOKEN_IDNCNAME    = xIntPool.getXInt(4);
  -    public static final XInt TOKEN_IDREFNAME   = xIntPool.getXInt(5);
  -    public static final XInt TOKEN_IDREFNCNAME = xIntPool.getXInt(6);
  -    public static final XInt TOKEN_ENTITY      = xIntPool.getXInt(7);
  -    public static final XInt TOKEN_NMTOKEN     = xIntPool.getXInt(8);
   
  -    private DatatypeMessageProvider fMessageProvider = new DatatypeMessageProvider();
  -    private Locale            fLocale  = null;
  -
  +    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_IDNAME      = 3;
  +    static final short SPECIAL_TOKEN_IDREFNAME   = 4;
  +    static final short SPECIAL_TOKEN_NCNAME      = 5;
  +    static final short SPECIAL_TOKEN_IDNCNAME    = 6;
  +    static final short SPECIAL_TOKEN_IDREFNCNAME = 7;
  +    static final short SPECIAL_TOKEN_ENTITY      = 8;
  +
  +    static final String[] SPECIAL_TOKEN_STRING   = {
  +        "NONE", "NMTOKEN", "Name", "ID(Name)", "IDREF(Name)",
  +        "NCName", "ID(NCName)", "IDREF(NCName)", "ENTITY(NCName)",
  +    };
   
  -    // REVISIT: we can have only one array
  -    private XSSimpleTypeDecl fBase;
  +    //private short fPrimitiveDV = -1;
       private XSSimpleTypeDecl fItemType;
  -    private XSSimpleTypeDecl [] fMemberTypes;
  +    private XSSimpleTypeDecl[] fMemberTypes;
   
       private String fTypeName;
       private String fTargetNamespace;
       private short fFinalSet = 0;
  -
  -    private int fBaseIdx = -1;
  -    private String fBaseUri;
  +    private XSSimpleTypeDecl fBase;
  +    private short fVariety = -1;
  +    private short fValidateDV = -1;
   
       private short fFacetsDefined = 0;
  -    private int fLength;
  -    private int fMinLength;
  -    private int fMaxLength;
  +    private short fFixedFacet = 0;
  +
  +    private short fWhiteSpace = 0;
  +    private int fLength = -1;
  +    private int fMinLength = -1;
  +    private int fMaxLength = -1;
  +    private int fTotalDigits = -1;
  +    private int fFractionDigits = -1;
  +    private short fTokenType = SPECIAL_TOKEN_NONE;
       private Vector fPattern;
  -    private Object fEnumeration[];
  -    private short fWhiteSpace;
  +    private Vector fEnumeration;
       private Object fMaxInclusive;
       private Object fMaxExclusive;
       private Object fMinExclusive;
       private Object fMinInclusive;
  -    private int fTotalDigits;
  -    private int fFractionDigits;
  -    private short fTokeyType = 0;
  -    private short fFixedFacet = 0;
  -    private short fVariety;
  -    private short fPrimitiveDV;
  -    private short fValidateDV;
  -    private int fFundFacets;
   
  -    public short getXSType () {
  -        return SIMPLE_TYPE;
  +    //Create a new built-in primitive types (and id/idref/entity)
  +    protected XSSimpleTypeDecl(XSSimpleTypeDecl base, String name, short validateDV) {
  +        fBase = base;
  +        fTypeName = name;
  +        fTargetNamespace = URI_SCHEMAFORSCHEMA;
  +        fVariety = VARIETY_ATOMIC;
  +        //fPrimitiveDV = validateDV;
  +        //if (validateDV == DV_ID || validateDV == DV_IDREF || validateDV == DV_ENTITY)
  +        //    fPrimitiveDV = DV_STRING;
  +        fValidateDV = validateDV;
  +        fFacetsDefined = FACET_WHITESPACE;
  +        if (validateDV == DV_STRING)
  +            fWhiteSpace = WS_PRESERVE;
  +        else
  +            fWhiteSpace = WS_COLLAPSE;
       }
   
  -    public String getXSTypeName() {
  -        return fTypeName;
  +    //Create a new simple type for restriction.
  +    protected XSSimpleTypeDecl(XSSimpleTypeDecl base, String name, String uri, short finalSet) {
  +        fBase = base;
  +        fTypeName = name;
  +        fTargetNamespace = uri;
  +        fFinalSet = finalSet;
  +
  +        fVariety = fBase.fVariety;
  +        fValidateDV = fBase.fValidateDV;
  +        switch (fVariety) {
  +        case VARIETY_ATOMIC:
  +            //fPrimitiveDV = fBase.fPrimitiveDV;
  +            break;
  +        case VARIETY_LIST:
  +            fItemType = fBase.fItemType;
  +            break;
  +        case VARIETY_UNION:
  +            fMemberTypes = fBase.fMemberTypes;
  +            break;
  +        }
       }
   
  +    //Create a new simple type for list.
  +    protected XSSimpleTypeDecl(XSSimpleTypeDecl base, String name, String uri, short finalSet, XSSimpleTypeDecl itemType) {
  +        fBase = base;
  +        fTypeName = name;
  +        fTargetNamespace = uri;
  +        fFinalSet = finalSet;
   
  +        fVariety = VARIETY_LIST;
  +        fItemType = (XSSimpleTypeDecl)itemType;
  +        fValidateDV = DV_LIST;
  +        fFacetsDefined = FACET_WHITESPACE;
  +        fWhiteSpace = WS_COLLAPSE;
  +    }
   
  -    //Create a new simple type.
  -    public XSSimpleTypeDecl(XSSimpleTypeDecl base, String name, String uri, short finalSet) {
  +    //Create a new simple type for union.
  +    protected XSSimpleTypeDecl(XSSimpleTypeDecl base, String name, String uri, short finalSet, XSSimpleTypeDecl[] memberTypes) {
  +        fBase = base;
           fTypeName = name;
           fTargetNamespace = uri;
           fFinalSet = finalSet;
  +
  +        fVariety = VARIETY_UNION;
  +        fMemberTypes = memberTypes;
  +        fValidateDV = DV_UNION;
  +        fFacetsDefined = FACET_WHITESPACE;
  +        fWhiteSpace = WS_COLLAPSE;
       }
   
  +    public short getXSType () {
  +        return XSTypeDecl.SIMPLE_TYPE;
  +    }
  +
  +    public String getXSTypeName() {
  +        return fTypeName;
  +    }
  +
  +    public String getXSTypeNamespace() {
  +        return fTargetNamespace;
  +    }
  +
  +    public short getFinalSet(){
  +        return fFinalSet;
  +    }
  +
  +    public XSSimpleType getBaseType(){
  +        return fBase;
  +    }
  +
  +    public short getVariety(){
  +        return fVariety;
  +    }
  +
  +    // REVISIT
  +    public XSSimpleType getPrimitiveType() {
  +        if (fVariety == VARIETY_ATOMIC)
  +            return null;
  +        else
  +            return null;
  +    }
  +
  +    // REVISIT
  +    public XSSimpleType getItemType() {
  +        if (fVariety == VARIETY_LIST)
  +            return fItemType;
  +        else
  +            return null;
  +    }
  +
  +    // REVISIT
  +    public XSSimpleType[] getMemberTypes() {
  +        if (fVariety == VARIETY_UNION)
  +            return fMemberTypes;
  +        else
  +            return null;
  +    }
  +
       /**
  -     * for built-in primitive types (and id/idref/entity)
  +     * If <restriction> is chosen, or built-in derived types by restriction
        */
  -    public void init4BuiltInType(short validateDV) {
  -        fVariety = VARIETY_ATOMIC;
  -        fPrimitiveDV = fDVs[validateDV].getPrimitiveDV();
  -        fValidateDV = validateDV;
  +    public void applyFacets(XSFacets facets, short presentFacet, short fixedFacet) {
  +        applyFacets(facets, presentFacet, fixedFacet, (short)0);
       }
   
       /**
        * If <restriction> is chosen, or built-in derived types by restriction
        */
  -    public void init4Restriction(XSSimpleTypeDecl base, Object[] facets,
  -                                 short presentFacet, short fixedFacet) {
  -        fVariety = base.fVariety;
  -        int result = 0 ;
  -        switch (fVariety) {
  -        case VARIETY_ATOMIC:
  -            fPrimitiveDV = base.fPrimitiveDV;
  -            fValidateDV = base.fValidateDV;
  -        break;
  -        case VARIETY_LIST:
  -            fItemType = base.fItemType;
  -            fValidateDV = DV_LIST;
  -        break;
  -        case VARIETY_UNION:
  -            fMemberTypes = base.fMemberTypes;
  -            fValidateDV = DV_UNION;
  -        break;
  -        }
  -
  -        // step 1: inherit fixed facets from base
  -        fFacetsDefined = fFixedFacet = base.fFixedFacet;
  -
  -        // length
  -        if ((fFixedFacet & DEFINED_LENGTH) != 0)
  -            fLength = base.fLength;
  -        // minLength
  -        if ((fFixedFacet & DEFINED_MINLENGTH) != 0)
  -            fMinLength = base.fMinLength;
  -        // maxLength
  -        if ((fFixedFacet & DEFINED_MAXLENGTH) != 0)
  -            fMaxLength = base.fMaxLength;
  -        // pattern
  -        if ((fFixedFacet & DEFINED_PATTERN) != 0)
  -            fPattern = base.fPattern;
  -        else
  -            fPattern = new Vector();
  -        // enumeration
  -        if ((fFixedFacet & DEFINED_ENUMERATION) != 0)
  -            fEnumeration = base.fEnumeration;
  -        // whiteSpace
  -        if ((fFixedFacet & DEFINED_WHITESPACE) != 0)
  -            fWhiteSpace = base.fWhiteSpace;
  -        // maxInclusive
  -        if ((fFixedFacet & DEFINED_MAXINCLUSIVE) != 0)
  -            fMaxInclusive = base.fMaxInclusive;
  -        // maxExclusive
  -        if ((fFixedFacet & DEFINED_MAXEXCLUSIVE) != 0)
  -            fMaxExclusive = base.fMaxExclusive;
  -        // minExclusive
  -        if ((fFixedFacet & DEFINED_MINEXCLUSIVE) != 0)
  -            fMinExclusive = base.fMinExclusive;
  -        // minInclusive
  -        if ((fFixedFacet & DEFINED_MININCLUSIVE) != 0)
  -            fMinInclusive = base.fMinInclusive;
  -        // totalDigits
  -        if ((fFixedFacet & DEFINED_TOTALDIGITS) != 0)
  -            fTotalDigits = base.fTotalDigits;
  -        // fractionDigits
  -        if ((fFixedFacet & DEFINED_FRACTIONDIGITS) != 0)
  -            fFractionDigits = base.fFractionDigits;
  -
  -        if (facets == null)
  +    void applyFacets(XSFacets facets, short presentFacet, short fixedFacet, short tokenType) {
  +        if (fFacetsDefined != 0)
               return;
   
  -        // step 2: parse present facets: check against base fixed
  +        int result = 0 ;
   
  +        // step 1: parse present facets
           short allowedFacet = fDVs[fValidateDV].getAllowedFacets();
   
           // length
  -        if ((presentFacet & DEFINED_LENGTH) != 0) {
  -            if ((allowedFacet & DEFINED_LENGTH) == 0) {
  +        if ((presentFacet & FACET_LENGTH) != 0) {
  +            if ((allowedFacet & FACET_LENGTH) == 0) {
                   reportError("non-supported facet");
  -            } else if ((fFixedFacet & DEFINED_LENGTH) == 0) {
  -                reportError("fixed facet in base");
               } else {
  -                fLength = ((Integer)facets[INDEX_LENGTH]).intValue();
  -                fFacetsDefined |= DEFINED_LENGTH;
  -                if ((fixedFacet & DEFINED_LENGTH) == 0)
  -                    fFixedFacet |= DEFINED_LENGTH;
  +                fLength = facets.length;
  +                fFacetsDefined |= FACET_LENGTH;
  +                if ((fixedFacet & FACET_LENGTH) != 0)
  +                    fFixedFacet |= FACET_LENGTH;
                   // check 4.3.1.c0 must: length >= 0
                   if (fLength < 0)
  -                    reportError("length value '"+facets[INDEX_LENGTH]+"' must be a nonNegativeInteger.");
  +                    reportError("length value '"+facets.length+"' must be a nonNegativeInteger.");
               }
           }
           // minLength
  -        if ((presentFacet & DEFINED_MINLENGTH) != 0) {
  -            if ((allowedFacet & DEFINED_MINLENGTH) == 0) {
  +        if ((presentFacet & FACET_MINLENGTH) != 0) {
  +            if ((allowedFacet & FACET_MINLENGTH) == 0) {
                   reportError("non-supported facet");
  -            } else if ((fFixedFacet & DEFINED_MINLENGTH) == 0) {
  -                reportError("fixed facet in base");
               } else {
  -                fMinLength = ((Integer)facets[INDEX_MINLENGTH]).intValue();
  -                fFacetsDefined |= DEFINED_MINLENGTH;
  -                if ((fixedFacet & DEFINED_MINLENGTH) == 0)
  -                    fFixedFacet |= DEFINED_MINLENGTH;
  +                fMinLength = facets.minLength;
  +                fFacetsDefined |= FACET_MINLENGTH;
  +                if ((fixedFacet & FACET_MINLENGTH) != 0)
  +                    fFixedFacet |= FACET_MINLENGTH;
                   // check 4.3.2.c0 must: minLength >= 0
                   if (fMinLength < 0)
  -                    reportError("minLength value '"+facets[INDEX_MINLENGTH]+"' must be a nonNegativeInteger.");
  +                    reportError("minLength value '"+facets.minLength+"' must be a nonNegativeInteger.");
               }
           }
           // maxLength
  -        if ((presentFacet & DEFINED_MAXLENGTH) != 0) {
  -            if ((allowedFacet & DEFINED_MAXLENGTH) == 0) {
  +        if ((presentFacet & FACET_MAXLENGTH) != 0) {
  +            if ((allowedFacet & FACET_MAXLENGTH) == 0) {
                   reportError("non-supported facet");
  -            } else if ((fFixedFacet & DEFINED_MAXLENGTH) == 0) {
  -                reportError("fixed facet in base");
               } else {
  -                fMaxLength = ((Integer)facets[INDEX_MAXLENGTH]).intValue();
  -                fFacetsDefined |= DEFINED_MAXLENGTH;
  -                if ((fixedFacet & DEFINED_MAXLENGTH) == 0)
  -                    fFixedFacet |= DEFINED_MAXLENGTH;
  +                fMaxLength = facets.maxLength;
  +                fFacetsDefined |= FACET_MAXLENGTH;
  +                if ((fixedFacet & FACET_MAXLENGTH) != 0)
  +                    fFixedFacet |= FACET_MAXLENGTH;
                   // check 4.3.3.c0 must: maxLength >= 0
                   if (fMaxLength < 0)
  -                    reportError("maxLength value '"+facets[INDEX_MAXLENGTH]+"' must be a nonNegativeInteger.");
  +                    reportError("maxLength value '"+facets.maxLength+"' must be a nonNegativeInteger.");
               }
           }
           // pattern
  -        if ((presentFacet & DEFINED_PATTERN) != 0) {
  -            if ((allowedFacet & DEFINED_PATTERN) == 0) {
  +        if ((presentFacet & FACET_PATTERN) != 0) {
  +            if ((allowedFacet & FACET_PATTERN) == 0) {
                   reportError("non-supported facet");
  -            } else if ((fFixedFacet & DEFINED_PATTERN) == 0) {
  -                reportError("fixed facet in base");
               } else {
  -                //REVISIT:
  -                //fPattern.addElement(new RegularExpression((String)facts[INDEX_PATTERN], "X"));
  -                fPattern.addElement(facets[INDEX_PATTERN]);
  -                fFacetsDefined |= DEFINED_PATTERN;
  -                if ((fixedFacet & DEFINED_PATTERN) == 0)
  -                    fFixedFacet |= DEFINED_PATTERN;
  +                fPattern = new Vector();
  +                fPattern.addElement(new RegularExpression(facets.patterh, "X"));
  +                fFacetsDefined |= FACET_PATTERN;
  +                if ((fixedFacet & FACET_PATTERN) != 0)
  +                    fFixedFacet |= FACET_PATTERN;
               }
           }
   
           // enumeration
  -        if ((presentFacet & DEFINED_ENUMERATION) != 0) {
  -            if ((allowedFacet & DEFINED_ENUMERATION) == 0) {
  +        if ((presentFacet & FACET_ENUMERATION) != 0) {
  +            if ((allowedFacet & FACET_ENUMERATION) == 0) {
                   reportError("non-supported facet");
  -            } else if ((fFixedFacet & DEFINED_ENUMERATION) == 0) {
  -                reportError("fixed facet in base");
               } else {
  -                String[] enumVals = (String[])facets[INDEX_ENUMERATION];
  -                fEnumeration = new Object[enumVals.length];
  -                for (int i = 0; i < fEnumeration.length; i++) {
  +                fEnumeration = new Vector();
  +                String[] enumVals = facets.enumeration;
  +                for (int i = enumVals.length-1; i >= 0; i--) {
                       try {
  -                        fEnumeration[i] = getCompiledValue(enumVals[i]);
  +                        fEnumeration.addElement(getActualValue(enumVals[i], null));
                       } catch (InvalidDatatypeValueException ide) {
                           reportError("Value of enumeration '" + enumVals[i] + "' must be from the value space of base");
  -                        fEnumeration[i] = SchemaSymbols.EMPTY_STRING;
                       }
                   }
  -                fFacetsDefined |= DEFINED_ENUMERATION;
  -                if ((fixedFacet & DEFINED_ENUMERATION) == 0)
  -                    fFixedFacet |= DEFINED_ENUMERATION;
  +                fFacetsDefined |= FACET_ENUMERATION;
  +                if ((fixedFacet & FACET_ENUMERATION) != 0)
  +                    fFixedFacet |= FACET_ENUMERATION;
               }
           }
           // whiteSpace
  -        if ((presentFacet & DEFINED_WHITESPACE) != 0) {
  -            if ((allowedFacet & DEFINED_WHITESPACE) == 0) {
  +        if ((presentFacet & FACET_WHITESPACE) != 0) {
  +            if ((allowedFacet & FACET_WHITESPACE) != 0) {
                   reportError("non-supported facet");
  -            } else if ((fFixedFacet & DEFINED_WHITESPACE) == 0) {
  -                reportError("fixed facet in base");
               } else {
  -                fWhiteSpace = ((Integer)facets[INDEX_WHITESPACE]).shortValue();
  -                fFacetsDefined |= DEFINED_WHITESPACE;
  -                if ((fixedFacet & DEFINED_WHITESPACE) == 0)
  -                    fFixedFacet |= DEFINED_WHITESPACE;
  +                fWhiteSpace = facets.whiteSpace;
  +                fFacetsDefined |= FACET_WHITESPACE;
  +                if ((fixedFacet & FACET_WHITESPACE) != 0)
  +                    fFixedFacet |= FACET_WHITESPACE;
               }
           }
           // maxInclusive
  -        if ((presentFacet & DEFINED_MAXINCLUSIVE) != 0) {
  -            if ((allowedFacet & DEFINED_MAXINCLUSIVE) == 0) {
  +        if ((presentFacet & FACET_MAXINCLUSIVE) != 0) {
  +            if ((allowedFacet & FACET_MAXINCLUSIVE) == 0) {
                   reportError("non-supported facet");
  -            } else if ((fFixedFacet & DEFINED_MAXINCLUSIVE) == 0) {
  -                reportError("fixed facet in base");
               } else {
                   try {
  -                    fMaxInclusive = getCompiledValue((String)facets[INDEX_MAXINCLUSIVE]);
  -                    fFacetsDefined |= DEFINED_MAXINCLUSIVE;
  -                    if ((fixedFacet & DEFINED_MAXINCLUSIVE) == 0)
  -                        fFixedFacet |= DEFINED_MAXINCLUSIVE;
  +                    fMaxInclusive = getActualValue(facets.maxInclusive, null);
  +                    fFacetsDefined |= FACET_MAXINCLUSIVE;
  +                    if ((fixedFacet & FACET_MAXINCLUSIVE) != 0)
  +                        fFixedFacet |= FACET_MAXINCLUSIVE;
                   } catch (InvalidDatatypeValueException ide) {
  -                    reportError("maxInclusive value '"+facets[INDEX_MAXINCLUSIVE]+"' is invalid.");
  +                    reportError("maxInclusive value '"+facets.maxInclusive+"' is invalid.");
                   }
               }
           }
           // maxExclusive
  -        if ((presentFacet & DEFINED_MAXEXCLUSIVE) != 0) {
  -            if ((allowedFacet & DEFINED_MAXEXCLUSIVE) == 0) {
  +        if ((presentFacet & FACET_MAXEXCLUSIVE) != 0) {
  +            if ((allowedFacet & FACET_MAXEXCLUSIVE) == 0) {
                   reportError("non-supported facet");
  -            } else if ((fFixedFacet & DEFINED_MAXEXCLUSIVE) == 0) {
  -                reportError("fixed facet in base");
               } else {
                   try {
  -                    fMaxExclusive = getCompiledValue((String)facets[INDEX_MAXEXCLUSIVE]);
  -                    fFacetsDefined |= DEFINED_MAXEXCLUSIVE;
  -                    if ((fixedFacet & DEFINED_MAXEXCLUSIVE) == 0)
  -                        fFixedFacet |= DEFINED_MAXEXCLUSIVE;
  +                    fMaxExclusive = getActualValue(facets.maxExclusive, null);
  +                    fFacetsDefined |= FACET_MAXEXCLUSIVE;
  +                    if ((fixedFacet & FACET_MAXEXCLUSIVE) != 0)
  +                        fFixedFacet |= FACET_MAXEXCLUSIVE;
                   } catch (InvalidDatatypeValueException ide) {
  -                    reportError("maxExclusive value '"+facets[INDEX_MAXEXCLUSIVE]+"' is invalid.");
  +                    reportError("maxExclusive value '"+facets.maxExclusive+"' is invalid.");
                   }
               }
           }
           // minExclusive
  -        if ((presentFacet & DEFINED_MINEXCLUSIVE) != 0) {
  -            if ((allowedFacet & DEFINED_MINEXCLUSIVE) == 0) {
  +        if ((presentFacet & FACET_MINEXCLUSIVE) != 0) {
  +            if ((allowedFacet & FACET_MINEXCLUSIVE) == 0) {
                   reportError("non-supported facet");
  -            } else if ((fFixedFacet & DEFINED_MINEXCLUSIVE) == 0) {
  -                reportError("fixed facet in base");
               } else {
                   try {
  -                    fMinExclusive = getCompiledValue((String)facets[INDEX_MINEXCLUSIVE]);
  -                    fFacetsDefined |= DEFINED_MINEXCLUSIVE;
  -                    if ((fixedFacet & DEFINED_MINEXCLUSIVE) == 0)
  -                        fFixedFacet |= DEFINED_MINEXCLUSIVE;
  +                    fMinExclusive = getActualValue(facets.minExclusive, null);
  +                    fFacetsDefined |= FACET_MINEXCLUSIVE;
  +                    if ((fixedFacet & FACET_MINEXCLUSIVE) != 0)
  +                        fFixedFacet |= FACET_MINEXCLUSIVE;
                   } catch (InvalidDatatypeValueException ide) {
  -                    reportError("minExclusive value '"+facets[INDEX_MINEXCLUSIVE]+"' is invalid.");
  +                    reportError("minExclusive value '"+facets.minExclusive+"' is invalid.");
                   }
               }
           }
           // minInclusive
  -        if ((presentFacet & DEFINED_MININCLUSIVE) != 0) {
  -            if ((allowedFacet & DEFINED_MININCLUSIVE) == 0) {
  +        if ((presentFacet & FACET_MININCLUSIVE) != 0) {
  +            if ((allowedFacet & FACET_MININCLUSIVE) == 0) {
                   reportError("non-supported facet");
  -            } else if ((fFixedFacet & DEFINED_MININCLUSIVE) == 0) {
  -                reportError("fixed facet in base");
               } else {
                   try {
  -                    fMinInclusive = getCompiledValue((String)facets[INDEX_MININCLUSIVE]);
  -                    fFacetsDefined |= DEFINED_MININCLUSIVE;
  -                    if ((fixedFacet & DEFINED_MININCLUSIVE) == 0)
  -                        fFixedFacet |= DEFINED_MININCLUSIVE;
  +                    fMinInclusive = getActualValue(facets.minInclusive, null);
  +                    fFacetsDefined |= FACET_MININCLUSIVE;
  +                    if ((fixedFacet & FACET_MININCLUSIVE) != 0)
  +                        fFixedFacet |= FACET_MININCLUSIVE;
                   } catch (InvalidDatatypeValueException ide) {
  -                    reportError("minInclusive value '"+facets[INDEX_MININCLUSIVE]+"' is invalid.");
  +                    reportError("minInclusive value '"+facets.minInclusive+"' is invalid.");
                   }
               }
           }
           // totalDigits
  -        if ((presentFacet & DEFINED_TOTALDIGITS) != 0) {
  -            if ((allowedFacet & DEFINED_TOTALDIGITS) == 0) {
  +        if ((presentFacet & FACET_TOTALDIGITS) != 0) {
  +            if ((allowedFacet & FACET_TOTALDIGITS) == 0) {
                   reportError("non-supported facet");
  -            } else if ((fFixedFacet & DEFINED_TOTALDIGITS) == 0) {
  -                reportError("fixed facet in base");
               } else {
  -                fTotalDigits = ((Integer)facets[INDEX_TOTALDIGITS]).intValue();
  -                fFacetsDefined |= DEFINED_TOTALDIGITS;
  -                if ((fixedFacet & DEFINED_TOTALDIGITS) == 0)
  -                    fFixedFacet |= DEFINED_TOTALDIGITS;
  +                fTotalDigits = facets.totalDigits;
  +                fFacetsDefined |= FACET_TOTALDIGITS;
  +                if ((fixedFacet & FACET_TOTALDIGITS) != 0)
  +                    fFixedFacet |= FACET_TOTALDIGITS;
                   // check 4.3.11.c0 must: totalDigits > 0
                   if (fTotalDigits <= 0)
  -                    reportError("totalDigits value '"+facets[INDEX_TOTALDIGITS]+"' must be a positiveInteger.");
  +                    reportError("totalDigits value '"+facets.totalDigits+"' must be a positiveInteger.");
               }
           }
           // fractionDigits
  -        if ((presentFacet & DEFINED_FRACTIONDIGITS) != 0) {
  -            if ((allowedFacet & DEFINED_FRACTIONDIGITS) == 0) {
  +        if ((presentFacet & FACET_FRACTIONDIGITS) != 0) {
  +            if ((allowedFacet & FACET_FRACTIONDIGITS) == 0) {
                   reportError("non-supported facet");
  -            } else if ((fFixedFacet & DEFINED_FRACTIONDIGITS) == 0) {
  -                reportError("fixed facet in base");
               } else {
  -                fFractionDigits = ((Integer)facets[INDEX_FRACTIONDIGITS]).intValue();
  -                fFacetsDefined |= DEFINED_FRACTIONDIGITS;
  -                if ((fixedFacet & DEFINED_FRACTIONDIGITS) == 0)
  -                    fFixedFacet |= DEFINED_FRACTIONDIGITS;
  +                fFractionDigits = facets.fractionDigits;
  +                fFacetsDefined |= FACET_FRACTIONDIGITS;
  +                if ((fixedFacet & FACET_FRACTIONDIGITS) != 0)
  +                    fFixedFacet |= FACET_FRACTIONDIGITS;
                   // check 4.3.12.c0 must: fractionDigits >= 0
                   if (fFractionDigits < 0)
  -                    reportError("fractionDigits value '"+facets[INDEX_FRACTIONDIGITS]+"' must be a positiveInteger.");
  +                    reportError("fractionDigits value '"+facets.fractionDigits+"' must be a positiveInteger.");
               }
           }
  +
           // token type: internal use, so do less checking
  -        if ((presentFacet & DEFINED_TOKENTYPE) != 0) {
  -            fTokeyType = ((Integer)facets[INDEX_TOKENTYPE]).shortValue();
  -            fFacetsDefined |= DEFINED_TOKENTYPE;
  +        if (tokenType != SPECIAL_TOKEN_NONE) {
  +            fTokenType = tokenType;
           }
  -
   
  -        // step 3: check facets against each other: length, bounds
  +        // step 2: check facets against each other: length, bounds
   
  -        if(fFacetsDefined != 0){
  +        if(fFacetsDefined != 0) {
   
               // check 4.3.1.c1 error: length & (maxLength | minLength)
  -            if((fFacetsDefined & DEFINED_LENGTH) != 0 ){
  -              if( (fFacetsDefined & DEFINED_MINLENGTH) != 0 ){
  +            if((fFacetsDefined & FACET_LENGTH) != 0 ){
  +              if( (fFacetsDefined & FACET_MINLENGTH) != 0 ){
                   reportError("it is an error for both length and min length to be present." );
                 }
  -              else if((fFacetsDefined & DEFINED_MAXLENGTH) != 0 ){
  +              else if((fFacetsDefined & FACET_MAXLENGTH) != 0 ){
                   reportError("it is an error for both length and max length to be present." );
                 }
               }
   
               // check 4.3.2.c1 must: minLength <= maxLength
  -            if(((fFacetsDefined & DEFINED_MINLENGTH ) != 0 ) && ((fFacetsDefined & DEFINED_MAXLENGTH) != 0))
  +            if(((fFacetsDefined & FACET_MINLENGTH ) != 0 ) && ((fFacetsDefined & FACET_MAXLENGTH) != 0))
               {
                 if(fMinLength > fMaxLength)
                   reportError("value of minLength = " + fMinLength + "must  be less than value of maxLength = "+ fMaxLength);
               }
   
               // check 4.3.8.c1 error: maxInclusive + maxExclusive
  -            if (((fFacetsDefined & DEFINED_MAXEXCLUSIVE) != 0) && ((fFacetsDefined & DEFINED_MAXINCLUSIVE) != 0)) {
  +            if (((fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) && ((fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
                   reportError( "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 & DEFINED_MINEXCLUSIVE) != 0) &&
  -              ((fFacetsDefined & DEFINED_MININCLUSIVE) != 0)) {
  +            if (((fFacetsDefined & FACET_MINEXCLUSIVE) != 0) &&
  +              ((fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
                   reportError("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 &  DEFINED_MAXINCLUSIVE) != 0) &&
  -            ((fFacetsDefined & DEFINED_MININCLUSIVE) != 0)) {
  -              result =  fDVs[fValidateDV].compare(fMinInclusive, fMaxInclusive);
  -              if (result == 1 || result == INDETERMINATE){
  +            if (((fFacetsDefined &  FACET_MAXINCLUSIVE) != 0) &&
  +            ((fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
  +              if (fDVs[fValidateDV].compare(fMinInclusive, fMaxInclusive) == 1)
                   reportError("minInclusive value ='" + getStringValue(fMinInclusive) + "'must be <= maxInclusive value ='" +
                       getStringValue(fMaxInclusive) + "'. " );
  -              }
               }
   
               // check 4.3.8.c2 must: minExclusive <= maxExclusive ??? minExclusive < maxExclusive
  -            if (((fFacetsDefined & DEFINED_MAXEXCLUSIVE) != 0) && ((fFacetsDefined & DEFINED_MINEXCLUSIVE) != 0)) {
  -              result =  fDVs[fValidateDV].compare(fMinExclusive, fMaxExclusive);
  -              if (result == 1 || result == INDETERMINATE)
  +            if (((fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) && ((fFacetsDefined & FACET_MINEXCLUSIVE) != 0)) {
  +              if (fDVs[fValidateDV].compare(fMinExclusive, fMaxExclusive) == 1)
                   reportError( "minExclusive value ='" + getStringValue(fMinExclusive) + "'must be <= maxExclusive value ='" +
                                                           getStringValue(fMaxExclusive) + "'. " );
               }
   
               // check 4.3.9.c2 must: minExclusive < maxInclusive
  -            if (((fFacetsDefined & DEFINED_MAXINCLUSIVE) != 0) && ((fFacetsDefined & DEFINED_MINEXCLUSIVE) != 0)) {
  +            if (((fFacetsDefined & FACET_MAXINCLUSIVE) != 0) && ((fFacetsDefined & FACET_MINEXCLUSIVE) != 0)) {
                 if (fDVs[fValidateDV].compare(fMinExclusive, fMaxInclusive) != -1)
                   reportError( "minExclusive value ='" + getStringValue(fMinExclusive) + "'must be > maxInclusive value ='" +
                                                                        getStringValue(fMaxInclusive) + "'. " );
               }
   
               // check 4.3.10.c1 must: minInclusive < maxExclusive
  -            if (((fFacetsDefined & DEFINED_MAXEXCLUSIVE) != 0) && ((fFacetsDefined & DEFINED_MININCLUSIVE) != 0)) {
  +            if (((fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) && ((fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
                 if (fDVs[fValidateDV].compare(fMinInclusive, fMaxExclusive) != -1)
                   reportError( "minInclusive value ='" + getStringValue(fMinInclusive) + "'must be < maxExclusive value ='" +
                                                                        getStringValue(fMaxExclusive) + "'. " );
               }
   
               // check 4.3.12.c1 must: fractionDigits <= totalDigits
  -            if (((fFacetsDefined & DEFINED_FRACTIONDIGITS) != 0) &&
  -                ((fFacetsDefined & DEFINED_TOTALDIGITS) != 0)) {
  +            if (((fFacetsDefined & FACET_FRACTIONDIGITS) != 0) &&
  +                ((fFacetsDefined & FACET_TOTALDIGITS) != 0)) {
                   if (fFractionDigits > fTotalDigits)
                       reportError( "fractionDigits value ='" + this.fFractionDigits + "'must be <= totalDigits value ='" +
                                                                this.fTotalDigits + "'. " );
               }
   
               // step 4: check facets against base
  -            if (base != null) {
  +            // check 4.3.1.c1 error: length & (fBase.maxLength | fBase.minLength)
  +            if ( ((fFacetsDefined & FACET_LENGTH ) != 0 ) ) {
   
  -                // check 4.3.1.c1 error: length & (base.maxLength | base.minLength)
  -                if ( ((fFacetsDefined & DEFINED_LENGTH ) != 0 ) ) {
  +                if ( ((fBase.fFacetsDefined & FACET_MAXLENGTH ) != 0 ) ) {
  +                    reportError("It is an error for both length and maxLength to be members of facets." );
  +                }
  +                else if ( ((fBase.fFacetsDefined & FACET_MINLENGTH ) != 0 ) ) {
  +                    reportError("It is an error for both length and minLength to be members of facets." );
  +                }
  +                else if ( (fBase.fFacetsDefined & FACET_LENGTH) != 0 ) {
  +                    // check 4.3.1.c2 error: length != fBase.length
  +                    if ( fLength != fBase.fLength )
  +                        reportError( "Value of length = '" + fLength +
  +                                                                 "' must be = the value of fBase.length = '" + fBase.fLength + "'.");
  +                }
  +            }
   
  -                    if ( ((base.fFacetsDefined & DEFINED_MAXLENGTH ) != 0 ) ) {
  -                        reportError("It is an error for both length and maxLength to be members of facets." );
  +            // check 4.3.1.c1 error: fBase.length & (maxLength | minLength)
  +            if ( ((fBase.fFacetsDefined & FACET_LENGTH ) != 0 ) ) {
  +                if ( ((fFacetsDefined & FACET_MAXLENGTH ) != 0 ) ) {
  +                    reportError("It is an error for both length and maxLength to be members of facets." );
  +                }
  +                else if ( ((fFacetsDefined & FACET_MINLENGTH ) != 0 ) ) {
  +                    reportError("It is an error for both length and minLength to be members of facets." );
  +                }
  +            }
  +
  +
  +
  +            // check 4.3.2.c1 must: minLength <= fBase.maxLength
  +            if ( ((fFacetsDefined & FACET_MINLENGTH ) != 0 ) ) {
  +                if ( (fBase.fFacetsDefined & FACET_MAXLENGTH ) != 0 ) {
  +                    if ( fMinLength > fBase.fMaxLength ) {
  +                        reportError( "Value of minLength = '" + fMinLength +
  +                                                                 "'must be <= the value of maxLength = '" + fMaxLength + "'.");
                       }
  -                    else if ( ((base.fFacetsDefined & DEFINED_MINLENGTH ) != 0 ) ) {
  -                        reportError("It is an error for both length and minLength to be members of facets." );
  +                }
  +                else if ( (fBase.fFacetsDefined & FACET_MINLENGTH) != 0 ) {
  +                    if ( (fBase.fFixedFacet & FACET_MINLENGTH) != 0 && fMinLength != fBase.fMinLength ) {
  +                        reportError( "minLength value = '" + fMinLength +
  +                                                                 "' must be equal to fBase.minLength value = '" +
  +                                                                 fBase.fMinLength + "' with attribute {fixed} = true" );
                       }
  -                    else if ( (base.fFacetsDefined & DEFINED_LENGTH) != 0 ) {
  -                        // check 4.3.1.c2 error: length != base.length
  -                        if ( fLength != base.fLength )
  -                            reportError( "Value of length = '" + fLength +
  -                                                                     "' must be = the value of base.length = '" + base.fLength + "'.");
  +
  +                    // check 4.3.2.c2 error: minLength < fBase.minLength
  +                    if ( fMinLength < fBase.fMinLength ) {
  +                        reportError( "Value of minLength = '" + fMinLength +
  +                                                                 "' must be >= the value of fBase.minLength = '" + fBase.fMinLength + "'.");
                       }
                   }
  +            }
  +
  +
  +            // check 4.3.2.c1 must: maxLength < fBase.minLength
  +            if ( ((fFacetsDefined & FACET_MAXLENGTH ) != 0 ) && ((fBase.fFacetsDefined & FACET_MINLENGTH ) != 0 ))
  +            {
  +                if ( fMaxLength < fBase.fMinLength) {
  +                    reportError( "Value of maxLength = '" + fMaxLength +
  +                                                             "'must be >= the value of fBase.minLength = '" + fBase.fMinLength + "'.");
  +                }
  +            }
   
  -                // check 4.3.1.c1 error: base.length & (maxLength | minLength)
  -                if ( ((base.fFacetsDefined & DEFINED_LENGTH ) != 0 ) ) {
  -                    if ( ((fFacetsDefined & DEFINED_MAXLENGTH ) != 0 ) ) {
  -                        reportError("It is an error for both length and maxLength to be members of facets." );
  +            // check 4.3.3.c1 error: maxLength > fBase.maxLength
  +            if ( (fFacetsDefined & FACET_MAXLENGTH) != 0 ) {
  +                if ( (fBase.fFacetsDefined & FACET_MAXLENGTH) != 0 ){
  +                    if(( (fBase.fFixedFacet & FACET_MAXLENGTH) != 0 )&& fMaxLength != fBase.fMaxLength ) {
  +                        reportError( "maxLength value = '" + fMaxLength +
  +                                                             "' must be equal to fBase.maxLength value = '" +
  +                                                             fBase.fMaxLength + "' with attribute {fixed} = true" );
                       }
  -                    else if ( ((fFacetsDefined & DEFINED_MINLENGTH ) != 0 ) ) {
  -                        reportError("It is an error for both length and minLength to be members of facets." );
  +                    if ( fMaxLength > fBase.fMaxLength ) {
  +                        reportError( "Value of maxLength = '" + fMaxLength +
  +                                                                 "' must be <= the value of fBase.maxLength = '" + fBase.fMaxLength + "'.");
                       }
                   }
  +            }
  +
   
  +            // check 4.3.7.c2 error:
  +            // maxInclusive > fBase.maxInclusive
  +            // maxInclusive >= fBase.maxExclusive
  +            // maxInclusive < fBase.minInclusive
  +            // maxInclusive <= fBase.minExclusive
   
  +            if (((fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
  +                if (((fBase.fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
  +                    result = fDVs[fValidateDV].compare(fMaxInclusive, fBase.fMaxInclusive);
   
  -                // check 4.3.2.c1 must: minLength <= base.maxLength
  -                if ( ((fFacetsDefined & DEFINED_MINLENGTH ) != 0 ) ) {
  -                    if ( (base.fFacetsDefined & DEFINED_MAXLENGTH ) != 0 ) {
  -                        if ( fMinLength > base.fMaxLength ) {
  -                            reportError( "Value of minLength = '" + fMinLength +
  -                                                                     "'must be <= the value of maxLength = '" + fMaxLength + "'.");
  -                        }
  +                    if ((fBase.fFixedFacet & FACET_MAXINCLUSIVE) != 0 &&
  +                        result != 0) {
  +                            reportError( "maxInclusive value = '" + getStringValue(fMaxInclusive) +
  +                                                                 "' must be equal to fBase.maxInclusive value = '" +
  +                                                                 getStringValue(fBase.fMaxInclusive) + "' with attribute {fixed} = true" );
                       }
  -                    else if ( (base.fFacetsDefined & DEFINED_MINLENGTH) != 0 ) {
  -                        if ( (base.fFixedFacet & DEFINED_MINLENGTH) != 0 && fMinLength != base.fMinLength ) {
  -                            reportError( "minLength value = '" + fMinLength +
  -                                                                     "' must be equal to base.minLength value = '" +
  -                                                                     base.fMinLength + "' with attribute {fixed} = true" );
  -                        }
  +                    if (result == 1) {
  +                        reportError( "maxInclusive value ='" + getStringValue(fMaxInclusive) + "' must be <= fBase.maxInclusive value ='" +
  +                                                                 getStringValue(fBase.fMaxInclusive) + "'." );
  +                    }
  +                }
  +                if (((fBase.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) &&
  +                    fDVs[fValidateDV].compare(fMaxInclusive, fBase.fMaxExclusive) != -1){
  +                        reportError(
  +                                                           "maxInclusive value ='" + getStringValue(fMaxInclusive) + "' must be < fBase.maxExclusive value ='" +
  +                                                           getStringValue(fBase.fMaxExclusive) + "'." );
  +                }
   
  -                        // check 4.3.2.c2 error: minLength < base.minLength
  -                        if ( fMinLength < base.fMinLength ) {
  -                            reportError( "Value of minLength = '" + fMinLength +
  -                                                                     "' must be >= the value of base.minLength = '" + base.fMinLength + "'.");
  -                        }
  +                if ((( fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
  +                    result = fDVs[fValidateDV].compare(fMaxInclusive, fBase.fMinInclusive);
  +                    if (result == -1) {
  +                        reportError( "maxInclusive value ='" + getStringValue(fMaxInclusive) + "' must be >= fBase.minInclusive value ='" +
  +                                                                 getStringValue(fBase.fMinInclusive) + "'." );
                       }
                   }
   
  +                if ((( fBase.fFacetsDefined & FACET_MINEXCLUSIVE) != 0) &&
  +                    fDVs[fValidateDV].compare(fMaxInclusive, fBase.fMinExclusive ) != 1)
  +                    reportError(
  +                                                           "maxInclusive value ='" + getStringValue(fMaxInclusive) + "' must be > fBase.minExclusive value ='" +
  +                                                           getStringValue(fBase.fMinExclusive) + "'." );
  +            }
  +
  +            // check 4.3.8.c3 error:
  +            // maxExclusive > fBase.maxExclusive
  +            // maxExclusive > fBase.maxInclusive
  +            // maxExclusive <= fBase.minInclusive
  +            // maxExclusive <= fBase.minExclusive
  +            if (((fFacetsDefined & FACET_MAXEXCLUSIVE) != 0)) {
  +                if ((( fBase.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0)) {
  +                    result= fDVs[fValidateDV].compare(fMaxExclusive, fBase.fMaxExclusive);
   
  -                // check 4.3.2.c1 must: maxLength < base.minLength
  -                if ( ((fFacetsDefined & DEFINED_MAXLENGTH ) != 0 ) && ((base.fFacetsDefined & DEFINED_MINLENGTH ) != 0 ))
  -                {
  -                    if ( fMaxLength < base.fMinLength) {
  -                        reportError( "Value of maxLength = '" + fMaxLength +
  -                                                                 "'must be >= the value of base.minLength = '" + base.fMinLength + "'.");
  +                    if ((fBase.fFixedFacet & FACET_MAXEXCLUSIVE) != 0 &&  result != 0) {
  +                        reportError( "maxExclusive value = '" + getStringValue(fMaxExclusive) +
  +                                                                 "' must be equal to fBase.maxExclusive value = '" +
  +                                                                 getStringValue(fBase.fMaxExclusive) + "' with attribute {fixed} = true" );
  +                    }
  +                    if (result == 1) {
  +                        reportError( "maxExclusive value ='" + getStringValue(fMaxExclusive) + "' must be < fBase.maxExclusive value ='" +
  +                                                                 getStringValue(fBase.fMaxExclusive) + "'." );
                       }
                   }
   
  -                // check 4.3.3.c1 error: maxLength > base.maxLength
  -                if ( (fFacetsDefined & DEFINED_MAXLENGTH) != 0 ) {
  -                    if ( (base.fFacetsDefined & DEFINED_MAXLENGTH) != 0 ){
  -                        if(( (base.fFixedFacet & DEFINED_MAXLENGTH) != 0 )&& fMaxLength != base.fMaxLength ) {
  -                            reportError( "maxLength value = '" + fMaxLength +
  -                                                                 "' must be equal to base.maxLength value = '" +
  -                                                                 base.fMaxLength + "' with attribute {fixed} = true" );
  -                        }
  -                        if ( fMaxLength > base.fMaxLength ) {
  -                            reportError( "Value of maxLength = '" + fMaxLength +
  -                                                                     "' must be <= the value of base.maxLength = '" + base.fMaxLength + "'.");
  -                        }
  +                if ((( fBase.fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
  +                    result= fDVs[fValidateDV].compare(fMaxExclusive, fBase.fMaxInclusive);
  +                    if (result == 1) {
  +                        reportError( "maxExclusive value ='" + getStringValue(fMaxExclusive) + "' must be <= fBase.maxInclusive value ='" +
  +                                                                 getStringValue(fBase.fMaxInclusive) + "'." );
                       }
                   }
   
  +                if ((( fBase.fFacetsDefined & FACET_MINEXCLUSIVE) != 0) &&
  +                    fDVs[fValidateDV].compare(fMaxExclusive, fBase.fMinExclusive ) != 1)
  +                    reportError( "maxExclusive value ='" + getStringValue(fMaxExclusive) + "' must be > fBase.minExclusive value ='" +
  +                                                             getStringValue(fBase.fMinExclusive) + "'." );
  +
  +                if ((( fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0) &&
  +                    fDVs[fValidateDV].compare(fMaxExclusive, fBase.fMinInclusive) != 1)
  +                    reportError( "maxExclusive value ='" + getStringValue(fMaxExclusive) + "' must be > fBase.minInclusive value ='" +
  +                                                             getStringValue(fBase.fMinInclusive) + "'." );
  +            }
  +
  +            // check 4.3.9.c3 error:
  +            // minExclusive < fBase.minExclusive
  +            // maxInclusive > fBase.maxInclusive
  +            // minInclusive < fBase.minInclusive
  +            // maxExclusive >= fBase.maxExclusive
  +            if (((fFacetsDefined & FACET_MINEXCLUSIVE) != 0)) {
  +                if ((( fBase.fFacetsDefined & FACET_MINEXCLUSIVE) != 0)) {
   
  -                // check 4.3.7.c2 error:
  -                // maxInclusive > base.maxInclusive
  -                // maxInclusive >= base.maxExclusive
  -                // maxInclusive < base.minInclusive
  -                // maxInclusive <= base.minExclusive
  -
  -                if (((fFacetsDefined & DEFINED_MAXINCLUSIVE) != 0)) {
  -                    if (((base.fFacetsDefined & DEFINED_MAXINCLUSIVE) != 0)) {
  -                        result = fDVs[fValidateDV].compare(fMaxInclusive, base.fMaxInclusive);
  -
  -                        if ((base.fFixedFacet & DEFINED_MAXINCLUSIVE) != 0 &&
  -                            result != 0) {
  -                                reportError( "maxInclusive value = '" + getStringValue(fMaxInclusive) +
  -                                                                     "' must be equal to base.maxInclusive value = '" +
  -                                                                     getStringValue(base.fMaxInclusive) + "' with attribute {fixed} = true" );
  -                        }
  -                        if (result == 1 || result == INDETERMINATE) {
  -                            reportError( "maxInclusive value ='" + getStringValue(fMaxInclusive) + "' must be <= base.maxInclusive value ='" +
  -                                                                     getStringValue(base.fMaxInclusive) + "'." );
  -                        }
  -                    }
  -                    if (((base.fFacetsDefined & DEFINED_MAXEXCLUSIVE) != 0) &&
  -                        fDVs[fValidateDV].compare(fMaxInclusive, base.fMaxExclusive) != -1){
  -                            reportError(
  -                                                               "maxInclusive value ='" + getStringValue(fMaxInclusive) + "' must be < base.maxExclusive value ='" +
  -                                                               getStringValue(base.fMaxExclusive) + "'." );
  -                    }
  -
  -                    if ((( base.fFacetsDefined & DEFINED_MININCLUSIVE) != 0)) {
  -                        result = fDVs[fValidateDV].compare(fMaxInclusive, base.fMinInclusive);
  -                        if (result == -1 || result == INDETERMINATE) {
  -                            reportError( "maxInclusive value ='" + getStringValue(fMaxInclusive) + "' must be >= base.minInclusive value ='" +
  -                                                                     getStringValue(base.fMinInclusive) + "'." );
  -                        }
  +                    result= fDVs[fValidateDV].compare(fMinExclusive, fBase.fMinExclusive);
  +                    if ((fBase.fFixedFacet & FACET_MINEXCLUSIVE) != 0 &&
  +                        result != 0) {
  +                        reportError( "minExclusive value = '" + getStringValue(fMinExclusive) +
  +                                                                 "' must be equal to fBase.minExclusive value = '" +
  +                                                                 getStringValue(fBase.fMinExclusive) + "' with attribute {fixed} = true" );
                       }
  +                    if (result == -1) {
  +                        reportError( "minExclusive value ='" + getStringValue(fMinExclusive) + "' must be >= fBase.minExclusive value ='" +
  +                                                                 getStringValue(fBase.fMinExclusive) + "'." );
  +                    }
  +                }
  +
  +                if ((( fBase.fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
  +                    result=fDVs[fValidateDV].compare(fMinExclusive, fBase.fMaxInclusive);
   
  -                    if ((( base.fFacetsDefined & DEFINED_MINEXCLUSIVE) != 0) &&
  -                        fDVs[fValidateDV].compare(fMaxInclusive, base.fMinExclusive ) != 1)
  +                    if (result == 1) {
                           reportError(
  -                                                               "maxInclusive value ='" + getStringValue(fMaxInclusive) + "' must be > base.minExclusive value ='" +
  -                                                               getStringValue(base.fMinExclusive) + "'." );
  +                                                               "minExclusive value ='" + getStringValue(fMinExclusive) + "' must be <= fBase.maxInclusive value ='" +
  +                                                               getStringValue(fBase.fMaxInclusive) + "'." );
  +                    }
                   }
  +
  +                if ((( fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
  +                    result = fDVs[fValidateDV].compare(fMinExclusive, fBase.fMinInclusive);
   
  -                // check 4.3.8.c3 error:
  -                // maxExclusive > base.maxExclusive
  -                // maxExclusive > base.maxInclusive
  -                // maxExclusive <= base.minInclusive
  -                // maxExclusive <= base.minExclusive
  -                if (((fFacetsDefined & DEFINED_MAXEXCLUSIVE) != 0)) {
  -                    if ((( base.fFacetsDefined & DEFINED_MAXEXCLUSIVE) != 0)) {
  -                        result= fDVs[fValidateDV].compare(fMaxExclusive, base.fMaxExclusive);
  -
  -                        if ((base.fFixedFacet & DEFINED_MAXEXCLUSIVE) != 0 &&  result != 0) {
  -                            reportError( "maxExclusive value = '" + getStringValue(fMaxExclusive) +
  -                                                                     "' must be equal to base.maxExclusive value = '" +
  -                                                                     getStringValue(base.fMaxExclusive) + "' with attribute {fixed} = true" );
  -                        }
  -                        if (result == 1 || result == INDETERMINATE) {
  -                            reportError( "maxExclusive value ='" + getStringValue(fMaxExclusive) + "' must be < base.maxExclusive value ='" +
  -                                                                     getStringValue(base.fMaxExclusive) + "'." );
  -                        }
  -                    }
  -
  -                    if ((( base.fFacetsDefined & DEFINED_MAXINCLUSIVE) != 0)) {
  -                        result= fDVs[fValidateDV].compare(fMaxExclusive, base.fMaxInclusive);
  -                        if (result == 1 || result == INDETERMINATE) {
  -                            reportError( "maxExclusive value ='" + getStringValue(fMaxExclusive) + "' must be <= base.maxInclusive value ='" +
  -                                                                     getStringValue(base.fMaxInclusive) + "'." );
  -                        }
  -                    }
  -
  -                    if ((( base.fFacetsDefined & DEFINED_MINEXCLUSIVE) != 0) &&
  -                        fDVs[fValidateDV].compare(fMaxExclusive, base.fMinExclusive ) != 1)
  -                        reportError( "maxExclusive value ='" + getStringValue(fMaxExclusive) + "' must be > base.minExclusive value ='" +
  -                                                                 getStringValue(base.fMinExclusive) + "'." );
  -
  -                    if ((( base.fFacetsDefined & DEFINED_MININCLUSIVE) != 0) &&
  -                        fDVs[fValidateDV].compare(fMaxExclusive, base.fMinInclusive) != 1)
  -                        reportError( "maxExclusive value ='" + getStringValue(fMaxExclusive) + "' must be > base.minInclusive value ='" +
  -                                                                 getStringValue(base.fMinInclusive) + "'." );
  -                }
  -
  -                // check 4.3.9.c3 error:
  -                // minExclusive < base.minExclusive
  -                // maxInclusive > base.maxInclusive
  -                // minInclusive < base.minInclusive
  -                // maxExclusive >= base.maxExclusive
  -                if (((fFacetsDefined & DEFINED_MINEXCLUSIVE) != 0)) {
  -                    if ((( base.fFacetsDefined & DEFINED_MINEXCLUSIVE) != 0)) {
  -
  -                        result= fDVs[fValidateDV].compare(fMinExclusive, base.fMinExclusive);
  -                        if ((base.fFixedFacet & DEFINED_MINEXCLUSIVE) != 0 &&
  -                            result != 0) {
  -                            reportError( "minExclusive value = '" + getStringValue(fMinExclusive) +
  -                                                                     "' must be equal to base.minExclusive value = '" +
  -                                                                     getStringValue(base.fMinExclusive) + "' with attribute {fixed} = true" );
  -                        }
  -                        if (result == -1 || result == INDETERMINATE) {
  -                            reportError( "minExclusive value ='" + getStringValue(fMinExclusive) + "' must be >= base.minExclusive value ='" +
  -                                                                     getStringValue(base.fMinExclusive) + "'." );
  -                        }
  -                    }
  -
  -                    if ((( base.fFacetsDefined & DEFINED_MAXINCLUSIVE) != 0)) {
  -                        result=fDVs[fValidateDV].compare(fMinExclusive, base.fMaxInclusive);
  -
  -                        if (result == 1 || result == INDETERMINATE) {
  -                            reportError(
  -                                                                   "minExclusive value ='" + getStringValue(fMinExclusive) + "' must be <= base.maxInclusive value ='" +
  -                                                                   getStringValue(base.fMaxInclusive) + "'." );
  -                        }
  -                    }
  -
  -                    if ((( base.fFacetsDefined & DEFINED_MININCLUSIVE) != 0)) {
  -                        result = fDVs[fValidateDV].compare(fMinExclusive, base.fMinInclusive);
  -
  -                        if (result == -1 || result == INDETERMINATE) {
  -                            reportError(
  -                                                                   "minExclusive value ='" + getStringValue(fMinExclusive) + "' must be >= base.minInclusive value ='" +
  -                                                                   getStringValue(base.fMinInclusive) + "'." );
  -                        }
  -                    }
  -
  -                    if ((( base.fFacetsDefined & DEFINED_MAXEXCLUSIVE) != 0) &&
  -                        fDVs[fValidateDV].compare(fMinExclusive, base.fMaxExclusive) != -1)
  -                        reportError( "minExclusive value ='" + getStringValue(fMinExclusive) + "' must be < base.maxExclusive value ='" +
  -                                                                 getStringValue(base.fMaxExclusive) + "'." );
  -                }
  -
  -                // check 4.3.10.c2 error:
  -                // minInclusive < base.minInclusive
  -                // minInclusive > base.maxInclusive
  -                // minInclusive <= base.minExclusive
  -                // minInclusive >= base.maxExclusive
  -                if (((fFacetsDefined & DEFINED_MININCLUSIVE) != 0)) {
  -                    if (((base.fFacetsDefined & DEFINED_MININCLUSIVE) != 0)) {
  -                        result = fDVs[fValidateDV].compare(fMinInclusive, base.fMinInclusive);
  -
  -                        if ((base.fFixedFacet & DEFINED_MININCLUSIVE) != 0 &&
  -                            result != 0) {
  -                            reportError( "minInclusive value = '" + getStringValue(fMinInclusive) +
  -                                                                     "' must be equal to base.minInclusive value = '" +
  -                                                                     getStringValue(base.fMinInclusive) + "' with attribute {fixed} = true" );
  -                        }
  -                        if (result == -1 || result == INDETERMINATE) {
  -                            reportError( "minInclusive value ='" + getStringValue(fMinInclusive) + "' must be >= base.minInclusive value ='" +
  -                                                                     getStringValue(base.fMinInclusive) + "'." );
  -                        }
  -                    }
  -                    if ((( base.fFacetsDefined & DEFINED_MAXINCLUSIVE) != 0)) {
  -                        result=fDVs[fValidateDV].compare(fMinInclusive, base.fMaxInclusive);
  -                        if (result == 1 || result == INDETERMINATE) {
  -                            reportError( "minInclusive value ='" + getStringValue(fMinInclusive) + "' must be <= base.maxInclusive value ='" +
  -                                                                     getStringValue(base.fMaxInclusive) + "'." );
  -                        }
  -                    }
  -                    if ((( base.fFacetsDefined & DEFINED_MINEXCLUSIVE) != 0) &&
  -                        fDVs[fValidateDV].compare(fMinInclusive, base.fMinExclusive ) != 1)
  -                        reportError( "minInclusive value ='" + getStringValue(fMinInclusive) + "' must be > base.minExclusive value ='" +
  -                                                                 getStringValue(base.fMinExclusive) + "'." );
  -                    if ((( base.fFacetsDefined & DEFINED_MAXEXCLUSIVE) != 0) &&
  -                        fDVs[fValidateDV].compare(fMinInclusive, base.fMaxExclusive) != -1)
  -                        reportError( "minInclusive value ='" + getStringValue(fMinInclusive) + "' must be < base.maxExclusive value ='" +
  -                                                                 getStringValue(base.fMaxExclusive) + "'." );
  -                }
  -
  -                // check 4.3.11.c1 error: totalDigits > base.totalDigits
  -                if (((fFacetsDefined & DEFINED_TOTALDIGITS) != 0)) {
  -                    if ((( base.fFacetsDefined & DEFINED_TOTALDIGITS) != 0)) {
  -                        if ((base.fFixedFacet & DEFINED_TOTALDIGITS) != 0 &&  fTotalDigits != base.fTotalDigits) {
  -                            reportError("totalDigits value = '" + fTotalDigits +
  -                                                                    "' must be equal to base.totalDigits value = '" +
  -                                                                    base.fTotalDigits +
  -                                                                    "' with attribute {fixed} = true" );
  -                        }
  -                        if (fTotalDigits > base.fTotalDigits) {
  -                            reportError( "totalDigits value ='" + fTotalDigits + "' must be <= base.totalDigits value ='" +
  -                                                                     base.fTotalDigits + "'." );
  -                        }
  -                    }
  -                }
  -
  -                // check fixed value for fractionDigits
  -                if (((fFacetsDefined & DEFINED_FRACTIONDIGITS) != 0)) {
  -                    if ((( base.fFacetsDefined & DEFINED_FRACTIONDIGITS) != 0)) {
  -                        if ((base.fFixedFacet & DEFINED_FRACTIONDIGITS) != 0 && fFractionDigits != base.fFractionDigits) {
  -                            reportError("fractionDigits value = '" + fFractionDigits +
  -                                                                    "' must be equal to base.fractionDigits value = '" +
  -                                                                    base.fFractionDigits +
  -                                                                    "' with attribute {fixed} = true" );
  -                        }
  -                    }
  -                }
  -
  -
  -                //REVISIT: we dont have any check for enumeration ??, do we need such a check.
  -                if(((fFacetsDefined & DEFINED_ENUMERATION) != 0)  && (fEnumeration != null) &&
  -                ((base.fFacetsDefined & DEFINED_ENUMERATION) != 0)  && (base.fEnumeration != null)){
  -                    // we expect that it will have compiled value
  -                    boolean found = false;
  -                    for(int i =0 ; i < fEnumeration.length  ; i++){
  -                        for( int j = 0 ; j < base.fEnumeration.length  ; j++){
  -                            if( isEqual(fEnumeration[i] , base.fEnumeration[j])){
  -                                found = true;
  -                                break; // we found the value
  -                            }
  -                        }
  -                    }
  -
  -                  if(!found){
  -                    reportError("values of enumeration should be from the value space of base.");
  -                   }
  -                }
  -
  -                // check 4.3.6.c1 error:
  -                // (whiteSpace = preserve || whiteSpace = replace) && base.whiteSpace = collapese or
  -                // whiteSpace = preserve && base.whiteSpace = replace
  -
  -                if ( (fFacetsDefined & DEFINED_WHITESPACE) != 0 && (base.fFacetsDefined & DEFINED_WHITESPACE) != 0 ){
  -                    if ( (fFixedFacet & DEFINED_WHITESPACE) != 0 &&  fWhiteSpace != base.fWhiteSpace ) {
  -                        reportError( "whiteSpace value = '" + whiteSpaceValue(fWhiteSpace) +
  -                                                             "' must be equal to base.whiteSpace value = '" +
  -                                                             whiteSpaceValue(base.fWhiteSpace) + "' with attribute {fixed} = true" );
  -                    }
  -
  -                    if ( (fWhiteSpace == PRESERVE || fWhiteSpace == REPLACE) &&  base.fWhiteSpace == COLLAPSE ){
  -                        reportError( "It is an error if whiteSpace = 'preserve' or 'replace' and base.whiteSpace = 'collapse'.");
  +                    if (result == -1) {
  +                        reportError(
  +                                                               "minExclusive value ='" + getStringValue(fMinExclusive) + "' must be >= fBase.minInclusive value ='" +
  +                                                               getStringValue(fBase.fMinInclusive) + "'." );
  +                    }
  +                }
  +
  +                if ((( fBase.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) &&
  +                    fDVs[fValidateDV].compare(fMinExclusive, fBase.fMaxExclusive) != -1)
  +                    reportError( "minExclusive value ='" + getStringValue(fMinExclusive) + "' must be < fBase.maxExclusive value ='" +
  +                                                             getStringValue(fBase.fMaxExclusive) + "'." );
  +            }
  +
  +            // check 4.3.10.c2 error:
  +            // minInclusive < fBase.minInclusive
  +            // minInclusive > fBase.maxInclusive
  +            // minInclusive <= fBase.minExclusive
  +            // minInclusive >= fBase.maxExclusive
  +            if (((fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
  +                if (((fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
  +                    result = fDVs[fValidateDV].compare(fMinInclusive, fBase.fMinInclusive);
  +
  +                    if ((fBase.fFixedFacet & FACET_MININCLUSIVE) != 0 &&
  +                        result != 0) {
  +                        reportError( "minInclusive value = '" + getStringValue(fMinInclusive) +
  +                                                                 "' must be equal to fBase.minInclusive value = '" +
  +                                                                 getStringValue(fBase.fMinInclusive) + "' with attribute {fixed} = true" );
                       }
  -                    if ( fWhiteSpace == PRESERVE &&  base.fWhiteSpace == REPLACE ){
  -                        reportError( "It is an error if whiteSpace = 'preserve' and base.whiteSpace = 'replace'.");
  +                    if (result == -1) {
  +                        reportError( "minInclusive value ='" + getStringValue(fMinInclusive) + "' must be >= fBase.minInclusive value ='" +
  +                                                                 getStringValue(fBase.fMinInclusive) + "'." );
                       }
                   }
  +                if ((( fBase.fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
  +                    result=fDVs[fValidateDV].compare(fMinInclusive, fBase.fMaxInclusive);
  +                    if (result == 1) {
  +                        reportError( "minInclusive value ='" + getStringValue(fMinInclusive) + "' must be <= fBase.maxInclusive value ='" +
  +                                                                 getStringValue(fBase.fMaxInclusive) + "'." );
  +                    }
  +                }
  +                if ((( fBase.fFacetsDefined & FACET_MINEXCLUSIVE) != 0) &&
  +                    fDVs[fValidateDV].compare(fMinInclusive, fBase.fMinExclusive ) != 1)
  +                    reportError( "minInclusive value ='" + getStringValue(fMinInclusive) + "' must be > fBase.minExclusive value ='" +
  +                                                             getStringValue(fBase.fMinExclusive) + "'." );
  +                if ((( fBase.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) &&
  +                    fDVs[fValidateDV].compare(fMinInclusive, fBase.fMaxExclusive) != -1)
  +                    reportError( "minInclusive value ='" + getStringValue(fMinInclusive) + "' must be < fBase.maxExclusive value ='" +
  +                                                             getStringValue(fBase.fMaxExclusive) + "'." );
  +            }
   
  -            }//base != null
  +            // check 4.3.11.c1 error: totalDigits > fBase.totalDigits
  +            if (((fFacetsDefined & FACET_TOTALDIGITS) != 0)) {
  +                if ((( fBase.fFacetsDefined & FACET_TOTALDIGITS) != 0)) {
  +                    if (fTotalDigits > fBase.fTotalDigits) {
  +                        reportError("totalDigits value = '" + fTotalDigits +
  +                                                                "' must be equal to fBase.totalDigits value = '" +
  +                                                                fBase.fTotalDigits +
  +                                                                "' with attribute {fixed} = true" );
  +                    }
  +                    if (fTotalDigits > fBase.fTotalDigits) {
  +                        reportError( "totalDigits value ='" + fTotalDigits + "' must be <= fBase.totalDigits value ='" +
  +                                                                 fBase.fTotalDigits + "'." );
  +                    }
  +                }
  +            }
  +
  +            // check fixed value for fractionDigits
  +            if (((fFacetsDefined & FACET_FRACTIONDIGITS) != 0)) {
  +                if ((( fBase.fFacetsDefined & FACET_FRACTIONDIGITS) != 0)) {
  +                    if ((fBase.fFixedFacet & FACET_FRACTIONDIGITS) != 0 && fFractionDigits != fBase.fFractionDigits) {
  +                        reportError("fractionDigits value = '" + fFractionDigits +
  +                                                                "' must be equal to fBase.fractionDigits value = '" +
  +                                                                fBase.fFractionDigits +
  +                                                                "' with attribute {fixed} = true" );
  +                    }
  +                }
  +            }
  +
  +            // check 4.3.6.c1 error:
  +            // (whiteSpace = preserve || whiteSpace = replace) && fBase.whiteSpace = collapese or
  +            // whiteSpace = preserve && fBase.whiteSpace = replace
  +
  +            if ( (fFacetsDefined & FACET_WHITESPACE) != 0 && (fBase.fFacetsDefined & FACET_WHITESPACE) != 0 ){
  +                if ( (fFixedFacet & FACET_WHITESPACE) != 0 &&  fWhiteSpace != fBase.fWhiteSpace ) {
  +                    reportError( "whiteSpace value = '" + whiteSpaceValue(fWhiteSpace) +
  +                                                         "' must be equal to fBase.whiteSpace value = '" +
  +                                                         whiteSpaceValue(fBase.fWhiteSpace) + "' with attribute {fixed} = true" );
  +                }
  +
  +                if ( (fWhiteSpace == WS_PRESERVE || fWhiteSpace == WS_REPLACE) &&  fBase.fWhiteSpace == WS_COLLAPSE ){
  +                    reportError( "It is an error if whiteSpace = 'preserve' or 'replace' and fBase.whiteSpace = 'collapse'.");
  +                }
  +                if ( fWhiteSpace == WS_PRESERVE &&  fBase.fWhiteSpace == WS_REPLACE ){
  +                    reportError( "It is an error if whiteSpace = 'preserve' and fBase.whiteSpace = 'replace'.");
  +                }
  +            }
           }//fFacetsDefined != null
   
  -        // REVISIT: fTokeyType
  -        // step 5: inherit other facets from base (including fTokeyType)
  +        // step 4: inherit other facets from base (including fTokeyType)
   
           // inherit length
  -        if ( (fFacetsDefined & DEFINED_LENGTH) == 0  && (base.fFacetsDefined & DEFINED_LENGTH) != 0 ) {
  -                fFacetsDefined |= DEFINED_LENGTH;
  -                fLength = base.fLength;
  +        if ( (fFacetsDefined & FACET_LENGTH) == 0  && (fBase.fFacetsDefined & FACET_LENGTH) != 0 ) {
  +            fFacetsDefined |= FACET_LENGTH;
  +            fLength = fBase.fLength;
           }
           // inherit minLength
  -        if ( (fFacetsDefined & DEFINED_MINLENGTH) == 0 && (base.fFacetsDefined & DEFINED_MINLENGTH) != 0 ) {
  -                fFacetsDefined |= DEFINED_MINLENGTH;
  -                fMinLength = base.fMinLength;
  +        if ( (fFacetsDefined & FACET_MINLENGTH) == 0 && (fBase.fFacetsDefined & FACET_MINLENGTH) != 0 ) {
  +            fFacetsDefined |= FACET_MINLENGTH;
  +            fMinLength = fBase.fMinLength;
           }
           // inherit maxLength
  -        if ((fFacetsDefined & DEFINED_MAXLENGTH) == 0 &&  (base.fFacetsDefined & DEFINED_MAXLENGTH) != 0 ) {
  -                fFacetsDefined |= DEFINED_MAXLENGTH;
  -                fMaxLength = base.fMaxLength;
  +        if ((fFacetsDefined & FACET_MAXLENGTH) == 0 &&  (fBase.fFacetsDefined & FACET_MAXLENGTH) != 0 ) {
  +            fFacetsDefined |= FACET_MAXLENGTH;
  +            fMaxLength = fBase.fMaxLength;
  +        }
  +        // inherit pattern //???
  +        if ( (fBase.fFacetsDefined & FACET_PATTERN) != 0 ) {
  +            if ((fFacetsDefined & FACET_PATTERN) == 0)
  +                fPattern = new Vector();
  +            fFacetsDefined |= FACET_ENUMERATION;
  +            for (int i = fBase.fPattern.size()-1; i >= 0; i--)
  +                fPattern.addElement(fBase.fPattern.elementAt(i));
  +            fEnumeration = fBase.fEnumeration;
           }
  -        // inherit enumeration
  -        if ( (fFacetsDefined & DEFINED_ENUMERATION) == 0 && (base.fFacetsDefined & DEFINED_ENUMERATION) != 0 ) {
  -            fFacetsDefined |= DEFINED_ENUMERATION;
  -            fEnumeration = base.fEnumeration;
  -        }
  -        //REVISIT:
           // inherit whiteSpace
  -        if ( (fFacetsDefined & DEFINED_WHITESPACE) == 0 &&  (base.fFacetsDefined & DEFINED_WHITESPACE) != 0 ) {
  -            fFacetsDefined |= DEFINED_WHITESPACE;
  -            fWhiteSpace = base.fWhiteSpace;
  +        if ( (fFacetsDefined & FACET_WHITESPACE) == 0 &&  (fBase.fFacetsDefined & FACET_WHITESPACE) != 0 ) {
  +            fFacetsDefined |= FACET_WHITESPACE;
  +            fWhiteSpace = fBase.fWhiteSpace;
           }
           // inherit enumeration
  -        if ((fFacetsDefined & DEFINED_ENUMERATION) == 0 && (base.fFacetsDefined & DEFINED_ENUMERATION) != 0) {
  -            fFacetsDefined |= DEFINED_ENUMERATION;
  -            fEnumeration = base.fEnumeration;
  +        if ((fFacetsDefined & FACET_ENUMERATION) == 0 && (fBase.fFacetsDefined & FACET_ENUMERATION) != 0) {
  +            fFacetsDefined |= FACET_ENUMERATION;
  +            fEnumeration = fBase.fEnumeration;
           }
  -
           // inherit maxExclusive
  -        if ((( base.fFacetsDefined & DEFINED_MAXEXCLUSIVE) != 0) &&
  -            !((fFacetsDefined & DEFINED_MAXEXCLUSIVE) != 0) && !((fFacetsDefined & DEFINED_MAXINCLUSIVE) != 0)) {
  -            fFacetsDefined |= DEFINED_MAXEXCLUSIVE;
  -            fMaxExclusive = base.fMaxExclusive;
  +        if ((( fBase.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) &&
  +            !((fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) && !((fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
  +            fFacetsDefined |= FACET_MAXEXCLUSIVE;
  +            fMaxExclusive = fBase.fMaxExclusive;
           }
           // inherit maxInclusive
  -        if ((( base.fFacetsDefined & DEFINED_MAXINCLUSIVE) != 0) &&
  -            !((fFacetsDefined & DEFINED_MAXEXCLUSIVE) != 0) && !((fFacetsDefined & DEFINED_MAXINCLUSIVE) != 0)) {
  -            fFacetsDefined |= DEFINED_MAXINCLUSIVE;
  -            fMaxInclusive = base.fMaxInclusive;
  +        if ((( fBase.fFacetsDefined & FACET_MAXINCLUSIVE) != 0) &&
  +            !((fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) && !((fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
  +            fFacetsDefined |= FACET_MAXINCLUSIVE;
  +            fMaxInclusive = fBase.fMaxInclusive;
           }
           // inherit minExclusive
  -        if ((( base.fFacetsDefined & DEFINED_MINEXCLUSIVE) != 0) &&
  -            !((fFacetsDefined & DEFINED_MINEXCLUSIVE) != 0) && !((fFacetsDefined & DEFINED_MININCLUSIVE) != 0)) {
  -            fFacetsDefined |= DEFINED_MINEXCLUSIVE;
  -            fMinExclusive = base.fMinExclusive;
  +        if ((( fBase.fFacetsDefined & FACET_MINEXCLUSIVE) != 0) &&
  +            !((fFacetsDefined & FACET_MINEXCLUSIVE) != 0) && !((fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
  +            fFacetsDefined |= FACET_MINEXCLUSIVE;
  +            fMinExclusive = fBase.fMinExclusive;
           }
           // inherit minExclusive
  -        if ((( base.fFacetsDefined & DEFINED_MININCLUSIVE) != 0) &&
  -            !((fFacetsDefined & DEFINED_MINEXCLUSIVE) != 0) && !((fFacetsDefined & DEFINED_MININCLUSIVE) != 0)) {
  -            fFacetsDefined |= DEFINED_MININCLUSIVE;
  -            fMinInclusive = base.fMinInclusive;
  +        if ((( fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0) &&
  +            !((fFacetsDefined & FACET_MINEXCLUSIVE) != 0) && !((fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
  +            fFacetsDefined |= FACET_MININCLUSIVE;
  +            fMinInclusive = fBase.fMinInclusive;
           }
           // inherit totalDigits
  -        if ((( base.fFacetsDefined & DEFINED_TOTALDIGITS) != 0) &&
  -            !((fFacetsDefined & DEFINED_TOTALDIGITS) != 0)) {
  -            fFacetsDefined |= DEFINED_TOTALDIGITS;
  -            fTotalDigits = base.fTotalDigits;
  +        if ((( fBase.fFacetsDefined & FACET_TOTALDIGITS) != 0) &&
  +            !((fFacetsDefined & FACET_TOTALDIGITS) != 0)) {
  +            fFacetsDefined |= FACET_TOTALDIGITS;
  +            fTotalDigits = fBase.fTotalDigits;
           }
           // inherit fractionDigits
  -        if ((( base.fFacetsDefined & DEFINED_FRACTIONDIGITS) != 0)
  -            && !((fFacetsDefined & DEFINED_FRACTIONDIGITS) != 0)) {
  -            fFacetsDefined |= DEFINED_FRACTIONDIGITS;
  -            fFractionDigits = base.fFractionDigits;
  +        if ((( fBase.fFacetsDefined & FACET_FRACTIONDIGITS) != 0)
  +            && !((fFacetsDefined & FACET_FRACTIONDIGITS) != 0)) {
  +            fFacetsDefined |= FACET_FRACTIONDIGITS;
  +            fFractionDigits = fBase.fFractionDigits;
           }
  -
  -
  -    } //init4Restriction()
  +        //inherit tokeytype
  +        if ((fTokenType == SPECIAL_TOKEN_NONE ) && (fBase.fTokenType != SPECIAL_TOKEN_NONE)) {
  +            fTokenType = fBase.fTokenType ;
  +        }
   
  -    /**
  -     * If <list> is chosen
  -     */
  -    public void init4List(XSSimpleTypeDecl itemType) {
  -        fVariety = VARIETY_LIST;
  -        fItemType = itemType;
  -    }
  +        // step 5: mark fixed values
  +        fFixedFacet |= fBase.fFixedFacet;
   
  -    /**
  -     * If <union> is chosen
  -     */
  -     //REVISIT:it will impact SimpleTypeTraverser
  -    public void init4Union(XSSimpleTypeDecl [] memberTypes) {
  -        fVariety = VARIETY_UNION;
  -        fMemberTypes = memberTypes;
  -    }
  +        //inherit baseBuiltInTypeName.
   
  +    } //init4Restriction()
   
       /**
        * validate a value, and return the compiled form
        */
  -    public Object validate(String content, ValidateContext context) throws InvalidDatatypeValueException {
  -        Object retVal = content;
  -
  -        switch (fVariety) {
  -        case VARIETY_ATOMIC:
  -            retVal = validateRestriction(content, context);
  -            break;
  -        case VARIETY_LIST:
  -            retVal = validateList(content, context);
  -            break;
  -        case VARIETY_UNION:
  -            retVal = validateUnion(content, context);
  -            break;
  -        }
  +    public Object validate(String content, ValidationContext context) throws InvalidDatatypeValueException {
   
  -        return retVal;
  -    }// validate()
  -
  -    public Object validateRestriction(String content, ValidateContext context) {
           // step 1: validate the value against the facets. we need to use the
           //         get***, compare, isEqual methods from TypeValidator
           Object ob = null;
  -
  -        //REVISIT: use of fValidateDV, reporting  errors
   
  -        try
  -        {
  -            ob = getCompiledValue(content);
  -        }
  -        catch (InvalidDatatypeValueException ide) {
  -                        reportError("Value of content '" + content + "' must be from the value space of base");
  +        try {
  +            ob = getActualValue(content, context);
  +        } catch (InvalidDatatypeValueException ide) {
  +            throw ide;
           }
   
  -
  -        // REVISIT: check it again
  -        if ( (fFacetsDefined & DEFINED_PATTERN ) != 0 ) {
  -            Enumeration keys = fPattern.elements() ;
  -            boolean matched = false;
  -            RegularExpression regex = new RegularExpression("X");
  -            while(keys.hasMoreElements() ){
  -                String pattern = (String)keys.nextElement();
  -                if (regex != null && regex.matches(pattern)){
  -                    matched = true;
  -                    break;
  +        if ( (fFacetsDefined & FACET_PATTERN ) != 0 ) {
  +            RegularExpression regex;
  +            for (int idx = fPattern.size()-1; idx >= 0; idx--) {
  +                regex = (RegularExpression)fPattern.elementAt(idx);
  +                if (!regex.matches(content)){
  +                    throw new InvalidDatatypeValueException("Value '"+content+
  +                                                            "' does not match regular expression facet '" + fPattern + "'." );
                   }
               }
  -            if(!matched)
  -                    reportError("Value '"+content+
  -                                                            "' does not match regular expression facet '" + fPattern + "'." );
  -
           }
   
           int length = fDVs[fValidateDV].getDataLength(ob);
   
  -          // maxLength
  -        if ( (fFacetsDefined & DEFINED_MAXLENGTH) != 0 ) {
  +        // maxLength
  +        if ( (fFacetsDefined & FACET_MAXLENGTH) != 0 ) {
               if ( length > fMaxLength ) {
  -                reportError("Value '"+content+
  +                throw new InvalidDatatypeValueException("Value '"+content+
                                                           "' with length '"+length+
                                                           "' exceeds maximum length facet of '"+fMaxLength+"'.");
               }
           }
   
  -          //minLength
  -        if ( (fFacetsDefined & DEFINED_MINLENGTH) != 0 ) {
  +        //minLength
  +        if ( (fFacetsDefined & FACET_MINLENGTH) != 0 ) {
               if ( length < fMinLength ) {
  -                reportError("Value '"+content+
  +                throw new InvalidDatatypeValueException("Value '"+content+
                                                           "' with length '"+length+
                                                           "' is less than minimum length facet of '"+fMinLength+"'." );
               }
           }
   
  -          //length
  -        if ( (fFacetsDefined & DEFINED_LENGTH) != 0 ) {
  +        //length
  +        if ( (fFacetsDefined & FACET_LENGTH) != 0 ) {
               if ( length != fLength ) {
  -                reportError("Value '"+content+
  +                throw new InvalidDatatypeValueException("Value '"+content+
                                                           "' with length '"+length+
                                                           "' is not equal to length facet '"+fLength+"'.");
               }
           }
   
  -          //enumeration
  -
  -        if ( ((fFacetsDefined & DEFINED_ENUMERATION) != 0 )&&
  -             (fEnumeration != null) ) {
  +        //enumeration
  +        if ( ((fFacetsDefined & FACET_ENUMERATION) != 0 ) ) {
               boolean present = false;
  -            for (int i = 0; i < fEnumeration.length; i++) {
  -              if (isEqual(ob,fEnumeration[i])) {
  +            for (int i = 0; i < fEnumeration.size(); i++) {
  +              if (isEqual(ob, fEnumeration.elementAt(i))) {
                     present = true;
                     break;
                 }
               }
               if(!present){
  -               String msg = getErrorString(
  -                                         DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.NOT_ENUM_VALUE],
  -                                         new Object [] { ob});
  -                reportError(msg);
  +                throw new InvalidDatatypeValueException(DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.NOT_ENUM_VALUE],
  +                                         new Object [] {content});
               }
           }
  -
   
  -
  -          //fractionDigits
  -        if ((fFacetsDefined & DEFINED_FRACTIONDIGITS) != 0) {
  -        int scale = fDVs[fValidateDV].getFractionDigits(ob);
  +        //fractionDigits
  +        if ((fFacetsDefined & FACET_FRACTIONDIGITS) != 0) {
  +            int scale = fDVs[fValidateDV].getFractionDigits(ob);
               if (scale > fFractionDigits) {
  -                String msg = getErrorString(
  -                                           DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.FRACTION_EXCEEDED],
  +                throw new InvalidDatatypeValueException(DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.FRACTION_EXCEEDED],
                                              new Object[] {
                                                  "'" + content + "'" + " with fractionDigits = '"+ scale +"'",
                                                  "'" + fFractionDigits + "'"
                                              });
  -                reportError(msg);
               }
           }
   
  -          //totalDigits
  -        if ((fFacetsDefined & DEFINED_TOTALDIGITS)!=0) {
  +        //totalDigits
  +        if ((fFacetsDefined & FACET_TOTALDIGITS)!=0) {
               int totalDigits = fDVs[fValidateDV].getTotalDigits(ob);
               if (totalDigits > fTotalDigits) {
  -
  -                String msg = getErrorString(
  -                                           DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.TOTALDIGITS_EXCEEDED],
  +                throw new InvalidDatatypeValueException(DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.TOTALDIGITS_EXCEEDED],
                                              new Object[] {
                                                  "'" + content + "'" + " with totalDigits = '"+ totalDigits +"'",
                                                  "'" + fTotalDigits + "'"
                                              });
  -                reportError(msg);
               }
           }
   
  @@ -1160,7 +1037,7 @@
           int compare;
   
           //maxinclusive
  -        if ( (fFacetsDefined & DEFINED_MAXINCLUSIVE) != 0 ) {
  +        if ( (fFacetsDefined & FACET_MAXINCLUSIVE) != 0 ) {
               compare = fDVs[fValidateDV].compare(ob, fMaxInclusive);
               maxOk =  (compare == 1) ? false:true;
               upperBound   = fMaxInclusive.toString();
  @@ -1173,7 +1050,7 @@
           }
   
           //maxExclusive
  -        if ( (fFacetsDefined & DEFINED_MAXEXCLUSIVE) != 0 ) {
  +        if ( (fFacetsDefined & FACET_MAXEXCLUSIVE) != 0 ) {
               compare = fDVs[fValidateDV].compare(ob,  fMaxExclusive );
               maxOk = (compare==-1)?true:false;
               upperBound = fMaxExclusive.toString();
  @@ -1186,7 +1063,7 @@
           }
   
           //minInclusive
  -        if ( (fFacetsDefined & DEFINED_MININCLUSIVE) != 0 ) {
  +        if ( (fFacetsDefined & FACET_MININCLUSIVE) != 0 ) {
               compare = fDVs[fValidateDV].compare(ob, fMinInclusive);
               minOk = (compare==-1)?false:true;
               lowerBound = fMinInclusive.toString();
  @@ -1199,7 +1076,7 @@
           }
   
           //minExclusive
  -        if ( (fFacetsDefined & DEFINED_MINEXCLUSIVE) != 0 ) {
  +        if ( (fFacetsDefined & FACET_MINEXCLUSIVE) != 0 ) {
               compare = fDVs[fValidateDV].compare(ob, fMinExclusive);
               minOk = (compare==1)?true:false;
               lowerBound = fMinExclusive.toString();
  @@ -1212,353 +1089,292 @@
           }
   
           if ( !(minOk && maxOk) ){
  -
  -            String msg = getErrorString(
  -                DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.OUT_OF_BOUNDS],
  +            throw new InvalidDatatypeValueException(DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.OUT_OF_BOUNDS],
                   new Object [] { ob.toString(), lowerBound, upperBound, lowerBoundIndicator, upperBoundIndicator});
  -            reportError(msg);
           }
   
   
           // step 2: validate the value against token_type, if there is one specified.
   
           // validate special kinds of token, in place of old pattern matching
  -        if (fTokeyType != TOKEN_NONE.shortValue() ) {
  +        if (fTokenType != SPECIAL_TOKEN_NONE) {
   
  -        boolean seenErr = false;
  -        if (fTokeyType == TOKEN_NMTOKEN.shortValue() ) {
  -
  -            seenErr = !XMLChar.isValidNmtoken(content);
  +            boolean seenErr = false;
  +            if (fTokenType == SPECIAL_TOKEN_NMTOKEN) {
  +                // PATTERN "\\c+"
  +                seenErr = !XMLChar.isValidNmtoken(content);
  +            }
  +            else if (fTokenType == SPECIAL_TOKEN_NAME ||
  +                     fTokenType == SPECIAL_TOKEN_IDNAME ||
  +                     fTokenType == SPECIAL_TOKEN_IDREFNAME) {
  +                // PATTERN "\\i\\c*"
  +                seenErr = !XMLChar.isValidName(content);
  +            }
  +            else if (fTokenType == SPECIAL_TOKEN_NCNAME ||
  +                     fTokenType == SPECIAL_TOKEN_IDNCNAME ||
  +                     fTokenType == SPECIAL_TOKEN_IDREFNCNAME ||
  +                     fTokenType == 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 " +
  +                                                        SPECIAL_TOKEN_STRING[fTokenType]);
  +            }
           }
  -        else if (fTokeyType == TOKEN_NAME.shortValue() ||
  -                   fTokeyType == TOKEN_IDNAME.shortValue() ||
  -                   fTokeyType == TOKEN_IDREFNAME.shortValue()) {
   
  -            seenErr = !XMLChar.isValidName(content);
  -        } else if (fTokeyType == TOKEN_NCNAME.shortValue() ||
  -                   fTokeyType == TOKEN_IDNCNAME.shortValue() ||
  -                   fTokeyType == TOKEN_IDREFNCNAME.shortValue() ||
  -                   fTokeyType == TOKEN_ENTITY.shortValue() ) {
  +        return ob;
  +    }// validate()
   
  -            // REVISIT: !!!NOT IMPLEMENTED in XMLChar
  -            seenErr = !XMLChar.isValidNCName(content);
  -        }
  -        if (seenErr) {
  -            reportError(
  -                            "Value '"+content+"' is not a valid " + fTokeyType);
  +    private Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException{
  +
  +        if(fVariety == VARIETY_ATOMIC)
  +            return fDVs[fValidateDV].getActualValue(content, context);
  +
  +        else if(fVariety == VARIETY_LIST){
  +            StringTokenizer parsedList = new StringTokenizer(content);
  +            int countOfTokens = parsedList.countTokens() ;
  +            Object[] ret = new Object[countOfTokens];
  +            for(int i = 0 ; i < countOfTokens ; i ++){
  +                ret[i] = fItemType.validate(parsedList.nextToken(), context);
  +            }
  +            return ret;
           }
   
  +        else if(fVariety == VARIETY_UNION){
  +            Object ret = null;
  +
  +            for(int i = 0 ; i < fMemberTypes.length; i++) {
  +                try {
  +                    //it should throw exception if anything goes wrong
  +                    return fMemberTypes[i].validate(content, context);
  +                } catch(InvalidDatatypeValueException invalidValue) {
  +                }
  +            }
  +
  +            String msg  = " content = " + content + " doesnt't match any of the member types " ;
  +            throw new InvalidDatatypeValueException(msg);
           }
   
  -        // step 3: call fValidateDV for extra validation. this is useful
  -        //         for ID/IDREF/ENTITY/QNAME, etc.
  +        // should never get here
  +        return null;
  +    }//getActualValue()
   
  +    public boolean isEqual(Object value1, Object value2) {
   
  -        if(context != null){
  +        if (fVariety == VARIETY_ATOMIC)
  +            return  fDVs[fValidateDV].isEqual(value1,value2);
   
  -        /* REVISIT: validateContext
  +        else if (fVariety == VARIETY_LIST) {
  +            Object[] v1 = (Object[])value1;
  +            Object[] v2 = (Object[])value2;
   
  -        */
  -        }// step 3
  +            int count = v1.length;
  +            if (count != v2.length)
  +                return false;
   
  -        return ob;
  -    }// validateRestriction()
  +            for (int i = 0 ; i < count ; i++) {
  +                if (!fItemType.isEqual(v1[i], v2[i]))
  +                    return false;
  +            }//end of loop
   
  -    private String getErrorString(String key, Object args[]) {
  -        try {
  -            return fMessageProvider.formatMessage(fLocale, key, args);
  -        }
  -        catch ( Exception e ) {
  -            return "Illegal Errorcode "+key;
  +            //everything went fine.
  +            return true;
  +
  +        } else if (fVariety == VARIETY_UNION) {
  +            for (int i = fMemberTypes.length-1; i >= 0; i--) {
  +                if (fMemberTypes[i].isEqual(value1,value2)){
  +                    return true;
  +                }
  +            }
  +            return false;
           }
  -    }
   
  -    /**
  -     * set the locate to be used for error messages
  -     */
  -    public void setLocale(Locale locale) {
  -        fLocale = locale;
  +        return false;
  +    }//isEqual()
  +
  +    void reportError(String msg) {
  +        // REVISIT: how do we report datatype facet errors?
  +        // passing ErrorReporter in? return an array of errors back?
  +        System.out.println("reportError: " + msg);
       }
   
  -    private boolean isEqual(Object value1 , Object value2){
  -        boolean retVal = false;
  -        short variety = fVariety;
   
  -        switch(variety){
  +    //REVISIT: error handling
  +    private String whiteSpaceValue(short ws){
  +      if (ws != WS_REPLACE)
  +        return (ws == WS_PRESERVE)?"preserve":"collapse" ;
  +      return "replace";
   
  -        case VARIETY_ATOMIC:
  -           retVal =  fDVs[fValidateDV].isEqual(value1,value2);
  -        break;
  +    }
   
  -        case VARIETY_LIST:
  -            //in case of list compiled values would be string only.
  -            StringTokenizer tokens1 = new StringTokenizer((String)value1);
  -            StringTokenizer tokens2 = new StringTokenizer((String)value2);
  +    public String getStringValue(Object value){
  +        if(value != null)
  +            return value.toString() ;
  +        else
  +            return null;
  +    }
   
  -            if(tokens1.countTokens() != tokens2.countTokens() )
  -                return false;
  +    public static void main(String [] args){
  +/*
  +        Object [] facets = new Object[XSSimpleTypeDecl.FACET_PARAM_SIZE ];
  +        short fixedFacets = 0 ;
   
  -            XSSimpleTypeDecl itemType = fItemType;
  -            variety = itemType.fVariety;
  -            //
  -            if(itemType.fVariety == VARIETY_ATOMIC){
   
  -                int count = tokens1.countTokens() ;
  +        XSSimpleTypeDecl anySimpleType = new XSSimpleTypeDecl(SchemaSymbols.ATTVAL_ANYSIMPLETYPE,SchemaSymbols.URI_SCHEMAFORSCHEMA,SchemaSymbols.EMPTY_SET   );
  +        anySimpleType.init4BuiltInType(XSSimpleTypeDecl.DV_ANYSIMPLETYPE );
  +        //addGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYSIMPLETYPE, anySimpleType);
   
  -                for(int i = 0 ; i < count ; i ++){
  -                    Object content1 = null;
  -                    Object content2 = null;
   
  -                    //getCompiledValues first, for list we pass string as it is
  -                    try{
  -                        content1 = fDVs[itemType.fValidateDV].getCompiledValue(tokens1.nextToken() );
  -                    }catch(InvalidDatatypeValueException invalid){
  -                        reportError("content = " + tokens1.nextToken() + " is not from the value space of base." );
  -                        return false;
  -                    }
  -                    try{
  -                        content2 = fDVs[itemType.fValidateDV].getCompiledValue(tokens2.nextToken() );
  -                    }catch(InvalidDatatypeValueException invalid){
  -                        reportError("content = " + tokens2.nextToken() + " is not from the value space of base." );
  -                        return false;
  -                    }
  -                    if(! fDVs[itemType.fValidateDV].isEqual(content1,content2)) {
  -                        return false;
  -                    }
  -                }//end of loop
  +        XSSimpleTypeDecl stringDecl = new XSSimpleTypeDecl(SchemaSymbols.ATTVAL_STRING,SchemaSymbols.URI_SCHEMAFORSCHEMA,SchemaSymbols.EMPTY_SET  );
  +        stringDecl.init4BuiltInType(XSSimpleTypeDecl.DV_STRING );
  +        facets[XSSimpleTypeDecl.INDEX_WHITESPACE ] = new Integer(SchemaSymbols.WS_PRESERVE );
  +        stringDecl.init4Restriction(anySimpleType,facets,XSSimpleTypeDecl.FACET_WHITESPACE ,fixedFacets);
  +        //addGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYSIMPLETYPE, stringDecl);
   
  -                //everything went fine.
  -                retVal = true;
   
  -            }
  -            else if(itemType.fVariety == VARIETY_UNION){
  -                XSSimpleTypeDecl [] memberTypes = itemType.fMemberTypes ;
  -                //REVISIT: still to implement
  -            }//REVISIT:reportError if its neither atomic or union.
   
  +        XSSimpleTypeDecl doubleDecl = new XSSimpleTypeDecl(SchemaSymbols.ATTVAL_DOUBLE,SchemaSymbols.URI_SCHEMAFORSCHEMA,SchemaSymbols.EMPTY_SET  );
  +        doubleDecl.init4BuiltInType(XSSimpleTypeDecl.DV_DOUBLE );
  +        doubleDecl.init4Restriction(anySimpleType,facets,XSSimpleTypeDecl.FACET_WHITESPACE ,XSSimpleTypeDecl.FACET_WHITESPACE);
  +        //addGlobalTypeDecl(SchemaSymbols.ATTVAL_DOUBLE  , doubleDecl);
   
  -        break;
   
  -        case VARIETY_UNION:
  -        //REVISIT: still to implement
  -        break;
  +        XSSimpleTypeDecl decimalDecl = new XSSimpleTypeDecl(SchemaSymbols.ATTVAL_DECIMAL,SchemaSymbols.URI_SCHEMAFORSCHEMA,SchemaSymbols.EMPTY_SET  );
  +        decimalDecl.init4BuiltInType(XSSimpleTypeDecl.DV_DECIMAL );
  +        decimalDecl.init4Restriction(anySimpleType,facets,XSSimpleTypeDecl.FACET_WHITESPACE ,XSSimpleTypeDecl.FACET_WHITESPACE);
  +        //addGlobalTypeDecl(SchemaSymbols.ATTVAL_DECIMAL  , decimalDecl);
  +        facets[XSSimpleTypeDecl.INDEX_WHITESPACE ] =   null;
   
  -        }
  -        return retVal;
  -    }//isEqual()
   
  +        XSSimpleTypeDecl newDecl = new XSSimpleTypeDecl("st1","http://www.foo.com",SchemaSymbols.EMPTY_SET);
  +        facets[XSSimpleTypeDecl.INDEX_LENGTH   ] = new Integer("3");
  +        newDecl.init4Restriction(stringDecl,facets,FACET_LENGTH ,fixedFacets );
   
  -    private Object getCompiledValue(String content) throws InvalidDatatypeValueException{
  +        try{
  +        newDecl.validate("hello",null);
  +        }catch(Exception ex){
  +        System.out.println(ex.getMessage() );
  +        ex.printStackTrace() ;}
   
  -        if(fVariety == VARIETY_ATOMIC)
  -            return fDVs[fValidateDV].getCompiledValue(content);
   
  -        else if(fVariety == VARIETY_LIST){
  -            StringTokenizer parsedList = new StringTokenizer(content);
  -            int countOfTokens = parsedList.countTokens() ;
  -            for(int i = 0 ; i < countOfTokens ; i ++){
  -                fItemType.validate(parsedList.nextToken(),null );
  -            }
  -        }
   
  -        else if(fVariety == VARIETY_UNION){
  -            for(int i = 0 ; i < fMemberTypes.length ; i++){
  -                fMemberTypes[i].validate(content,null);
  -            }
  +        XSSimpleTypeDecl newDecl = new XSSimpleTypeDecl("st1","http://www.foo.com",SchemaSymbols.EMPTY_SET);
  +        facets[XSSimpleTypeDecl.INDEX_ENUMERATION ] = new String[]{"hello","hello1","hello2"};
  +        newDecl.init4Restriction(stringDecl,facets,FACET_ENUMERATION ,fixedFacets );
   
  -        }
  +        try{
  +        newDecl.validate("hello3",null);
  +        }catch(Exception ex){
  +        System.out.println(ex.getMessage() );
  +        ex.printStackTrace() ;}
   
  -        return content;
   
  -    }//getCompiledValue()
  +        XSSimpleTypeDecl newDecl = new XSSimpleTypeDecl("st1","http://www.foo.com",SchemaSymbols.EMPTY_SET);
  +        newDecl.init4List(decimalDecl);
   
  -    private Object validateList(String content, ValidateContext context)throws InvalidDatatypeValueException{
  +        try{
  +        newDecl.validate("12 13 neeraj",null);
  +        }catch(Exception ex){
  +        System.out.println(ex.getMessage() );
  +        ex.printStackTrace() ;}
   
  -        StringTokenizer parsedList = new StringTokenizer( content );
  -        int numberOfTokens = parsedList.countTokens();
  -        XSSimpleTypeDecl itemType = fItemType;
  +        XSSimpleTypeDecl newDecl = new XSSimpleTypeDecl("st1","http://www.foo.com",SchemaSymbols.EMPTY_SET);
  +        newDecl.init4Union(new XSSimpleTypeDecl[]{decimalDecl,stringDecl});
   
  -        // REVISIT: check it again
  -        if ( (fFacetsDefined & DEFINED_PATTERN ) != 0 ) {
  -            Enumeration keys = fPattern.elements() ;
  -            boolean matched = false;
  -            RegularExpression regex = new RegularExpression("X");
  -            while(keys.hasMoreElements() ){
  -                String pattern = (String)keys.nextElement();
  -                if (regex != null && regex.matches(pattern)){
  -                    matched = true;
  -                    break;
  -                }
  -            }
  -            if(!matched)
  -                    reportError("Value '"+content+
  -                                                            "' does not match regular expression facet '" + fPattern + "'." );
  +        try{
  +        newDecl.validate("neeraj",null);
  +        }catch(Exception ex){
  +        System.out.println(ex.getMessage() );
  +        ex.printStackTrace() ;}
   
  -        }
  +          //list checks
   
  -        if ( (fFacetsDefined & DEFINED_MAXLENGTH) != 0 ) {
  -            if ( numberOfTokens > fMaxLength ) {
  -                throw new InvalidDatatypeValueException("Value '"+content+
  -                "' with length ='"+  numberOfTokens + "' tokens"+
  -                "' exceeds maximum length facet of '"+fMaxLength+"' tokens.");
  -            }
  -        }
  -        if ( (fFacetsDefined & DEFINED_MINLENGTH) != 0 ) {
  -            if ( numberOfTokens < fMinLength ) {
  -                throw new InvalidDatatypeValueException("Value '"+content+
  -                "' with length ='"+ numberOfTokens+ "' tokens" +
  -                "' is less than minimum length facet of '"+fMinLength+"' tokens." );
  -            }
  -        }
  +        XSSimpleTypeDecl newDecl = new XSSimpleTypeDecl("newDecl","http://www.foo.com",SchemaSymbols.EMPTY_SET);
  +        newDecl.init4Union(new XSSimpleTypeDecl[]{decimalDecl,stringDecl});
   
  -        if ( (fFacetsDefined & DEFINED_LENGTH) != 0 ) {
  -            if ( numberOfTokens != fLength ) {
  -                throw new InvalidDatatypeValueException("Value '"+content+
  -                "' with length ='"+ numberOfTokens+ "' tokens" +
  -                "' is not equal to length facet of '"+fLength+"' tokens.");
  -            }
  -        }
   
  -        if ((fFacetsDefined & DEFINED_ENUMERATION) != 0 ){
  -            boolean present = false;
  -            if(fEnumeration != null){
  -                for(int i = 0 ; i < fEnumeration.length ; i++){
  -                    if(isEqual(content,fEnumeration[i])){
  -                        present = true;
  -                        break;
  -                    }
  -                }
  -                if(!present){
  -                    //REVISIT: error handling
  -                    String msg = getErrorString(
  -                            DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.NOT_ENUM_VALUE],
  -                            new Object [] { fEnumeration });
  -                        throw new InvalidDatatypeValueException(msg);
  +        XSSimpleTypeDecl listDecl = new XSSimpleTypeDecl("listDecl","http://www.foo.com",SchemaSymbols.EMPTY_SET);
  +        listDecl.init4List(newDecl);
   
  -                }
  -            }
  +        try{
  +        listDecl.validate("12 neeraj",null);
  +        }catch(Exception ex){
  +            System.out.println(ex.getMessage() );
           }
   
   
  -        if(itemType.fVariety == VARIETY_ATOMIC){
  +          List & union check.
   
  -            for(int i = 0 ; i < numberOfTokens ; i++ )
  -            {
  -                try
  -                {   //check if the values are of item type
  -                    itemType.validate(parsedList.nextToken(),context);
  -                }
  -                catch(InvalidDatatypeValueException invalidValue){
  -                    //REVISIT: should we check all tokens and report error or 'get out of loop' when we get exception.
  -                    reportError(invalidValue.getMessage() );
  -                }
  -            }
  -        }
  -        else if(itemType.fVariety == VARIETY_UNION){
  -            itemType.validate(content,context);
  -        }
   
  -        return content;
  -    } //validateList()
   
  +        XSSimpleTypeDecl listDecl = new XSSimpleTypeDecl("listDecl","http://www.foo.com",SchemaSymbols.EMPTY_SET);
  +        listDecl.init4List(decimalDecl);
   
  -    private Object validateUnion(String content, ValidateContext context)throws InvalidDatatypeValueException {
  +        XSSimpleTypeDecl restDecl = new XSSimpleTypeDecl("listDecl","http://www.foo.com",SchemaSymbols.EMPTY_SET);
  +        facets[INDEX_ENUMERATION  ] = new String[]{"12 13 14","23 24 25.0"} ;
  +        restDecl.init4Restriction(listDecl,facets,FACET_ENUMERATION ,fixedFacets);
  +        try{
  +            restDecl.validate("23 24 25",null);
  +        }catch(Exception ex){
  +            System.out.println(ex.getMessage() );
  +            ex.printStackTrace() ;
  +        }
   
  -        XSSimpleTypeDecl [] memberTypes = fMemberTypes;
   
  -        // REVISIT: check it again
  -        if ( (fFacetsDefined & DEFINED_PATTERN ) != 0 ) {
  -            Enumeration keys = fPattern.elements() ;
  -            boolean matched = false;
  -            RegularExpression regex = new RegularExpression("X");
  -            while(keys.hasMoreElements() ){
  -                String pattern = (String)keys.nextElement();
  -                if (regex != null && regex.matches(pattern)){
  -                    matched = true;
  -                    break;
  -                }
  -            }
  -            if(!matched)
  -                    reportError("Value '"+content+
  -                                                            "' does not match regular expression facet '" + fPattern + "'." );
  +        XSSimpleTypeDecl newDecl = new XSSimpleTypeDecl("newDecl","http://www.foo.com",SchemaSymbols.EMPTY_SET);
  +        newDecl.init4Union(new XSSimpleTypeDecl[]{decimalDecl,stringDecl});
   
  -        }
  +        XSSimpleTypeDecl listDecl = new XSSimpleTypeDecl("listDecl","http://www.foo.com",SchemaSymbols.EMPTY_SET);
  +        listDecl.init4List(newDecl);
   
  +        XSSimpleTypeDecl restDecl = new XSSimpleTypeDecl("listDecl","http://www.foo.com",SchemaSymbols.EMPTY_SET);
  +        facets[INDEX_ENUMERATION  ] = new String[]{"12 13 14","23 24 neeraj"} ;
  +        restDecl.init4Restriction(listDecl,facets,FACET_ENUMERATION ,fixedFacets);
   
  -        if ((fFacetsDefined & DEFINED_ENUMERATION) != 0 ){
  -            boolean present = false;
  -            if(fEnumeration != null){
  -                for(int i = 0 ; i < fEnumeration.length ; i++){
  -                    if(isEqual(content,fEnumeration[i])){
  -                        present = true;
  -                        break;
  -                    }
  -                }
  -                if(!present){
  -                    //REVISIT: error handling
  -                    String msg = getErrorString(
  -                            DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.NOT_ENUM_VALUE],
  -                            new Object [] { fEnumeration });
  -                        throw new InvalidDatatypeValueException(msg);
  -
  -                }
  -            }
  +        try{
  +            restDecl.validate("23 24 neeraj",null);
  +        }catch(Exception ex){
  +            System.out.println(ex.getMessage() );
  +            ex.printStackTrace() ;
           }
   
  -        if(memberTypes != null){
  -            int noOfMemberTypes = memberTypes.length;
  -            boolean exceptionOccured = false;
  -            for(int i = 0 ; i < noOfMemberTypes ;  i ++){
  -                try{
  -                    //it should throw exception if anything goes wrong
  -                    memberTypes[i].validate(content,context);
  -                }
  -                catch(InvalidDatatypeValueException invalidValue){
  -                    exceptionOccured = true;
  -                }
  -                if(!exceptionOccured)
  -                    break;
  -            }
  -            //REVISIT:error handling
  -            if(exceptionOccured){
  -                String msg  = " content = " + content + " doesnt't match any of the member types " ;
  -                throw new InvalidDatatypeValueException(msg);
  -            }
  -        }
  -    return content;
  -    }//validateUnion()
   
  -    void reportError(String msg) {
  -        // REVISIT: how do we report datatype facet errors?
  -        // passing ErrorReporter in? return an array of errors back?
  -    }
  +        XSSimpleTypeDecl newDecl = new XSSimpleTypeDecl("newDecl","http://www.foo.com",SchemaSymbols.EMPTY_SET);
  +        newDecl.init4Union(new XSSimpleTypeDecl[]{decimalDecl,stringDecl});
   
  +        XSSimpleTypeDecl listDecl = new XSSimpleTypeDecl("listDecl","http://www.foo.com",SchemaSymbols.EMPTY_SET);
  +        listDecl.init4List(newDecl);
   
  -    //REVISIT: error handling
  -    private String whiteSpaceValue(short ws){
  -      if(ws != REPLACE)
  -        return (ws == PRESERVE)?"preserve":"collapse" ;
  -      return "replace";
  +        XSSimpleTypeDecl restDecl = new XSSimpleTypeDecl("listDecl","http://www.foo.com",SchemaSymbols.EMPTY_SET);
  +        facets[INDEX_ENUMERATION  ] = new String[]{"12 13 14","23 24 neeraj"} ;
  +        restDecl.init4Restriction(listDecl,facets,FACET_ENUMERATION ,fixedFacets);
   
  -    }
  +        try{
  +            restDecl.validate("23 24.0 neeraj",null);
  +        }catch(Exception ex){
  +            System.out.println(ex.getMessage() );
  +            ex.printStackTrace() ;
  +        }
   
  -    public String getStringValue(Object value){
  -        if(value != null)
  -            return value.toString() ;
  -        else
  -            return null;
  -    }
   
  +        XSSimpleTypeDecl newDecl = new XSSimpleTypeDecl("newDecl","http://www.foo.com",SchemaSymbols.EMPTY_SET);
  +        newDecl.init4Union(new XSSimpleTypeDecl[]{decimalDecl});
  +
  +        XSSimpleTypeDecl listDecl = new XSSimpleTypeDecl("listDecl","http://www.foo.com",SchemaSymbols.EMPTY_SET);
  +        listDecl.init4List(newDecl);
   
  -    public class ValidateContext {
  -        //REVISIT: still to complete and step 3 of validateRestriction
  -        //XSGrammarResolver grammarResolver;
  -
  -        Hashtable IDTbl = null;
  -        Hashtable IDREFTbl = null;
  -        Object fNullValue = null;
  -        //EntityResolver entityResolver;
  +        XSSimpleTypeDecl restDecl = new XSSimpleTypeDecl("listDecl","http://www.foo.com",SchemaSymbols.EMPTY_SET);
  +        facets[INDEX_ENUMERATION  ] = new String[]{"12 13 14","23 24 25"} ;
  +        restDecl.init4Restriction(listDecl,facets,FACET_ENUMERATION ,fixedFacets);
   
  -    }// class ValidateContext
  +        try{
  +            restDecl.validate("23 24.0 25",null);
  +        }catch(Exception ex){
  +            System.out.println(ex.getMessage() );
  +        }
  +*/
  +    }//main()
   
   } // class XSComplexTypeDecl
  
  
  
  1.3       +51 -24    xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/TypeValidator.java
  
  Index: TypeValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/TypeValidator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TypeValidator.java	2001/10/03 18:27:07	1.2
  +++ TypeValidator.java	2001/11/09 00:30:37	1.3
  @@ -57,41 +57,68 @@
   
   package org.apache.xerces.impl.v2.new_datatypes;
   
  -import org.apache.xerces.impl.v2.datatypes.InvalidDatatypeValueException;
  -
   /**
  - * @version $Id: TypeValidator.java,v 1.2 2001/10/03 18:27:07 neilg Exp $
  + * All primitive types plus ID/IDREF/ENTITY are derived from this abstract
  + * class. It provides extra information XSSimpleTypeDecl requires from each
  + * type: allowed facets, converting String to actual value, check equality,
  + * comparison, etc.
  + *
  + * @author Neeraj Bajaj, Sun Microsystems, inc.
  + * @author Sandy Gao, IBM
  + *
  + * @version $Id: TypeValidator.java,v 1.3 2001/11/09 00:30:37 sandygao Exp $
    */
  -public interface TypeValidator {
  -    // for most DV classes, this is the same as the DV_?? value defined
  -    // in XSSimpleTypeDecl that's corresponding to that class. But for
  -    // ID/IDREF/ENTITY, the privitivaDV is DV_STRING.
  -    public short getPrimitiveDV();
  -    public short getAllowedFacets();
  +public abstract class TypeValidator {
  +
  +    // which facets are allowed for this type
  +    public abstract short getAllowedFacets();
   
  -    // convert a string to a compiled form. for example,
  +    // convert a string to an actual value. for example,
       // for number types (decimal, double, float, and types derived from them),
       // get the BigDecimal, Double, Flout object.
       // for some types (string and derived), they just return the string itself
  -    public Object getCompiledValue(String content) throws InvalidDatatypeValueException;
  -    // the parameters are in compiled form (from getCompiledValue)
  -    public boolean isEqual(Object value1, Object value2);
  +    public abstract Object getActualValue(String content, ValidationContext context)
  +        throws InvalidDatatypeValueException;
  +
  +    // for ID/IDREF/ENTITY types, do some extra checking after the value is
  +    // checked to be valid with respect to both lexical representation and
  +    // facets
  +    public void checkExtraRules(Object value, ValidationContext context) throws InvalidDatatypeValueException {
  +    }
  +
  +    // whether two values are equal
  +    // the parameters are in compiled form (from getActualValue)
  +    public boolean isEqual(Object value1, Object value2) {
  +        return value1.equals(value2);
  +    }
   
       // the following methods might not be supported by every DV.
       // but XSSimpleTypeDecl should know which type supports which methods,
       // and it's an *internal* error if a method is called on a DV that
       // doesn't support it.
  +
  +    // check the order relation between the two values
  +    // the parameters are in compiled form (from getActualValue)
  +    public int compare(Object value1, Object value2) {
  +        return -1;
  +    }
  +
  +    // get the length of the value
  +    // the parameters are in compiled form (from getActualValue)
  +    public int getDataLength(Object value) {
  +        return (value instanceof String) ? ((String)value).length() : -1;
  +    }
  +
  +    // get the number of digits of the value
  +    // the parameters are in compiled form (from getActualValue)
  +    public int getTotalDigits(Object value) {
  +        return -1;
  +    }
  +
  +    // get the number of fraction digits of the value
  +    // the parameters are in compiled form (from getActualValue)
  +    public int getFractionDigits(Object value) {
  +        return -1;
  +    }
   
  -    public static final short COMPARE_LESS    = -1;
  -    public static final short COMPARE_EQUAL   = 0;
  -    public static final short COMPARE_GREATER = 1;
  -    // the parameters are in compiled form (from getCompiledValue)
  -    public int compare(Object value1, Object value2);
  -
  -    // the parameters are in compiled form (from getCompiledValue)
  -    public int getDataLength(Object value);
  -    // the parameters are in compiled form (from getCompiledValue)
  -    public int getTotalDigits(Object value);
  -    // the parameters are in compiled form (from getCompiledValue)
  -    public int getFractionDigits(Object value);
   } // interface TypeValidator
  
  
  
  1.2       +25 -36    xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/TimeDV.java
  
  Index: TimeDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/TimeDV.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TimeDV.java	2001/10/04 21:02:50	1.1
  +++ TimeDV.java	2001/11/09 00:30:37	1.2
  @@ -3,7 +3,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
  @@ -11,7 +11,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
  @@ -19,7 +19,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,
  @@ -27,7 +27,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",
  @@ -58,41 +58,33 @@
   
   package org.apache.xerces.impl.v2.new_datatypes;
   
  -import org.apache.xerces.impl.v2.datatypes.InvalidDatatypeValueException;
  -import org.apache.xerces.impl.v2.datatypes.SchemaDateTimeException;
   /**
    * Validator for <time> datatype (W3C Schema Datatypes)
  - * 
  + *
    * @author Elena Litani
    * @author Gopal Sharma, SUN Microsystem Inc.
  + *
  + * @version $Id: TimeDV.java,v 1.2 2001/11/09 00:30:37 sandygao Exp $
    */
   public class TimeDV extends AbstractDateTimeDV {
   
       /**
  -     @return Index of TimeDV
  -	*/
  -	public short getPrimitiveDV(){
  -		return XSSimpleTypeDecl.DV_TIME;
  -    }
  -   
  -	/**
        * Convert a string to a compiled form
  -	 * 
  -	 * @param  content The lexical representation of time
  -	 * @return a valid and normalized time object
  -	 */
  -	public Object  getCompiledValue(String content) throws InvalidDatatypeValueException{
  -			int[] date=null;
  -			try{
  -					date= parse(content, null);
  -			}catch(Exception ex){
  -			}
  -			return date;
  -	}
  -    
  -	/**
  +     *
  +     * @param  content The lexical representation of time
  +     * @return a valid and normalized time object
  +     */
  +    public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException{
  +        try{
  +            return parse(content, null);
  +        } catch(Exception ex){
  +            throw new InvalidDatatypeValueException("not a valid time");
  +        }
  +    }
  +
  +    /**
        * Parses, validates and computes normalized version of time object
  -     * 
  +     *
        * @param str    The lexical representation of time object hh:mm:ss.sss
        *               with possible time zone Z or (-),(+)hh:mm
        *               Pattern: "(\\d\\d):(\\d\\d):(\\d\\d)(\\.(\\d)*)?(Z|(([-+])(\\d\\d)(:(\\d\\d))?))?")
  @@ -101,7 +93,7 @@
        * @exception Exception Invalid lexical representation
        */
       protected int[] parse(String str, int[] date) throws SchemaDateTimeException{
  -        
  +
           resetBuffer(str);
   
           //create structure to hold an object
  @@ -118,23 +110,21 @@
           getTime(fStart, fEnd, date);
   
           //validate and normalize
  -        
  +
           validateDateTime(date);
  -        
  +
           if ( date[utc]!=0 ) {
               normalize(date);
           }
                   return date;
       }
   
  -
       /**
        * Converts time object representation to String
  -     * 
  +     *
        * @param date   time object
        * @return lexical representation of time: hh:mm:ss.sss with an optional time zone sign
        */
  -     
       protected String dateToString(int[] date) {
           message.setLength(0);
           message.append(date[h]);
  @@ -147,7 +137,6 @@
           message.append((char)date[utc]);
           return message.toString();
       }
  -     
   
   }
   
  
  
  
  1.3       +13 -22    xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/StringDV.java
  
  Index: StringDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/StringDV.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StringDV.java	2001/10/03 18:27:07	1.2
  +++ StringDV.java	2001/11/09 00:30:37	1.3
  @@ -57,34 +57,25 @@
   
   package org.apache.xerces.impl.v2.new_datatypes;
   
  -import org.apache.xerces.impl.v2.datatypes.InvalidDatatypeValueException;
  -import org.apache.xerces.impl.v2.datatypes.DatatypeMessageProvider;
  -
   import java.util.Locale;
  -import java.text.Collator;
  -
   
   /**
  - * @version $Id: StringDV.java,v 1.2 2001/10/03 18:27:07 neilg Exp $
  + * Represent the schema type "string"
  + *
  + * @author Neeraj Bajaj, Sun Microsystems, inc.
  + * @author Sandy Gao, IBM
  + *
  + * @version $Id: StringDV.java,v 1.3 2001/11/09 00:30:37 sandygao Exp $
    */
  -public class StringDV extends AbstractStringDV{
  -    // for most DV classes, this is the same as the DV_?? value defined
  -    // in XSSimpleTypeDecl that's corresponding to that class. But for
  -    // ID/IDREF/ENTITY, the privitivaDV is DV_STRING.
  -    public short getPrimitiveDV(){
  -	      return XSSimpleTypeDecl.DV_STRING;
  -    }//getPrimitiveDV()
  -
  +public class StringDV extends TypeValidator {
   
  -    // the following methods might not be supported by every DV.
  -    // but XSSimpleTypeDecl should know which type supports which methods,
  -    // and it's an *internal* error if a method is called on a DV that
  -    // doesn't support it.
  -
  -
  -    public int compare(Object value1, Object value2){
  -	      return ((String)value1).equals((String)value2) ? 0 :-1 ;
  +    public short getAllowedFacets(){
  +        return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE );
       }
   
  +    public Object getActualValue(String content, ValidationContext context)
  +        throws InvalidDatatypeValueException {
  +        return content;
  +    }
   
   } // class StringDV
  
  
  
  1.3       +39 -50    xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/QNameDV.java
  
  Index: QNameDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/QNameDV.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- QNameDV.java	2001/10/03 18:27:07	1.2
  +++ QNameDV.java	2001/11/09 00:30:37	1.3
  @@ -57,71 +57,60 @@
   
   package org.apache.xerces.impl.v2.new_datatypes;
   
  -//internal imports
   import org.apache.xerces.util.XMLChar;
  -import org.apache.xerces.impl.v2.datatypes.InvalidDatatypeValueException;
  -import org.apache.xerces.impl.v2.datatypes.DatatypeMessageProvider;
  +import org.apache.xerces.xni.QName;
   
  -import java.util.Locale;
  -import java.text.Collator;
  -
   /**
  - * @version $Id: QNameDV.java,v 1.2 2001/10/03 18:27:07 neilg Exp $
  + * Represent the schema type "QName" and "NOTATION"
  + *
  + * @author Neeraj Bajaj, Sun Microsystems, inc.
  + * @author Sandy Gao, IBM
  + *
  + * @version $Id: QNameDV.java,v 1.3 2001/11/09 00:30:37 sandygao Exp $
    */
  -public  class QNameDV extends AbstractStringDV{
  -
  -    protected DatatypeMessageProvider fMessageProvider = new DatatypeMessageProvider();
  -    protected Locale fLocale = null;
  +public class QNameDV extends TypeValidator {
   
  +    private static final String EMPTY_STRING = "";
   
  -    // for most DV classes, this is the same as the DV_?? value defined
  -    // in XSSimpleTypeDecl that's corresponding to that class. But for
  -    // ID/IDREF/ENTITY, the privitivaDV is DV_STRING.
  -
  -    public short getPrimitiveDV(){
  -        return XSSimpleTypeDecl.DV_QNAME;
  +    public short getAllowedFacets() {
  +        return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE);
       }
   
  +    public Object getActualValue(String content, ValidationContext context)
  +        throws InvalidDatatypeValueException {
   
  -    // convert a string to a compiled form. for example,
  -    // for number types (decimal, double, float, and types derived from them),
  -    // get the BigDecimal, Double, Flout object.
  -    // for some types (string and derived), they just return the string itself
  -    public Object getCompiledValue(String content) throws InvalidDatatypeValueException{
  -        //NCNames check should be done here.
  -        boolean NCName = false;
  -        int posColon = content.indexOf(':');
  -        if (posColon >= 0){
  -            if( !XMLChar.isValidNCName(content.substring(0,posColon)) ||
  -                !XMLChar.isValidNCName(content.substring(posColon+1))){
  -                NCName = false;
  -            }
  +        // "prefix:localpart" or "localpart"
  +        // get prefix and local part out of content
  +        String prefix, localpart;
  +        int colonptr = content.indexOf(":");
  +        if (colonptr > 0) {
  +            prefix = context.getSymbol(content.substring(0,colonptr));
  +            localpart = content.substring(colonptr+1);
  +        } else {
  +            prefix = context.getSymbol(EMPTY_STRING);
  +            localpart = content;
           }
  -        if(!NCName)
  -            throw new InvalidDatatypeValueException("Value '"+content+"' is not a valid QName");
  -
  -        return content;
   
  -    }//getCompiledValue()
  +        // both prefix (if any) and localpart must be valid NCName
  +        if (prefix.length() > 0 && !XMLChar.isValidNCName(prefix))
  +            throw new InvalidDatatypeValueException("Value '"+content+"' is not a valid QName: '" + prefix + "' is not an NCName");
  +
  +        if(!XMLChar.isValidNCName(localpart))
  +            throw new InvalidDatatypeValueException("Value '"+content+"' is not a valid QName: '" + localpart + "' is not an NCName");
  +
  +        // resove prefix to a uri, report an error if failed
  +        String uri = context.getURI(prefix);
  +        if (prefix.length() > 0 && uri == null)
  +            throw new InvalidDatatypeValueException("Value '"+content+"' is not a valid QName: cannot resolve the prefix to a namespace uri");
   
  +        return new QName(prefix, localpart, content, uri);
   
  -    // the parameters are in compiled form (from getCompiledValue)
  -    public boolean isEqual(Object value1, Object value2){
  -        return ((String)value1).equals((String)value2);
       }
   
  -    // the following methods might not be supported by every DV.
  -    // but XSSimpleTypeDecl should know which type supports which methods,
  -    // and it's an *internal* error if a method is called on a DV that
  -    // doesn't support it.
  -
  -
  -    public  int compare(Object value1, Object value2) {
  -        Locale    loc       = Locale.getDefault();
  -        Collator  collator  = Collator.getInstance( loc );
  -        return collator.compare( (String)value1 , (String)value2 );
  +    // REVISIT: qname and notation shouldn't support length facets.
  +    //          now we just return the length of the rawname
  +    public int getDataLength(Object value) {
  +        return ((QName)value).rawname.length();
       }
  -
  -
   
   } // class QNameDVDV
  
  
  
  1.2       +30 -40    xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/MonthDV.java
  
  Index: MonthDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/MonthDV.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MonthDV.java	2001/10/04 21:02:50	1.1
  +++ MonthDV.java	2001/11/09 00:30:37	1.2
  @@ -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",
  @@ -57,44 +57,34 @@
   
   package org.apache.xerces.impl.v2.new_datatypes;
   
  -import org.apache.xerces.impl.v2.datatypes.InvalidDatatypeValueException;
  -import org.apache.xerces.impl.v2.datatypes.SchemaDateTimeException;
   /**
    * Validator for <gMonth> datatype (W3C Schema Datatypes)
  - * 
  + *
    * @author Elena Litani
    * @author Gopal Sharma, SUN Microsystem Inc.
  + *
  + * @version $Id: MonthDV.java,v 1.2 2001/11/09 00:30:37 sandygao Exp $
    */
   
   public class MonthDV extends AbstractDateTimeDV {
   
       /**
  -     @return Index of MonthDV
  -	*/
  -
  -	public short getPrimitiveDV(){
  -		return XSSimpleTypeDecl.DV_GMONTH;
  -    }
  -   
  -	/**
        * Convert a string to a compiled form
  -	 * 
  -	 * @param  content The lexical representation of gMonth
  -	 * @return a valid and normalized gMonth object
  -	 */
  -	public Object  getCompiledValue(String content) throws InvalidDatatypeValueException{
  -			int[] date=null;
  -			try{
  -					date= parse(content, null);
  -			}catch(Exception ex){
  -			}
  -			return date;
  -	}
  -
  +     *
  +     * @param  content The lexical representation of gMonth
  +     * @return a valid and normalized gMonth object
  +     */
  +    public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException{
  +        try{
  +            return parse(content, null);
  +        } catch(Exception ex){
  +            throw new InvalidDatatypeValueException("not a valid month");
  +        }
  +    }
   
       /**
        * Parses, validates and computes normalized version of gMonth object
  -     * 
  +     *
        * @param str    The lexical representation of gMonth object --MM--
        *               with possible time zone Z or (-),(+)hh:mm
        * @param date   uninitialized date object
  @@ -134,7 +124,7 @@
           }
           //validate and normalize
           validateDateTime(date);
  -        
  +
           if ( date[utc]!=0 && date[utc]!='Z' ) {
               normalize(date);
           }
  @@ -143,44 +133,44 @@
   
       /**
        * Overwrite compare algorithm to optimize month comparison
  -     * 
  +     *
        * @param date1
        * @param date2
  -     * @return 
  +     * @return
        */
       protected  int compareDates(int[] date1, int[] date2) {
   
           if ( date1[utc]==date2[utc] ) {
  -            return (date1[M]>=date2[M])?(date1[M]>date2[M])?COMPARE_LESS:COMPARE_EQUAL:COMPARE_GREATER;
  +            return (date1[M]>=date2[M])?(date1[M]>date2[M])?-1:0:1;
           }
   
           if ( date1[utc]=='Z' || date2[utc]=='Z' ) {
  -            
  +
               if ( date1[M]==date2[M] ) {
                   //--05--Z and --05--
                   return INDETERMINATE;
               }
               if ( (date1[M]+1 == date2[M] || date1[M]-1 == date2[M]) ) {
  -                //--05--Z and (--04-- or --05--) 
  -                //REVISIT: should this case be less than or equal? 
  +                //--05--Z and (--04-- or --05--)
  +                //REVISIT: should this case be less than or equal?
                   //         maxExclusive should fail but what about maxInclusive
  -                //         
  +                //
                   return INDETERMINATE;
               }
           }
   
           if ( date1[M]<date2[M] ) {
  -            return COMPARE_LESS;
  +            return -1;
           }
           else {
  -            return COMPARE_GREATER;
  +            return 1;
           }
   
       }
   
       /**
        * Converts month object representation to String
  -     * 
  +     *
        * @param date   month object
        * @return lexical representation of month: --MM-- with an optional time zone sign
        */
  
  
  
  1.2       +26 -37    xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/MonthDayDV.java
  
  Index: MonthDayDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/MonthDayDV.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MonthDayDV.java	2001/10/04 21:02:50	1.1
  +++ MonthDayDV.java	2001/11/09 00:30:37	1.2
  @@ -3,7 +3,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
  @@ -11,7 +11,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
  @@ -19,7 +19,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,
  @@ -27,7 +27,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",
  @@ -58,47 +58,37 @@
   
   package org.apache.xerces.impl.v2.new_datatypes;
   
  -import org.apache.xerces.impl.v2.datatypes.InvalidDatatypeValueException;
  -import org.apache.xerces.impl.v2.datatypes.SchemaDateTimeException;
   /**
    * Validator for <gMonthDay> datatype (W3C Schema Datatypes)
  - * 
  + *
    * @author Elena Litani
    * @author Gopal Sharma, SUN Microsystem Inc.
  + *
  + * @version $Id: MonthDayDV.java,v 1.2 2001/11/09 00:30:37 sandygao Exp $
    */
   
   public class MonthDayDV extends AbstractDateTimeDV {
   
  -    //size without time zone: --MM-DD    
  +    //size without time zone: --MM-DD
       private final static int MONTHDAY_SIZE = 7;
   
       /**
  -     * @return Index of MonthDayDV
  -	 */
  -
  -	public short getPrimitiveDV(){
  -		return XSSimpleTypeDecl.DV_GMONTHDAY;
  +     * Convert a string to a compiled form
  +     *
  +     * @param  content The lexical representation of gMonthDay
  +     * @return a valid and normalized gMonthDay object
  +     */
  +    public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
  +        try{
  +            return parse(content, null);
  +        } catch(Exception ex){
  +            throw new InvalidDatatypeValueException("not a valid monthDay");
  +        }
       }
   
       /**
  -     * Convert a string to a compiled form
  -	 * 
  -	 * @param  content The lexical representation of gMonthDay
  -	 * @return a valid and normalized gMonthDay object
  -	 */
  -	public Object  getCompiledValue(String content) throws InvalidDatatypeValueException{
  -			int[] date=null;
  -			try{
  -					date= parse(content, null);
  -			}catch(Exception ex){
  -			}
  -			return date;
  -	}
  -
  -
  -    /** 
        * Parses, validates and computes normalized version of gMonthDay object
  -     * 
  +     *
        * @param str    The lexical representation of gMonthDay object --MM-DD
        *               with possible time zone Z or (-),(+)hh:mm
        * @param date   uninitialized date object
  @@ -115,7 +105,7 @@
           }
           resetDateObj(date);
   
  -        //initialize 
  +        //initialize
           date[CY]=YEAR;
   
           if (fBuffer.charAt(0)!='-' || fBuffer.charAt(1)!='-') {
  @@ -123,11 +113,11 @@
           }
           date[M]=parseInt(fStart+2,fStart+4);
           fStart+=4;
  -        
  +
           if (fBuffer.charAt(fStart++)!='-') {
               throw new SchemaDateTimeException("Invalid format for gMonthDay: " + str);
           }
  -        
  +
           date[D]=parseInt(fStart, fStart+2);
   
           if ( MONTHDAY_SIZE<fEnd ) {
  @@ -140,19 +130,18 @@
               }
           }
           //validate and normalize
  +
  +        validateDateTime(date);
   
  -		validateDateTime(date);
  -        
           if ( date[utc]!=0 && date[utc]!='Z' ) {
               normalize(date);
           }
           return date;
       }
   
  -
       /**
        * Converts gMonthDay object representation to String
  -     * 
  +     *
        * @param date   gmonthDay object
        * @return lexical representation of month: --MM-DD with an optional time zone sign
        */
  
  
  
  1.3       +17 -87    xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/HexBinaryDV.java
  
  Index: HexBinaryDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/HexBinaryDV.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HexBinaryDV.java	2001/10/02 19:19:18	1.2
  +++ HexBinaryDV.java	2001/11/09 00:30:37	1.3
  @@ -57,99 +57,29 @@
   
   package org.apache.xerces.impl.v2.new_datatypes;
   
  -//internal imports
  -import org.apache.xerces.impl.v2.util.HexBin;
  -import org.apache.xerces.impl.v2.datatypes.InvalidDatatypeValueException;
  -
  -//java imports
  +import org.apache.xerces.impl.xs.util.HexBin;
   import java.io.UnsupportedEncodingException;
   
   /**
  - * @version $Id: HexBinaryDV.java,v 1.2 2001/10/02 19:19:18 neilg Exp $
  + * Represent the schema type "hexBinary"
  + *
  + * @author Neeraj Bajaj, Sun Microsystems, inc.
  + * @author Sandy Gao, IBM
  + *
  + * @version $Id: HexBinaryDV.java,v 1.3 2001/11/09 00:30:37 sandygao Exp $
    */
  -public class HexBinaryDV extends AbstractStringDV{
  -
  -    // for most DV classes, this is the same as the DV_?? value defined
  -    // in XSSimpleTypeDecl that's corresponding to that class. But for
  -    // ID/IDREF/ENTITY, the privitivaDV is DV_STRING.
  -
  -    public short getPrimitiveDV(){
  -        return XSSimpleTypeDecl.DV_HEXBINARY;
  -    }
  +public class HexBinaryDV extends TypeValidator {
   
  -    // convert a string to a compiled form. for example,
  -    // for number types (decimal, double, float, and types derived from them),
  -    // get the BigDecimal, Double, Flout object.
  -    // for some types (string and derived), they just return the string itself
  -    public Object getCompiledValue(String content) throws InvalidDatatypeValueException{
  -        if (getDataLength(content) < 0) {
  -            throw new InvalidDatatypeValueException( "Value '"+content+"' is not encoded in Hex" );
  -        }
  -        return content;
  +    public short getAllowedFacets(){
  +        return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE );
       }
  -
  -
  -    // the parameters are in compiled form (from getCompiledValue)
  -    public boolean isEqual(Object value1, Object value2){
  -
  -        return compare(value1,value2) == 0 ? true : false;
  -
  -    }//isEqual()
  -
  -    // the following methods might not be supported by every DV.
  -    // but XSSimpleTypeDecl should know which type supports which methods,
  -    // and it's an *internal* error if a method is called on a DV that
  -    // doesn't support it.
  -
  -    //compiled value is string in this case ,as we return string for all derived by string.
  -    public  int compare(Object value1, Object value2){
  -
  -        String str1 = (String)value1;
  -        String str2 = (String)value2;
   
  -        if (str1 == null || str2 == null)
  -            return -1;
  +    public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
  +        String decoded = HexBin.decode(content);
  +        if (decoded == null)
  +            throw new InvalidDatatypeValueException("Value '"+content+"' is not encoded in Hex");
   
  -        if (str1 == str2 || str1.equals(str2))
  -            return 0;
  -
  -        byte[] data1=HexBin.decode(str1.getBytes());
  -        byte[] data2=HexBin.decode(str2.getBytes());
  -
  -        if (data1 == null || data2 == null)
  -            return -1;
  -
  -        for (int i = 0; i < Math.min(data1.length, data2.length); i++){
  -            if (data1[i] < data2[i])
  -                return -1;
  -            else if (data1[i] > data2[i])
  -                return 1;
  -        }
  -
  -        if (data1.length == data2.length)
  -            return 0;
  -
  -        return data1.length > data2.length ? 1 : -1;
  -
  -    }//compare()
  -
  -
  -    //compiled value is string in this case ,as we return string for all derived by string.
  -    //for hex bin length is measured in octets of binary data.
  -    public int getDataLength(Object value){
  -        int x = -1;
  -        String content = (String)value;
  -        try {
  -            if(content != null){
  -                x = HexBin.getDecodedDataLength(content.getBytes("utf-8"));
  -            }
  -        }
  -        catch (UnsupportedEncodingException e) {
  -        }
  -        finally {
  -            return x;
  -        }
  -    }//getDataLength()
  -
  +        return decoded;
  +    }
   
  -} // class AbstractStringDV
  +}
  
  
  
  1.3       +17 -49    xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/FloatDV.java
  
  Index: FloatDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/FloatDV.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FloatDV.java	2001/10/03 18:27:07	1.2
  +++ FloatDV.java	2001/11/09 00:30:37	1.3
  @@ -57,63 +57,33 @@
   
   package org.apache.xerces.impl.v2.new_datatypes;
   
  -//internal imports
  -import org.apache.xerces.impl.v2.datatypes.InvalidDatatypeValueException;
  -import org.apache.xerces.impl.v2.datatypes.DatatypeMessageProvider;
  -
  -
   /**
  - * @version $Id: FloatDV.java,v 1.2 2001/10/03 18:27:07 neilg Exp $
  + * Represent the schema type "float"
  + *
  + * @author Neeraj Bajaj, Sun Microsystems, inc.
  + * @author Sandy Gao, IBM
  + *
  + * @version $Id: FloatDV.java,v 1.3 2001/11/09 00:30:37 sandygao Exp $
    */
  -public class FloatDV extends AbstractNumericDV{
  -    // for most DV classes, this is the same as the DV_?? value defined
  -    // in XSSimpleTypeDecl that's corresponding to that class. But for
  -    // ID/IDREF/ENTITY, the privitivaDV is DV_STRING.
  -    public short getPrimitiveDV(){
  -        return XSSimpleTypeDecl.DV_FLOAT;
  -    }
  +public class FloatDV extends TypeValidator {
   
  -    //convert a String to Float form, we have to take care of cases specified in spec like INF, -INF and NaN
  -    public Object getCompiledValue(String content) throws InvalidDatatypeValueException{
  +    public short getAllowedFacets(){
  +        return ( XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_WHITESPACE | XSSimpleTypeDecl.FACET_ENUMERATION |XSSimpleTypeDecl.FACET_MAXINCLUSIVE |XSSimpleTypeDecl.FACET_MININCLUSIVE | XSSimpleTypeDecl.FACET_MAXEXCLUSIVE  | XSSimpleTypeDecl.FACET_MINEXCLUSIVE  );
  +    }//getAllowedFacets()
   
  -        Float compiledValue = null;
  -
  +    //convert a String to Float form, we have to take care of cases specified in spec like INF, -INF and NaN
  +    public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
           try{
  -            compiledValue = fValueOf(content);
  -        }catch(Exception ex){
  -        String msg = getErrorString(
  -                                           DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.NOT_FLOAT ],
  -                                           new Object[] { "'" + content +"'"});
  -        throw new InvalidDatatypeValueException(msg);
  -        }
  -        return compiledValue;
  -    }//getCompiledValue()
  -
  -
  -    // Float equals method takes care of cases specified for Float in schema spec.
  -    public boolean isEqual(Object value1, Object value2){
  -        if(value1 != null && value2 != null){
  -            if(value1 instanceof Float && value2 instanceof Float){
  -                return ((Float)value1).equals((Float)value2);
  -            }
  -            return false;
  +            return fValueOf(content);
  +        } catch (Exception ex){
  +            throw new InvalidDatatypeValueException(DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.NOT_FLOAT ],
  +                                                    new Object[]{content});
           }
  -        else //REVISIT: should we throw error for not getting right object or to be taken care in XSSimpleTypeDecl.
  -            return false;
  -    }//isEqual()
  -
  -    // the following methods might not be supported by every DV.
  -    // but XSSimpleTypeDecl should know which type supports which methods,
  -    // and it's an *internal* error if a method is called on a DV that
  -    // doesn't support it.
  +    }//getActualValue()
   
  -
       // Float compareTo method takes care of cases specified for Float in schema spec.
       public int compare(Object value1, Object value2){
  -	      if(value1 instanceof Float && value2 instanceof Float)
  -            return ((Float)value1).compareTo((Float)value2)  ;
  -        else
  -            return -1;
  +        return ((Float)value1).compareTo((Float)value2);
       }//compare()
   
       //takes care of special values positive, negative infinity and Not a Number as per the spec.
  @@ -138,7 +108,5 @@
           }
           return f;
       }
  -
  -
   
   } // class FloatDV
  
  
  
  1.2       +18 -57    xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/DoubleDV.java
  
  Index: DoubleDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/DoubleDV.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DoubleDV.java	2001/10/02 18:46:09	1.1
  +++ DoubleDV.java	2001/11/09 00:30:37	1.2
  @@ -57,68 +57,32 @@
   
   package org.apache.xerces.impl.v2.new_datatypes;
   
  -//internal imports
  -import org.apache.xerces.impl.v2.datatypes.InvalidDatatypeValueException;
  -import org.apache.xerces.impl.v2.datatypes.DatatypeMessageProvider;
  -
  -//java import
  -
   /**
  - * @version $Id: DoubleDV.java,v 1.1 2001/10/02 18:46:09 neilg Exp $
  + * Represent the schema type "double"
  + *
  + * @author Neeraj Bajaj, Sun Microsystems, inc.
  + * @author Sandy Gao, IBM
  + *
  + * @version $Id: DoubleDV.java,v 1.2 2001/11/09 00:30:37 sandygao Exp $
    */
  -public class DoubleDV extends AbstractNumericDV{
  -    // for most DV classes, this is the same as the DV_?? value defined
  -    // in XSSimpleTypeDecl that's corresponding to that class. But for
  -    // ID/IDREF/ENTITY, the privitivaDV is DV_STRING.
  -    public short getPrimitiveDV(){
  -	      return XSSimpleTypeDecl.DV_DOUBLE;
  -    }
  -
  -    //convert a String to Double form, we have to take care of cases specified in spec like INF, -INF and NaN
  -    public Object getCompiledValue(String content) throws InvalidDatatypeValueException{
  +public class DoubleDV extends TypeValidator {
   
  -        Double compiledValue = null;
  +    public short getAllowedFacets(){
  +        return ( XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_WHITESPACE | XSSimpleTypeDecl.FACET_ENUMERATION |XSSimpleTypeDecl.FACET_MAXINCLUSIVE |XSSimpleTypeDecl.FACET_MININCLUSIVE | XSSimpleTypeDecl.FACET_MAXEXCLUSIVE  | XSSimpleTypeDecl.FACET_MINEXCLUSIVE  );
  +    }//getAllowedFacets()
   
  +    //convert a String to Double form, we have to take care of cases specified in spec like INF, -INF and NaN
  +    public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
           try{
  -            compiledValue = dValueOf(content);
  -        }catch(Exception ex){
  -        String msg = getErrorString(
  -                                           DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.NOT_DOUBLE ],
  -                                           new Object[] { "'" + content +"'"});
  -        throw new InvalidDatatypeValueException(msg);
  -        }
  -        return compiledValue;
  -    }//getCompiledValue()
  -
  -    //Double equals method takes care of cases specified for double in schema spec.
  -    public boolean isEqual(Object value1, Object value2){
  -        if(value1 != null && value2 != null){
  -            if(value1 instanceof Double && value2 instanceof Double){
  -                return ((Double)value1).equals((Double)value2);
  -            }
  -            return false;
  +            return dValueOf(content);
  +        } catch (Exception ex){
  +            throw new InvalidDatatypeValueException(DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.NOT_DOUBLE ],
  +                                                    new Object[]{content});
           }
  +    }//getActualValue()
   
  -        else //REVISIT: should we throw error for not getting right object or to be taken care in XSSimpleTypeDecl.
  -            return false;
  -    }//isEqual()
  -
  -    // the following methods might not be supported by every DV.
  -    // but XSSimpleTypeDecl should know which type supports which methods,
  -    // and it's an *internal* error if a method is called on a DV that
  -    // doesn't support it.
  -
  -
  -    // Double compareTo method takes care of cases specified for double in schema spec.
  -    public int compare(Object value1, Object value2){
  -        if(value1 != null && value2 != null){
  -	          if(value1 instanceof Double && value2 instanceof Double){
  -                return ((Double)value1).compareTo((Double)value2)  ;
  -            }
  -            return -1;
  -        }
  -        else
  -            return -1;
  +    public int compare(Object value1, Object value2) {
  +        return ((Double)value1).compareTo((Double)value2);
       }//compare()
   
       //
  @@ -145,8 +109,5 @@
           }
           return d;
       }//dValueOf()
  -
  -
  -
   
   } // class DoubleDV
  
  
  
  1.2       +22 -72    xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/DecimalDV.java
  
  Index: DecimalDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/DecimalDV.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DecimalDV.java	2001/10/02 18:46:09	1.1
  +++ DecimalDV.java	2001/11/09 00:30:37	1.2
  @@ -57,95 +57,45 @@
   
   package org.apache.xerces.impl.v2.new_datatypes;
   
  -//internal imports
  -import org.apache.xerces.impl.v2.datatypes.InvalidDatatypeValueException;
  -import org.apache.xerces.impl.v2.datatypes.DatatypeMessageProvider;
  -
  -//java imports
   import java.math.BigDecimal;
   
   /**
  - * @version $Id: DecimalDV.java,v 1.1 2001/10/02 18:46:09 neilg Exp $
  + * Represent the schema type "decimal"
  + *
  + * @author Neeraj Bajaj, Sun Microsystems, inc.
  + * @author Sandy Gao, IBM
  + *
  + * @version $Id: DecimalDV.java,v 1.2 2001/11/09 00:30:37 sandygao Exp $
    */
  -public class DecimalDV extends AbstractNumericDV{
  -    // for most DV classes, this is the same as the DV_?? value defined
  -    // in XSSimpleTypeDecl that's corresponding to that class. But for
  -    // ID/IDREF/ENTITY, the privitivaDV is DV_STRING.
  -    public short getPrimitiveDV(){
  -	      return XSSimpleTypeDecl.DV_DECIMAL;
  -    }
  +public class DecimalDV extends TypeValidator {
   
  -    /**
  -    * return the facets allowed by Decimal
  -    */
       public short getAllowedFacets(){
  -	      return (short)(super.getAllowedFacets() |XSSimpleTypeDecl.DEFINED_TOTALDIGITS | XSSimpleTypeDecl.DEFINED_FRACTIONDIGITS);
  -    }//getAllowedFacets()
  -
  -
  -    // convert a string to a compiled form. for example,
  -    // for number types (decimal, double, float, and types derived from them),
  -    // get the BigDecimal, Double, Flout object.
  -    // for some types (string and derived), they just return the string itself
  -    public Object getCompiledValue(String content) throws InvalidDatatypeValueException{
  +        return ( XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_WHITESPACE | XSSimpleTypeDecl.FACET_ENUMERATION |XSSimpleTypeDecl.FACET_MAXINCLUSIVE |XSSimpleTypeDecl.FACET_MININCLUSIVE | XSSimpleTypeDecl.FACET_MAXEXCLUSIVE  | XSSimpleTypeDecl.FACET_MINEXCLUSIVE | XSSimpleTypeDecl.FACET_TOTALDIGITS | XSSimpleTypeDecl.FACET_FRACTIONDIGITS);
  +    }
   
  -	  BigDecimal bigDecimal = null; // Is content a Decimal
  +    public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
           try {
  -            bigDecimal = new BigDecimal( stripPlusIfPresent( content));
  -        }
  -        catch (Exception nfe) {
  -            String msg = getErrorString(
  -                                       DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.NOT_DECIMAL],
  -                                       new Object[] { "'" + content +"'"});
  -            throw new InvalidDatatypeValueException(msg);
  +            return new BigDecimal( stripPlusIfPresent( content));
  +        } catch (Exception nfe) {
  +            throw new InvalidDatatypeValueException(DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.NOT_DECIMAL],
  +                                                    new Object[]{content});
           }
  +    } //getActualValue()
   
  -    	return bigDecimal;
  -    } //getCompiledValue()
  -
  -
  -    // the parameters are in compiled form (from getCompiledValue)
  -    public boolean isEqual(Object value1, Object value2){
  -        if(value1 instanceof BigDecimal && value2 instanceof BigDecimal)
  -            return value1.equals(value2);
  -        else //REVISIT: to be taken care in XSSimpleTypeDecl.
  -            return false;
  -    }
  -
  -    // the following methods might not be supported by every DV.
  -    // but XSSimpleTypeDecl should know which type supports which methods,
  -    // and it's an *internal* error if a method is called on a DV that
  -    // doesn't support it.
  -
  -
  -
  -    // the  parameters are in compiled form (from getCompiledValue)
       public int compare(Object value1, Object value2){
  -        if(value1 instanceof BigDecimal && value2 instanceof BigDecimal)
  -	          return ((BigDecimal)value1).compareTo((BigDecimal)value2);
  -        else
  -            return -1;
  -    }//compare()
  -
  +        return ((BigDecimal)value1).compareTo((BigDecimal)value2);
  +    }
   
  -    // the parameters are in compiled form (from getCompiledValue)
       public int getTotalDigits(Object value){
  -        if(value instanceof BigDecimal)
  -	          return ((BigDecimal)value).movePointRight(((BigDecimal)value).scale()).toString().length() -
  -                             ((((BigDecimal)value).signum() < 0) ? 1 : 0); // account for minus sign
  -        else
  -            return -1;
  +        return ((BigDecimal)value).movePointRight(((BigDecimal)value).scale()).toString().length() -
  +                ((((BigDecimal)value).signum() < 0) ? 1 : 0); // account for minus sign
       }
   
  -    // the parameters are in compiled form (from getCompiledValue)
       public int getFractionDigits(Object value){
  -	      if(value instanceof BigDecimal)
  -            return ((BigDecimal)value).scale();
  -        else
  -            return -1;
  -    }//getFractionDigits()
  +        return ((BigDecimal)value).scale();
  +    }
   
  -     /**
  +    /**
        * This class deals with a bug in BigDecimal class
        * present up to version 1.1.2. 1.1.3 knows how
        * to deal with the + sign.
  @@ -160,7 +110,7 @@
        * @param value
        * @return
        */
  -    static private String stripPlusIfPresent( String value ) {
  +    static private String stripPlusIfPresent(String value) {
           String strippedPlus = value;
   
           if (value.length() >= 2 && value.charAt(0) == '+' && value.charAt(1) != '-') {
  
  
  
  1.3       +10 -23    xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/DayDV.java
  
  Index: DayDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/DayDV.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DayDV.java	2001/10/03 18:27:07	1.2
  +++ DayDV.java	2001/11/09 00:30:37	1.3
  @@ -58,39 +58,26 @@
   
   package org.apache.xerces.impl.v2.new_datatypes;
   
  -import org.apache.xerces.impl.v2.datatypes.SchemaDateTimeException;
  -import org.apache.xerces.impl.v2.datatypes.InvalidDatatypeValueException;
  -
   /**
    * Validator for <gDay> datatype (W3C Schema datatypes)
    *
    * @author Elena Litani
    * @author Gopal Sharma, SUN Microsystem Inc.
  - * @version $Id: DayDV.java,v 1.2 2001/10/03 18:27:07 neilg Exp $
  + * @version $Id: DayDV.java,v 1.3 2001/11/09 00:30:37 sandygao Exp $
    */
  -
  -public class DayDV extends AbstractDateTimeDV{
  +public class DayDV extends AbstractDateTimeDV {
   
       //size without time zone: ---09
       private final static int DAY_SIZE=5;
  -
  -    // for most DV classes, this is the same as the DV_?? value defined
  -    // in XSSimpleTypeDecl that's corresponding to that class. But for
  -    // ID/IDREF/ENTITY, the privitivaDV is DV_STRING.
   
  -	public short getPrimitiveDV(){
  -		return XSSimpleTypeDecl.DV_GDAY;
  +    public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
  +        try{
  +            return parse(content, null);
  +        } catch(Exception ex){
  +            throw new InvalidDatatypeValueException("not a valid day");
  +        }
       }
   
  -	public Object  getCompiledValue(String content) throws InvalidDatatypeValueException{
  -			int[] date;
  -			try{
  -					date= parse(content, null);
  -			}catch(Exception ex){
  -			}
  -			return date;
  -	}
  -
       /**
        * Parses, validates and computes normalized version of gDay object
        *
  @@ -101,7 +88,7 @@
        * @return normalized date representation
        * @exception Exception Invalid lexical representation
        */
  -    protected int[] parse(String str, int[] date) throws SchemaDateTimeException{
  +    protected int[] parse(String str, int[] date) throws SchemaDateTimeException {
   
           resetBuffer(str);
   
  @@ -131,7 +118,7 @@
               }
           }
   
  -	   //validate and normalize
  +       //validate and normalize
           validateDateTime(date);
   
           if ( date[utc]!=0 && date[utc]!='Z' ) {
  
  
  
  1.4       +9 -24     xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/DateTimeDV.java
  
  Index: DateTimeDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/DateTimeDV.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DateTimeDV.java	2001/10/05 19:48:42	1.3
  +++ DateTimeDV.java	2001/11/09 00:30:37	1.4
  @@ -57,37 +57,24 @@
   
   package org.apache.xerces.impl.v2.new_datatypes;
   
  -import org.apache.xerces.impl.v2.datatypes.InvalidDatatypeValueException;
  -import org.apache.xerces.impl.v2.datatypes.SchemaDateTimeException;
  -
   /**
    * Validator for <dateTime> datatype (W3C Schema Datatypes)
    *
    * @author Elena Litani
    * @author Gopal Sharma, SUN Microsystem Inc.
  - * @version $Id: DateTimeDV.java,v 1.3 2001/10/05 19:48:42 neilg Exp $
  + *
  + * @version $Id: DateTimeDV.java,v 1.4 2001/11/09 00:30:37 sandygao Exp $
    */
   public class DateTimeDV extends AbstractDateTimeDV {
   
  -    // for most DV classes, this is the same as the DV_?? value defined
  -    // in XSSimpleTypeDecl that's corresponding to that class. But for
  -    // ID/IDREF/ENTITY, the privitivaDV is DV_STRING.
  -
  -	public short getPrimitiveDV(){
  -		return XSSimpleTypeDecl.DV_DATETIME;
  +    public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
  +        try{
  +            return parse(content, null);
  +        } catch(Exception ex){
  +            throw new InvalidDatatypeValueException("not a valid dataTime");
  +        }
       }
   
  -	public Object  getCompiledValue(String content) throws InvalidDatatypeValueException{
  -            // REVISIT:  Initialize this intelligently!!!  Fixed by neilg for the sake
  -            // of making this compile...
  -			int[] date = new int[10];
  -			try{
  -					date= parse(content, null);
  -			}catch(Exception ex){
  -			}
  -			return date;
  -	}
  -
       /**
        * Parses, validates and computes normalized version of dateTime object
        *
  @@ -97,8 +84,7 @@
        * @return normalized dateTime representation
        * @exception Exception Invalid lexical representation
        */
  -
  -	protected int[] parse(String str, int[] date) throws SchemaDateTimeException{
  +    protected int[] parse(String str, int[] date) throws SchemaDateTimeException {
           resetBuffer(str);
   
           //create structure to hold an object
  @@ -122,7 +108,6 @@
           }
           return date;
       }
  -
   
   }
   
  
  
  
  1.3       +16 -85    xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/Base64BinaryDV.java
  
  Index: Base64BinaryDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/Base64BinaryDV.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Base64BinaryDV.java	2001/10/02 19:19:18	1.2
  +++ Base64BinaryDV.java	2001/11/09 00:30:37	1.3
  @@ -57,97 +57,28 @@
   
   package org.apache.xerces.impl.v2.new_datatypes;
   
  -//internal imports
  -import org.apache.xerces.impl.v2.util.Base64;
  -import org.apache.xerces.impl.v2.datatypes.InvalidDatatypeValueException;
  +import org.apache.xerces.impl.xs.util.Base64;
   
  -//java imports
  -import java.io.UnsupportedEncodingException;
  -
   /**
  - * @version $Id: Base64BinaryDV.java,v 1.2 2001/10/02 19:19:18 neilg Exp $
  + * Represent the schema type "base64Binary"
  + *
  + * @author Neeraj Bajaj, Sun Microsystems, inc.
  + * @author Sandy Gao, IBM
  + *
  + * @version $Id: Base64BinaryDV.java,v 1.3 2001/11/09 00:30:37 sandygao Exp $
    */
  -public class Base64BinaryDV extends AbstractStringDV{
  -
  -    // for most DV classes, this is the same as the DV_?? value defined
  -    // in XSSimpleTypeDecl that's corresponding to that class. But for
  -    // ID/IDREF/ENTITY, the privitivaDV is DV_STRING.
  -
  -    public short getPrimitiveDV(){
  -        return XSSimpleTypeDecl.DV_BASE64BINARY;
  -    }
  +public class Base64BinaryDV extends TypeValidator {
   
  -    // convert a string to a compiled form. for example,
  -    // for number types (decimal, double, float, and types derived from them),
  -    // get the BigDecimal, Double, Flout object.
  -    // for some types (string and derived), they just return the string itself
  -    public Object getCompiledValue(String content) throws InvalidDatatypeValueException{
  -        if (getDataLength(content) < 0) {
  -            throw new InvalidDatatypeValueException( "Value '"+content+"' is not encoded in Hex" );
  -        }
  -        return content;
  +    public short getAllowedFacets(){
  +        return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE );
       }
  -
  -
  -    // the parameters are in compiled form (from getCompiledValue)
  -    public boolean isEqual(Object value1, Object value2){
  -
  -        return compare(value1,value2) == 0 ? true : false;
  -
  -    }//isEqual()
  -
  -    // the following methods might not be supported by every DV.
  -    // but XSSimpleTypeDecl should know which type supports which methods,
  -    // and it's an *internal* error if a method is called on a DV that
  -    // doesn't support it.
  -
  -    //compiled value is string in this case ,as we return string for all derived by string.
  -    public  int compare(Object value1, Object value2){
  -
  -        String str1 = (String)value1;
  -        String str2 = (String)value2;
   
  -        if (str1 == null || str2 == null)
  -            return -1;
  +    public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
  +        String decoded = Base64.decode(content);
  +        if (decoded == null)
  +            throw new InvalidDatatypeValueException("Value '"+content+"' is not encoded in base64");
   
  -        if (str1 == str2 || str1.equals(str2))
  -            return 0;
  -
  -        byte[] data1= Base64.decode(str1.getBytes());
  -        byte[] data2= Base64.decode(str2.getBytes());
  -
  -        if (data1 == null || data2 == null)
  -            return -1;
  -
  -        for (int i = 0; i < Math.min(data1.length, data2.length); i++){
  -            if (data1[i] < data2[i])
  -                return -1;
  -            else if (data1[i] > data2[i])
  -                return 1;
  -        }
  -
  -        if (data1.length == data2.length)
  -            return 0;
  -
  -        return data1.length > data2.length ? 1 : -1;
  -
  -    }//compare()
  -
  -
  -    //compiled value is string in this case ,as we return string for all derived by string.
  -    //for base64 length is measured in octets of binary data.
  -    public int getDataLength(Object value){
  -        int x = -1;
  -        String content = (String)value;
  -        try {
  -            x = Base64.getDecodedDataLength(content.getBytes("utf-8"));
  -        }
  -        catch (UnsupportedEncodingException e) {
  -        }
  -        finally {
  -            return x;
  -        }
  -    }//getDataLength()
  -
  +        return decoded;
  +    }
   
   } // class Base64BinaryDV
  
  
  
  1.3       +31 -39    xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/AbstractDateTimeDV.java
  
  Index: AbstractDateTimeDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/AbstractDateTimeDV.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractDateTimeDV.java	2001/10/03 18:27:07	1.2
  +++ AbstractDateTimeDV.java	2001/11/09 00:30:37	1.3
  @@ -57,28 +57,32 @@
   
   package org.apache.xerces.impl.v2.new_datatypes;
   
  -import org.apache.xerces.impl.v2.datatypes.SchemaDateTimeException;
  -
   /**
    * 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.
    *
  + * REVISIT: There are many instance variables, which would cause problems
  + *          when we support grammar caching. A grammar is possibly used by
  + *          two parser instances at the same time, then the same simple type
  + *          decl object can be used to validate two strings at the same time.
  + *          -SG
  + *
    * @author Elena Litani
    * @author Len Berman
    * @author Gopal Sharma, SUN Microsystems Inc.
  - * @version $Id: AbstractDateTimeDV.java,v 1.2 2001/10/03 18:27:07 neilg Exp $
  + *
  + * @version $Id: AbstractDateTimeDV.java,v 1.3 2001/11/09 00:30:37 sandygao Exp $
    */
  +public abstract class AbstractDateTimeDV extends TypeValidator {
   
  -public abstract class AbstractDateTimeDV extends AbstractNumericDV {
  -
       //debugging
       private static final boolean DEBUG=false;
   
       //define shared variables for date/time
   
  -	//To check order relation as per 3.2.7.3
  -	public static final short INDETERMINATE=2;
  +    //To check order relation as per 3.2.7.3
  +    public static final short INDETERMINATE=2;
   
       //define constants
       protected final static int CY = 0,  M = 1, D = 2, h = 3,
  @@ -131,18 +135,22 @@
           timeZone = new int[2];
       }
   
  +    public short getAllowedFacets(){
  +        return ( XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_WHITESPACE | XSSimpleTypeDecl.FACET_ENUMERATION |XSSimpleTypeDecl.FACET_MAXINCLUSIVE |XSSimpleTypeDecl.FACET_MININCLUSIVE | XSSimpleTypeDecl.FACET_MAXEXCLUSIVE  | XSSimpleTypeDecl.FACET_MINEXCLUSIVE  );
  +    }//getAllowedFacets()
  +
   
  -   // the parameters are in compiled form (from getCompiledValue)
  +    // the parameters are in compiled form (from getActualValue)
       public boolean isEqual(Object value1, Object value2){
  -        return compareDates((int[])value1,(int[])value2)==COMPARE_EQUAL?true:false;
  +        return compareDates((int[])value1,(int[])value2)==0;
       }//IsEqual()
   
  -   // the parameters are in compiled form (from getCompiledValue)
  -       public int compare (Object value1, Object value2) {
  -            return compareDates((int[])value1, (int[])value2);
  +    // the parameters are in compiled form (from getActualValue)
  +    public int compare (Object value1, Object value2) {
  +        return compareDates((int[])value1, (int[])value2);
       }//compare()
   
  -	/**
  +    /**
        * Implemented by each subtype, calling appropriate function to parse
        * given date/time
        *
  @@ -155,7 +163,7 @@
        */
        abstract protected int[] parse (String content, int[] date) throws SchemaDateTimeException;
   
  -	 /**
  +     /**
        * Compare algorithm described in dateDime (3.2.7).
        * Duration datatype overwrites this method
        *
  @@ -164,8 +172,7 @@
        * @param strict
        * @return less, greater, less_equal, greater_equal, equal
        */
  -
  -    protected  int compareDates(int[] date1, int[] date2) {
  +    protected int compareDates(int[] date1, int[] date2) {
           if ( date1[utc]==date2[utc] ) {
               return compareOrder(date1, date2);
           }
  @@ -191,8 +198,8 @@
               normalize(fTempDate);
               c2 = compareOrder(date1, fTempDate);
   
  -            if ( (c1==COMPARE_LESS && c2==COMPARE_GREATER) ||
  -                 (c1==COMPARE_GREATER && c2==COMPARE_LESS) ) {
  +            if ( (c1 < 0 && c2 > 0) ||
  +                 (c1 == 0 && c2 == 0) ) {
                   return INDETERMINATE;
               }
               //REVISIT: wait for clarification on this case from schema
  @@ -227,8 +234,8 @@
               if (DEBUG) {
                  System.out.println("fTempDate=" + dateToString(fTempDate));
               }
  -            if ( (c1==COMPARE_LESS && c2==COMPARE_GREATER) ||
  -                 (c1==COMPARE_GREATER && c2==COMPARE_LESS) ) {
  +            if ( (c1 < 0 && c2 > 0) ||
  +                 (c1 == 0 && c2 == 0) ) {
                   return INDETERMINATE;
               }
               //REVISIT: wait for clarification on this case from schema
  @@ -238,7 +245,6 @@
   
       }
   
  -
       /**
        * Given normalized values, determines order-relation
        * between give date/time objects.
  @@ -251,16 +257,15 @@
   
           for ( int i=0;i<TOTAL_SIZE;i++ ) {
               if ( date1[i]<date2[i] ) {
  -                return COMPARE_LESS;
  +                return -1;
               }
               else if ( date1[i]>date2[i] ) {
  -                return COMPARE_GREATER;
  +                return 1;
               }
           }
  -        return COMPARE_EQUAL;
  +        return 0;
       }
   
  -
       /**
        * Parses time hh:mm:ss.sss and time zone if any
        *
  @@ -322,7 +327,6 @@
           }
       }
   
  -
       /**
        * Parses date CCYY-MM-DD
        *
  @@ -380,8 +384,6 @@
           fStart = i; //fStart points right after the MONTH
       }
   
  -
  -
       /**
        * Shared code from Date and YearMonth datatypes.
        * Finds if time zone sign is present
  @@ -447,8 +449,6 @@
           }
       }
   
  -
  -
       /**
        * Computes index of given char within StringBuffer
        *
  @@ -466,7 +466,6 @@
           return -1;
       }
   
  -
       /**
        * Validates given date/time object accoring to W3C PR Schema
        * [D.1 ISO 8601 Conventions]
  @@ -520,7 +519,6 @@
           }
       }
   
  -
       /**
        * Return index of UTC char: 'Z', '+', '-'
        *
  @@ -540,7 +538,6 @@
           return -1;
       }
   
  -
       /**
        * Given start and end position, parses string value
        *
  @@ -571,7 +568,7 @@
       }
   
       // parse Year differently to support negative value.
  -     protected int parseIntYear (int end){
  +    protected int parseIntYear (int end){
           int radix=10;
           int result = 0;
           boolean negative = false;
  @@ -607,8 +604,6 @@
           }
           return -result;
   
  -
  -
       }
   
       /**
  @@ -686,7 +681,6 @@
   
       }
   
  -
       /**
        * Resets object representation of date/time
        *
  @@ -698,7 +692,6 @@
           }
       }
   
  -
       /**
        * Given {year,month} computes maximum
        * number of days for given month
  @@ -724,7 +717,6 @@
               return 31;
           }
       }
  -
   
       private boolean isLeapYear(int year) {
   
  
  
  
  1.1                  xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/UnionDV.java
  
  Index: UnionDV.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    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
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    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,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 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
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.xerces.impl.v2.new_datatypes;
  
  import java.util.StringTokenizer;
  
  /**
   * Represent the schema union types
   *
   * @author Neeraj Bajaj, Sun Microsystems, inc.
   * @author Sandy Gao, IBM
   *
   * @version $Id: UnionDV.java,v 1.1 2001/11/09 00:30:37 sandygao Exp $
   */
  public class UnionDV extends TypeValidator{
  
      public short getAllowedFacets(){
            return (XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION );
      }
  
      // this method should never be called: XSSimpleTypeDecl is responsible for
      // calling the member types for the convertion
      public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException{
          return content;
      }
  
  } // class UnionDV
  
  
  
  1.1                  xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/SchemaDVFactoryImpl.java
  
  Index: SchemaDVFactoryImpl.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    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
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    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,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 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
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.xerces.impl.v2.new_datatypes;
  
  import java.util.Hashtable;
  
  /**
   * the factory to create/return built-in schema DVs and create user-defined DVs
   *
   * @author Neeraj Bajaj, Sun Microsystems, inc.
   * @author Sandy Gao, IBM
   *
   * @version $Id: SchemaDVFactoryImpl.java,v 1.1 2001/11/09 00:30:37 sandygao Exp $
   */
  public class SchemaDVFactoryImpl implements SchemaDVFactory {
  
      static final String URI_SCHEMAFORSCHEMA = "http://www.w3.org/2001/XMLSchema";
  
      static Hashtable fBuiltInTypes = null;
      static XSSimpleTypeDecl fAnySimpleType = null;
  
      // get a built-in DV of the given name
      // we need to pass in anyType as the base of anySimpleType
      public XSSimpleType getBuiltInType(String name) {
          prepareBuiltInTypes();
          return (XSSimpleType)fBuiltInTypes.get(name);
      }
  
      // create a user-defined DV according to how it's defined: <restriction>
      public XSSimpleType createTypeRestriction(String name, String targetNamespace,
                                                short finalSet, XSSimpleType base) {
          return new XSSimpleTypeDecl((XSSimpleTypeDecl)base, name, targetNamespace, finalSet);
      }
  
      // create a user-defined DV according to how it's defined: <list>
      public XSListSimpleType createTypeList(String name, String targetNamespace,
                                             short finalSet, XSSimpleType itemType) {
          prepareBuiltInTypes();
          return new XSSimpleTypeDecl(fAnySimpleType, name, targetNamespace, finalSet, (XSSimpleTypeDecl)itemType);
      }
  
      // create a user-defined DV according to how it's defined: <union>
      public XSUnionSimpleType createTypeUnion(String name, String targetNamespace,
                                               short finalSet, XSSimpleType[] memberTypes) {
          prepareBuiltInTypes();
          int typeNum = memberTypes.length;
          XSSimpleTypeDecl[] mtypes = new XSSimpleTypeDecl[typeNum];
          System.arraycopy(memberTypes, 0, mtypes, 0, typeNum);
          return new XSSimpleTypeDecl(fAnySimpleType, name, targetNamespace, finalSet, mtypes);
      }
  
      void prepareBuiltInTypes() {
          if (fBuiltInTypes == null) {
              synchronized (this.getClass()) {
                  if (fBuiltInTypes == null) {
                      createBuiltInTypes();
                  }
              }
          }
      }
  
      // create all built-in types
      // we are assumeing that fBuiltInTypes == null
      void createBuiltInTypes() {
  
          // all schema simple type names
          final String ANYSIMPLETYPE     = "anySimpleType";
          final String ANYURI            = "anyURI";
          final String BASE64BINARY      = "base64Binary";
          final String BOOLEAN           = "boolean";
          final String BYTE              = "byte";
          final String DATE              = "date";
          final String DATETIME          = "dateTime";
          final String DAY               = "gDay";
          final String DECIMAL           = "decimal";
          final String DOUBLE            = "double";
          final String DURATION          = "duration";
          final String ENTITY            = "ENTITY";
          final String ENTITIES          = "ENTITIES";
          final String FLOAT             = "float";
          final String HEXBINARY         = "hexBinary";
          final String ID                = "ID";
          final String IDREF             = "IDREF";
          final String IDREFS            = "IDREFS";
          final String INT               = "int";
          final String INTEGER           = "integer";
          final String LONG              = "long";
          final String NAME              = "Name";
          final String NEGATIVEINTEGER   = "negativeInteger";
          final String MONTH             = "gMonth";
          final String MONTHDAY          = "gMonthDay";
          final String NCNAME            = "NCName";
          final String NMTOKEN           = "NMTOKEN";
          final String NMTOKENS          = "NMTOKENS";
          final String NONNEGATIVEINTEGER= "nonNegativeInteger";
          final String NONPOSITIVEINTEGER= "nonPositiveInteger";
          final String NORMALIZEDSTRING  = "normalizedString";
          final String NOTATION          = "NOTATION";
          final String POSITIVEINTEGER   = "positiveInteger";
          final String QNAME             = "QName";
          final String SHORT             = "short";
          final String STRING            = "string";
          final String TIME              = "time";
          final String TOKEN             = "token";
          final String UNSIGNEDBYTE      = "unsignedByte";
          final String UNSIGNEDINT       = "unsignedInt";
          final String UNSIGNEDLONG      = "unsignedLong";
          final String UNSIGNEDSHORT     = "unsignedShort";
          final String YEAR              = "gYear";
          final String YEARMONTH         = "gYearMonth";
  
          final XSFacets facets = new XSFacets();
  
          fBuiltInTypes = new Hashtable();
  
          fAnySimpleType = new XSSimpleTypeDecl(null, ANYSIMPLETYPE, XSSimpleTypeDecl.DV_ANYSIMPLETYPE);
          fBuiltInTypes.put(ANYSIMPLETYPE, fAnySimpleType);
          XSSimpleTypeDecl stringDV = new XSSimpleTypeDecl(fAnySimpleType, STRING, XSSimpleTypeDecl.DV_STRING);
          fBuiltInTypes.put(STRING, stringDV);
          fBuiltInTypes.put(BOOLEAN, new XSSimpleTypeDecl(fAnySimpleType, STRING, XSSimpleTypeDecl.DV_BOOLEAN));
          XSSimpleTypeDecl decimalDV = new XSSimpleTypeDecl(fAnySimpleType, DECIMAL, XSSimpleTypeDecl.DV_DECIMAL);
          fBuiltInTypes.put(DECIMAL, decimalDV);
          fBuiltInTypes.put(BOOLEAN, new XSSimpleTypeDecl(fAnySimpleType, BOOLEAN, XSSimpleTypeDecl.DV_BOOLEAN));
          fBuiltInTypes.put(BOOLEAN, new XSSimpleTypeDecl(fAnySimpleType, ANYURI, XSSimpleTypeDecl.DV_ANYURI));
          fBuiltInTypes.put(BOOLEAN, new XSSimpleTypeDecl(fAnySimpleType, BASE64BINARY, XSSimpleTypeDecl.DV_BASE64BINARY));
          fBuiltInTypes.put(BOOLEAN, new XSSimpleTypeDecl(fAnySimpleType, DURATION, XSSimpleTypeDecl.DV_DURATION));
          fBuiltInTypes.put(BOOLEAN, new XSSimpleTypeDecl(fAnySimpleType, DATETIME, XSSimpleTypeDecl.DV_DATETIME));
          fBuiltInTypes.put(BOOLEAN, new XSSimpleTypeDecl(fAnySimpleType, TIME, XSSimpleTypeDecl.DV_TIME));
          fBuiltInTypes.put(BOOLEAN, new XSSimpleTypeDecl(fAnySimpleType, DATE, XSSimpleTypeDecl.DV_DATE));
          fBuiltInTypes.put(BOOLEAN, new XSSimpleTypeDecl(fAnySimpleType, YEARMONTH, XSSimpleTypeDecl.DV_GYEARMONTH));
          fBuiltInTypes.put(BOOLEAN, new XSSimpleTypeDecl(fAnySimpleType, YEAR, XSSimpleTypeDecl.DV_GYEAR));
          fBuiltInTypes.put(BOOLEAN, new XSSimpleTypeDecl(fAnySimpleType, MONTHDAY, XSSimpleTypeDecl.DV_GMONTHDAY));
          fBuiltInTypes.put(BOOLEAN, new XSSimpleTypeDecl(fAnySimpleType, MONTH, XSSimpleTypeDecl.DV_GMONTH));
  
          facets.fractionDigits = 0;
          XSSimpleTypeDecl integerDV = new XSSimpleTypeDecl(decimalDV, INTEGER, URI_SCHEMAFORSCHEMA, (short)0);
          integerDV.applyFacets(facets, XSSimpleType.FACET_FRACTIONDIGITS, (short)0);
          fBuiltInTypes.put(INTEGER, integerDV);
          facets.maxInclusive = "0";
          XSSimpleTypeDecl nonPositiveDV = new XSSimpleTypeDecl(integerDV, NONPOSITIVEINTEGER, URI_SCHEMAFORSCHEMA, (short)0);
          nonPositiveDV.applyFacets(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0);
          fBuiltInTypes.put(NONPOSITIVEINTEGER, nonPositiveDV);
          facets.maxInclusive = "-1";
          XSSimpleTypeDecl negativeDV = new XSSimpleTypeDecl(integerDV, NEGATIVEINTEGER, URI_SCHEMAFORSCHEMA, (short)0);
          negativeDV.applyFacets(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0);
          fBuiltInTypes.put(NEGATIVEINTEGER, negativeDV);
          /*facets.put(SchemaSymbols.ELT_MAXINCLUSIVE , "9223372036854775807");
          facets.put(SchemaSymbols.ELT_MININCLUSIVE,  "-9223372036854775808");
          XSSimpleTypeDecl longDV = new DecimalXSSimpleTypeDecl(integerDV, facets, false, null);
          addGlobalTypeDecl(SchemaSymbols.LONG, longDV);
          facets.clear();
          facets.put(SchemaSymbols.ELT_MAXINCLUSIVE , "2147483647");
          facets.put(SchemaSymbols.ELT_MININCLUSIVE,  "-2147483648");
          XSSimpleTypeDecl intDV = new DecimalXSSimpleTypeDecl(longDV, facets, false, null);
          addGlobalTypeDecl(SchemaSymbols.INT, intDV);
          facets.clear();
          facets.put(SchemaSymbols.ELT_MAXINCLUSIVE , "32767");
          facets.put(SchemaSymbols.ELT_MININCLUSIVE,  "-32768");
          XSSimpleTypeDecl shortDV = new DecimalXSSimpleTypeDecl(intDV, facets, false, null);
          addGlobalTypeDecl(SchemaSymbols.SHORT, shortDV);
          facets.clear();
          facets.put(SchemaSymbols.ELT_MAXINCLUSIVE , "127");
          facets.put(SchemaSymbols.ELT_MININCLUSIVE,  "-128");
          addGlobalTypeDecl(SchemaSymbols.BYTE, new DecimalXSSimpleTypeDecl(shortDV, facets, false, null));
          facets.clear();
          facets.put(SchemaSymbols.ELT_MININCLUSIVE, "0" );
          XSSimpleTypeDecl nonNegativeDV = new DecimalXSSimpleTypeDecl(integerDV, facets, false, null);
          addGlobalTypeDecl(SchemaSymbols.NONNEGATIVEINTEGER, nonNegativeDV);
          facets.clear();
          facets.put(SchemaSymbols.ELT_MAXINCLUSIVE, "18446744073709551615" );
          XSSimpleTypeDecl unsignedLongDV = new DecimalXSSimpleTypeDecl(nonNegativeDV, facets, false, null);
          addGlobalTypeDecl(SchemaSymbols.UNSIGNEDLONG, unsignedLongDV);
          facets.clear();
          facets.put(SchemaSymbols.ELT_MAXINCLUSIVE, "4294967295" );
          XSSimpleTypeDecl unsignedIntDV = new DecimalXSSimpleTypeDecl(unsignedLongDV, facets, false, null);
          addGlobalTypeDecl(SchemaSymbols.UNSIGNEDINT, unsignedIntDV);
          facets.clear();
          facets.put(SchemaSymbols.ELT_MAXINCLUSIVE, "65535" );
          XSSimpleTypeDecl unsignedShortDV = new DecimalXSSimpleTypeDecl(unsignedIntDV, facets, false, null);
          addGlobalTypeDecl(SchemaSymbols.UNSIGNEDSHORT, unsignedShortDV);
          facets.clear();
          facets.put(SchemaSymbols.ELT_MAXINCLUSIVE, "255" );
          addGlobalTypeDecl(SchemaSymbols.UNSIGNEDBYTE, new DecimalXSSimpleTypeDecl(unsignedShortDV, facets, false, null));
          facets.clear();
          facets.put(SchemaSymbols.ELT_MININCLUSIVE, "1" );
          addGlobalTypeDecl(SchemaSymbols.POSITIVEINTEGER, new DecimalXSSimpleTypeDecl(nonNegativeDV, facets, false, null));
  
          if (!fullSet)
              return;
  
          addGlobalTypeDecl(SchemaSymbols.FLOAT, new FloatXSSimpleTypeDecl(fAnySimpleType,  null, false, null));
          addGlobalTypeDecl(SchemaSymbols.DOUBLE, new DoubleXSSimpleTypeDecl(fAnySimpleType,  null, false, null));
          addGlobalTypeDecl(SchemaSymbols.HEXBINARY, new HexBinaryXSSimpleTypeDecl(fAnySimpleType,  null, false, null));
          addGlobalTypeDecl(SchemaSymbols.NOTATION, new NOTATIONXSSimpleTypeDecl(fAnySimpleType,  null, false, null));
  
          facets.clear();
          facets.put(SchemaSymbols.ELT_WHITESPACE, SchemaSymbols.REPLACE);
          XSSimpleTypeDecl normalizedDV = new StringXSSimpleTypeDecl(stringDV, facets, false, null);
          addGlobalTypeDecl(SchemaSymbols.NORMALIZEDSTRING, normalizedDV);
          facets.clear();
          facets.put(SchemaSymbols.ELT_WHITESPACE, SchemaSymbols.COLLAPSE);
          XSSimpleTypeDecl tokenDV = new StringXSSimpleTypeDecl(normalizedDV, facets, false, null);
          addGlobalTypeDecl(SchemaSymbols.TOKEN, tokenDV);
          facets.clear();
          facets.put(SchemaSymbols.ELT_WHITESPACE, SchemaSymbols.COLLAPSE);
          facets.put(SchemaSymbols.ELT_PATTERN , "([a-zA-Z]{2}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]+)(-[a-zA-Z]+)*");
          addGlobalTypeDecl(SchemaSymbols.LANGUAGE, new StringXSSimpleTypeDecl(tokenDV, facets, false, null));
          facets.clear();
          facets.put(SchemaSymbols.ELT_WHITESPACE, SchemaSymbols.COLLAPSE);
          facets.put(AbstractStringValidator.FACET_SPECIAL_TOKEN, AbstractStringValidator.SPECIAL_TOKEN_NAME);
          XSSimpleTypeDecl nameDV = new StringXSSimpleTypeDecl(tokenDV, facets, false, null);
          addGlobalTypeDecl(SchemaSymbols.NAME, nameDV);
          facets.clear();
          facets.put(SchemaSymbols.ELT_WHITESPACE, SchemaSymbols.COLLAPSE);
          facets.put(AbstractStringValidator.FACET_SPECIAL_TOKEN, AbstractStringValidator.SPECIAL_TOKEN_NCNAME);
          XSSimpleTypeDecl ncnameDV = new StringXSSimpleTypeDecl(nameDV, facets, false, null);
          addGlobalTypeDecl(SchemaSymbols.NCNAME, ncnameDV);
          XSSimpleTypeDecl qnameDV = new QNameXSSimpleTypeDecl(fAnySimpleType,  null, false, null);
          ((QNameXSSimpleTypeDecl)qnameDV).setNCNameValidator(ncnameDV);
          addGlobalTypeDecl(SchemaSymbols.QNAME, qnameDV);
          addGlobalTypeDecl(SchemaSymbols.ID, new IDXSSimpleTypeDecl(ncnameDV,  null, false, null));
          XSSimpleTypeDecl idrefDV = new IDREFXSSimpleTypeDecl(ncnameDV,  null, false, null);
          addGlobalTypeDecl(SchemaSymbols.IDREF, idrefDV);
          addGlobalTypeDecl(SchemaSymbols.IDREFS, new ListXSSimpleTypeDecl(idrefDV, null, true, null));
          XSSimpleTypeDecl entityDV = new EntityXSSimpleTypeDecl(ncnameDV, null, false, null);
          addGlobalTypeDecl(SchemaSymbols.ENTITY, entityDV);
          addGlobalTypeDecl(SchemaSymbols.ENTITIES, new ListXSSimpleTypeDecl(entityDV, null, true, null));
  
          facets.clear();
          facets.put(SchemaSymbols.ELT_WHITESPACE, SchemaSymbols.COLLAPSE);
          facets.put(AbstractStringValidator.FACET_SPECIAL_TOKEN, AbstractStringValidator.SPECIAL_TOKEN_NMTOKEN);
          XSSimpleTypeDecl nmtokenDV = new StringXSSimpleTypeDecl(tokenDV, facets, false, null);
          addGlobalTypeDecl(SchemaSymbols.NMTOKEN, nmtokenDV);
          addGlobalTypeDecl(SchemaSymbols.NMTOKENS, new ListXSSimpleTypeDecl(nmtokenDV, null, true, null));
  */
      }//getBuiltInSimpleType()
  
  }//SchemaDVFactory
  
  
  
  1.1                  xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/SchemaDateTimeException.java
  
  Index: SchemaDateTimeException.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999, 2000, 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    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
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    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,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 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
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
   /*$Id*/
  
  package org.apache.xerces.impl.v2.new_datatypes;
  
  public class SchemaDateTimeException extends RuntimeException {
      public SchemaDateTimeException () {
          super();
      }
  
      public SchemaDateTimeException (String s) {
          super (s);
      }
  }
  
  
  
  1.1                  xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/NewDVInterfaces.java
  
  Index: NewDVInterfaces.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    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
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    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,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 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
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.xerces.impl.v2.new_datatypes;
  
  /**
   * All the interfaces that need to be implemented by DV implementations,
   * and those interfaces/classes that DV implementations depend on.
   *
   * REVISIT: putting them all together in one file is temporary. after we clean
   *          up these interfaces, and the implementation, we'll make the
   *          interfaces public in separate files in the impl.dv package.
   *
   * @author Sandy Gao, IBM
   *
   * @version $Id: NewDVInterfaces.java,v 1.1 2001/11/09 00:30:37 sandygao Exp $
  */
  
  /**
   * Base datatype exception class
   */
  class DatatypeException extends Exception {
      // this one is like reportGenericSchemaError: remove it later
      public DatatypeException(String msg) {
          this("general", new Object[]{msg});
      }
  
      // store a datatype error: error code plus the arguments
      String key;
      Object[] args;
  
      // report an error
      public DatatypeException(String key, Object[] args) {
          this.key = key;
          this.args = args;
      }
  
      public String getKey() {
          return key;
      }
  
      public Object[] getArgs() {
          return args;
      }
  }
  
  /**
   * Exception for facets
   */
  class InvalidDatatypeFacetException extends DatatypeException {
      public InvalidDatatypeFacetException(String key, Object[] args) {
          super(key, args);
      }
  
      public InvalidDatatypeFacetException(String msg) {
          super(msg);
      }
  }
  
  /**
   * Exception for values
   */
  class InvalidDatatypeValueException extends DatatypeException {
      public InvalidDatatypeValueException(String key, Object[] args) {
          super(key, args);
      }
  
      public InvalidDatatypeValueException(String msg) {
          super(msg);
      }
  }
  
  /**
   * the factory to create and return DTD types.
   */
  interface DTDDVFactory {
      // return a dtd type of the given name
      public DatatypeValidator getBuiltInDV(String name);
  }
  
  /**
   * the interface that a DTD DV must implement
   */
  interface DatatypeValidator {
      // validate a given string against this DV
      public Object validate(String content, ValidationContext context)
          throws InvalidDatatypeValueException;
  }
  
  /**
   * the factory to create/return built-in schema DVs and create user-defined DVs
   */
  interface SchemaDVFactory {
      // get a built-in DV of the given name
      // we need to pass in anyType as the base of anySimpleType
      public XSSimpleType getBuiltInType(String name);
  
      // create a user-defined DV according to how it's defined:
      // <restriction> / <list> / <union>
      public XSSimpleType createTypeRestriction(String name, String targetNamespace,
                                                short finalSet, XSSimpleType base);
      public XSListSimpleType createTypeList(String name, String targetNamespace,
                                             short finalSet, XSSimpleType itemType);
      public XSUnionSimpleType createTypeUnion(String name, String targetNamespace,
                                               short finalSet, XSSimpleType[] memberTypes);
  }
  
  /**
   * represent a facet. similar to the one defined in PSVI API
   */
  interface XSFacet {
      public String getName();
      public Object getValue();
      public boolean isFixed();
  }
  
  /**
   * The base interface for both complex type and simple type
   */
  interface XSTypeDecl {
      public static final short COMPLEX_TYPE   = 1;
      public static final short SIMPLE_TYPE    = 2;
  
      public short getXSType();
      public String getXSTypeName();
      public String getXSTypeNamespace();
  }
  
  /**
   * the simple type interface, equivalent to XSSimpleTypeDefinition in PSVI API
   * it can't be derived from DatatypeValidator (for DTD), because we need to
   * derive it from the base type definition
   */
  interface XSSimpleType extends XSTypeDecl, DatatypeValidator {
  
      // To tell which facets are fixed, and which ones are present, we use
      // bit mask of the following contants
      public static final short FACET_LENGTH         = 1<<0;
      public static final short FACET_MINLENGTH      = 1<<1;
      public static final short FACET_MAXLENGTH      = 1<<2;
      public static final short FACET_PATTERN        = 1<<3;
      public static final short FACET_ENUMERATION    = 1<<4;
      public static final short FACET_WHITESPACE     = 1<<5;
      public static final short FACET_MAXINCLUSIVE   = 1<<6;
      public static final short FACET_MAXEXCLUSIVE   = 1<<7;
      public static final short FACET_MINEXCLUSIVE   = 1<<8;
      public static final short FACET_MININCLUSIVE   = 1<<9;
      public static final short FACET_TOTALDIGITS    = 1<<10;
      public static final short FACET_FRACTIONDIGITS = 1<<11;
  
      // varieties
      public static final short VARIETY_ATOMIC    = 1;
      public static final short VARIETY_LIST      = 2;
      public static final short VARIETY_UNION     = 3;
  
      // whitespace values
      public static final short WS_PRESERVE = 0;
      public static final short WS_REPLACE  = 1;
      public static final short WS_COLLAPSE = 2;
  
      // order constants: for PSVI
      public static final short ORDERED_FALSE     = 1;
      public static final short ORDERED_PARTIAL   = 2;
      public static final short ORDERED_TOTAL     = 3;
  
      // cardinality constants: for PSVI
      public static final short CARDINALITY_FINITE             = 1;
      public static final short CARDINALITY_COUNTABLY_INFINITE = 2;
  
      // apply the facets
      public void applyFacets(XSFacets facets, short presentFacet, short fixedFacet)
          throws InvalidDatatypeFacetException;
  
      // to check whether two values are equal
      // we can't depend on Object#isEqual: for list types, we need to compare
      // the items one by one.
      public boolean isEqual(Object value1, Object value2)
          throws DatatypeException;
  
      // Andy also believes that a compare() method is necessary.
      // I don't see the necessity for schema (there only place where we need
      // to compare two values is to check min/maxIn/Exclusive facets, but we
      // only need a private method for this case.)
      // But Andy thinks XPATH potentially needs this compare() method.
      //public short compare(Object value1, Object value2);
  
      public short getFinalSet();
      public short getVariety();
  
      // the following methods are for PSVI. they are not implemented yet.
      //public XSFacet[] getFacets();
      // the following four are for fundamental facets
      //public short getOrderedFacet();
      //public boolean isBounded();
      //public boolean isNumeric();
      //public short getCardinalityFacet();
  }
  
  /**
   * atomic types
   */
  interface XSAtomicSimpleType extends XSSimpleType {
      // return the built-in primitive type
      public XSSimpleType getPrimitiveType();
  }
  
  /**
   * list types
   */
  interface XSListSimpleType extends XSSimpleType {
      // return the item type
      public XSSimpleType getItemType();
  }
  
  /**
   * union types
   */
  interface XSUnionSimpleType extends XSSimpleType {
      // return the member types
      public XSSimpleType[] getMemberTypes();
  }
  
  /**
   * context for validatoin. it's useful for some types:
   *   ENTITY: check whether an entity is declared or unparsed
   *   ID    : check whether an ID value is declared
   *           declare a new ID value
   *   IDREF : declare a new IDREF value (for later checking against ID values)
   *   QName : resolve a prefix to a namespace uri
   *           get a string to the symbol table, to compare by reference
   */
  interface ValidationContext {
  
      // entity
      public boolean isEntityDeclared (String name);
      public boolean isEntityUnparsed (String name);
  
      // id
      public boolean isIdDeclared (String name);
      public void    addId(String name);
  
      // idref
      public void addIdRef(String name);
  
      // get symbol from symbol table
      public String getSymbol (String symbol);
  
      // qname
      public String getURI(String prefix);
  }
  
  /**
   * The class for all facets to be passed to applyFacets()
   */
  class XSFacets {
      int length;
      int minLength;
      int maxLength;
      short whiteSpace;
      int totalDigits;
      int fractionDigits;
      String patterh;
      String[] enumeration;
      String maxInclusive;
      String maxExclusive;
      String minInclusive;
      String minExclusive;
  }
  
  
  
  1.1                  xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/ListDV.java
  
  Index: ListDV.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    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
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    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,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 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
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.xerces.impl.v2.new_datatypes;
  
  /**
   * Represent the schema list types
   *
   * @author Neeraj Bajaj, Sun Microsystems, inc.
   * @author Sandy Gao, IBM
   *
   * @version $Id: ListDV.java,v 1.1 2001/11/09 00:30:37 sandygao Exp $
   */
  public class ListDV extends TypeValidator{
  
      public short getAllowedFacets(){
            return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE );
      }
  
      // this method should never be called: XSSimpleTypeDecl is responsible for
      // calling the item type for the convertion
      public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException{
          return content;
      }
  
  } // class ListDV
  
  
  
  1.1                  xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/IDREFDV.java
  
  Index: IDREFDV.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    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
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    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,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 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
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.xerces.impl.v2.new_datatypes;
  
  import org.apache.xerces.util.XMLChar;
  
  /**
   * Represent the schema type "IDREF"
   *
   * @author Neeraj Bajaj, Sun Microsystems, inc.
   * @author Sandy Gao, IBM
   *
   * @version $Id: IDREFDV.java,v 1.1 2001/11/09 00:30:37 sandygao Exp $
   */
  public class IDREFDV extends TypeValidator{
  
      public short getAllowedFacets(){
          return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE );
      }
  
      public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
          if (!XMLChar.isValidNCName(content)) {
              throw new InvalidDatatypeValueException("Value '"+content+"' is not a valid ID");
          }
          return content;
      }
  
      public void checkExtraRules(Object value, ValidationContext context) throws InvalidDatatypeValueException {
          context.addIdRef((String)value);
      }
  
  }//IDREF class
  
  
  1.1                  xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/IDDV.java
  
  Index: IDDV.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    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
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    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,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 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
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.xerces.impl.v2.new_datatypes;
  
  import org.apache.xerces.util.XMLChar;
  
  /**
   * Represent the schema type "ID"
   *
   * @author Neeraj Bajaj, Sun Microsystems, inc.
   * @author Sandy Gao, IBM
   *
   * @version $Id: IDDV.java,v 1.1 2001/11/09 00:30:37 sandygao Exp $
   */
  public class IDDV extends TypeValidator{
  
      public short getAllowedFacets(){
          return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE );
      }
  
      public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
          if (!XMLChar.isValidNCName(content)) {
              throw new InvalidDatatypeValueException("Value '"+content+"' is not a valid ID");
          }
          return content;
      }
  
      public void checkExtraRules(Object value, ValidationContext context) throws InvalidDatatypeValueException {
          String content = (String)value;
          if (context.isIdDeclared(content))
              throw new InvalidDatatypeValueException("Value '"+content+"' is not a valid ID");
          context.addId(content);
      }
  } // class IDDV
  
  
  
  1.1                  xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/EntityDV.java
  
  Index: EntityDV.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    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
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    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,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 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
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.xerces.impl.v2.new_datatypes;
  
  import org.apache.xerces.util.XMLChar;
  
  /**
   * Represent the schema type "entity"
   *
   * @author Neeraj Bajaj, Sun Microsystems, inc.
   * @author Sandy Gao, IBM
   *
   * @version $Id: EntityDV.java,v 1.1 2001/11/09 00:30:37 sandygao Exp $
   */
  public class EntityDV extends TypeValidator {
  
      public short getAllowedFacets(){
          return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE );
      }
  
      public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
          if (!XMLChar.isValidNCName(content)) {
              throw new InvalidDatatypeValueException("Value '"+content+"' is not a valid ID");
          }
  
          return content;
      }
  
      public void checkExtraRules(Object value, ValidationContext context) throws InvalidDatatypeValueException {
          if (!context.isEntityDeclared((String)value)) {
              throw new InvalidDatatypeValueException("entity not declared");
          }
      }
  
  } // class EntityDV
  
  
  
  1.1                  xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/DurationDV.java
  
  Index: DurationDV.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999, 2000 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    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
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    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,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 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
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.xerces.impl.v2.new_datatypes;
  
  /**
   * Validator for <duration> datatype (W3C Schema Datatypes)
   *
   * @author Elena Litani
   * @author Gopal Sharma, SUN Microsystem Inc.
   * @version $Id: DurationDV.java,v 1.1 2001/11/09 00:30:37 sandygao Exp $
   */
  public class DurationDV extends AbstractDateTimeDV {
  
      // order-relation on duration is a partial order. The dates below are used to
      // for comparison of 2 durations, based on the fact that
      // duration x and y is x<=y iff s+x<=s+y
      // see 3.2.6 duration W3C schema datatype specs
      //
      // the dates are in format: {CCYY,MM,DD, H, S, M, MS, timezone}
      private final static int[][] DATETIMES= {
          {1696, 9, 1, 0, 0, 0, 0, 'Z'},
          {1697, 2, 1, 0, 0, 0, 0, 'Z'},
          {1903, 3, 1, 0, 0, 0, 0, 'Z'},
          {1903, 7, 1, 0, 0, 0, 0, 'Z'}};
  
      private int[][] fDuration = null;
  
      public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException{
          try{
              return parse(content, null);
          } catch (Exception ex) {
              throw new InvalidDatatypeValueException("not a valid duration");
          }
      }
  
      /**
       * Parses, validates and computes normalized version of duration object
       *
       * @param str    The lexical representation of duration object PnYn MnDTnH nMnS
       * @param date   uninitialized date object
       * @return normalized date representation
       * @exception Exception Invalid lexical representation
       */
      protected int[] parse(String str, int[] date) throws SchemaDateTimeException{
  
          //PnYn MnDTnH nMnS: -P1Y2M3DT10H30M
          resetBuffer(str);
  
          //create structure to hold an object
          if ( date== null ) {
              date=new int[TOTAL_SIZE];
          }
          resetDateObj(date);
  
  
          char c=fBuffer.charAt(fStart++);
          if ( c!='P' && c!='-' ) {
              throw new SchemaDateTimeException();
          }
          else {
              date[utc]=(c=='-')?'-':0;
              if ( c=='-' && fBuffer.charAt(fStart++)!='P' ) {
                  throw new SchemaDateTimeException();
              }
          }
  
          int negate = 1;
          //negative duration
          if ( date[utc]=='-' ) {
              negate = -1;
  
          }
          //at least one number and designator must be seen after P
          boolean designator = false;
  
          int endDate = indexOf (fStart, fEnd, 'T');
          if ( endDate == -1 ) {
              endDate = fEnd;
          }
          //find 'Y'
          int end = indexOf (fStart, endDate, 'Y');
          if ( end!=-1 ) {
              //scan year
              date[CY]=negate * parseInt(fStart,end);
              fStart = end+1;
              designator = true;
          }
  
          end = indexOf (fStart, endDate, 'M');
          if ( end!=-1 ) {
              //scan month
              date[M]=negate * parseInt(fStart,end);
              fStart = end+1;
              designator = true;
          }
  
          end = indexOf (fStart, endDate, 'D');
          if ( end!=-1 ) {
              //scan day
              date[D]=negate * parseInt(fStart,end);
              fStart = end+1;
              designator = true;
          }
  
          if ( fEnd == endDate && fStart!=fEnd ) {
              throw new SchemaDateTimeException();
          }
          if ( fEnd !=endDate ) {
  
              //scan hours, minutes, seconds
              //REVISIT: can any item include a decimal fraction or only seconds?
              //
  
              end = indexOf (++fStart, fEnd, 'H');
              if ( end!=-1 ) {
                  //scan hours
                  date[h]=negate * parseInt(fStart,end);
                  fStart=end+1;
                  designator = true;
              }
  
              end = indexOf (fStart, fEnd, 'M');
              if ( end!=-1 ) {
                  //scan min
                  date[m]=negate * parseInt(fStart,end);
                  fStart=end+1;
                  designator = true;
              }
  
              end = indexOf (fStart, fEnd, 'S');
              if ( end!=-1 ) {
                  //scan seconds
                  int mlsec = indexOf (fStart, end, '.');
                  if ( mlsec >0 ) {
                      date[s]  = negate * parseInt (fStart, mlsec);
                      date[ms] = negate * parseInt (mlsec+1, end);
                  }
                  else {
                      date[s]=negate * parseInt(fStart,end);
                  }
                  fStart=end+1;
                  designator = true;
              }
              // no additional data shouls appear after last item
              // P1Y1M1DT is illigal value as well
              if ( fStart != fEnd || fBuffer.charAt(--fStart)=='T' ) {
                  throw new SchemaDateTimeException();
              }
          }
  
          if ( !designator ) {
              throw new SchemaDateTimeException();
          }
  
          return date;
      }
  
      /**
       * Compares 2 given durations. (refer to W3C Schema Datatypes "3.2.6 duration")
       *
       * @param date1  Unnormalized duration
       * @param date2  Unnormalized duration
       * @param strict (min/max)Exclusive strict == true ( LESS_THAN ) or ( GREATER_THAN )
       *               (min/max)Inclusive strict == false (LESS_EQUAL) or (GREATER_EQUAL)
       * @return
       */
      protected  short compareDates(int[] date1, int[] date2, boolean strict) {
  
          //REVISIT: this is unoptimazed vs of comparing 2 durations
          //         Algorithm is described in 3.2.6.2 W3C Schema Datatype specs
          //
  
          //add constA to both durations
          short resultA, resultB= INDETERMINATE;
  
          //try and see if the objects are equal
          resultA = compareOrder (date1, date2);
          if ( resultA == 0 ) {
              return 0;
          }
          if ( fDuration == null ) {
              fDuration = new int[2][TOTAL_SIZE];
          }
          //long comparison algorithm is required
          int[] tempA = addDuration (date1, 0, fDuration[0]);
          int[] tempB = addDuration (date2, 0, fDuration[1]);
          resultA =  compareOrder(tempA, tempB);
          if ( resultA == INDETERMINATE ) {
              return INDETERMINATE;
          }
  
          tempA = addDuration(date1, 1, fDuration[0]);
          tempB = addDuration(date2, 1, fDuration[1]);
          resultB = compareOrder(tempA, tempB);
          resultA = compareResults(resultA, resultB, strict);
          if (resultA == INDETERMINATE) {
              return INDETERMINATE;
          }
  
          tempA = addDuration(date1, 2, fDuration[0]);
          tempB = addDuration(date2, 2, fDuration[1]);
          resultB = compareOrder(tempA, tempB);
          resultA = compareResults(resultA, resultB, strict);
          if (resultA == INDETERMINATE) {
              return INDETERMINATE;
          }
  
          tempA = addDuration(date1, 3, fDuration[0]);
          tempB = addDuration(date2, 3, fDuration[1]);
          resultB = compareOrder(tempA, tempB);
          resultA = compareResults(resultA, resultB, strict);
  
          return resultA;
      }
  
      private short compareResults(short resultA, short resultB, boolean strict){
  
        if ( resultB == INDETERMINATE ) {
              return INDETERMINATE;
          }
          else if ( resultA!=resultB && strict ) {
              return INDETERMINATE;
          }
          else if ( resultA!=resultB && !strict ) {
              if ( resultA!=0 && resultB!=0 ) {
                  return INDETERMINATE;
              }
              else {
                  return (resultA!=0)?resultA:resultB;
              }
          }
          return resultA;
      }
  
      private int[] addDuration(int[] date, int index, int[] duration) {
  
          //REVISIT: some code could be shared between normalize() and this method,
          //         however is it worth moving it? The structures are different...
          //
  
          resetDateObj(duration);
          //add months (may be modified additionaly below)
          int temp = DATETIMES[index][M] + date[M];
          duration[M] = modulo (temp, 1, 13);
          int carry = fQuotient (temp, 1, 13);
  
          //add years (may be modified additionaly below)
          duration[CY]=DATETIMES[index][CY] + date[CY] + carry;
  
          //add seconds
          temp = DATETIMES[index][s] + date[s];
          carry = fQuotient (temp, 60);
          duration[s] =  mod(temp, 60, carry);
  
          //add minutes
          temp = DATETIMES[index][m] +date[m] + carry;
          carry = fQuotient (temp, 60);
          duration[m]= mod(temp, 60, carry);
  
          //add hours
          temp = DATETIMES[index][h] + date[h] + carry;
          carry = fQuotient(temp, 24);
          duration[h] = mod(temp, 24, carry);
  
  
          duration[D]=DATETIMES[index][D] + date[D] + carry;
  
          while ( true ) {
  
              temp=maxDayInMonthFor(duration[CY], duration[M]);
              if ( duration[D] < 1 ) { //original duration was negative
                  duration[D] = duration[D] + maxDayInMonthFor(duration[CY], duration[M]-1);
                  carry=-1;
              }
              else if ( duration[D] > temp ) {
                  duration[D] = duration[D] - temp;
                  carry=1;
              }
              else {
                  break;
              }
              temp = duration[M]+carry;
              duration[M] = modulo(temp, 1, 13);
              duration[CY] = duration[CY]+fQuotient(temp, 1, 13);
          }
  
          duration[utc]='Z';
          return duration;
      }
  
      protected String dateToString(int[] date) {
          message.setLength(0);
          int negate = 1;
          if ( date[CY]<0 ) {
              message.append('-');
              negate=-1;
          }
          message.append('P');
          message.append(negate * date[CY]);
          message.append('Y');
          message.append(negate * date[M]);
          message.append('M');
          message.append(negate * date[D]);
          message.append('D');
          message.append('T');
          message.append(negate * date[h]);
          message.append('H');
          message.append(negate * date[m]);
          message.append('M');
          message.append(negate * date[s]);
          message.append('.');
          message.append(negate * date[ms]);
          message.append('S');
  
          return message.toString();
      }
  }
  
  
  
  1.1                  xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/DateDV.java
  
  Index: DateDV.java
  ===================================================================
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999, 2000 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    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
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    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,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 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
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.xerces.impl.v2.new_datatypes;
  
  import java.util.Hashtable;
  import org.apache.xerces.impl.XMLErrorReporter;
  
  /**
   * Validator for <date> datatype (W3C Schema datatypes)
   *
   * @author Elena Litani
   * @Gopal Sharma, SUN Microsystems Inc.
   *
   * @version $Id: DateDV.java,v 1.1 2001/11/09 00:30:37 sandygao Exp $
   */
  public class DateDV extends DateTimeDV {
  
      public Object getActualValue(String content) throws InvalidDatatypeValueException {
          try{
              return parse(content, null);
          } catch(Exception ex){
              throw new InvalidDatatypeValueException("not a valid date");
          }
      }
  
      /**
       * Parses, validates and computes normalized version of dateTime object
       *
       * @param str    The lexical representation of dateTime object CCYY-MM-DD
       *               with possible time zone Z or (-),(+)hh:mm
       * @param date   uninitialized date object
       * @return normalized dateTime representation
       * @exception Exception Invalid lexical representation
       */
      protected int[] parse(String str, int[] date) throws SchemaDateTimeException{
          resetBuffer(str);
          //create structure to hold an object
  
          if ( date == null ) {
              date = new int[TOTAL_SIZE];
          }
          resetDateObj(date);
          // get date
  
          getDate(fStart, fEnd, date);
          parseTimeZone (fEnd, date);
  
          //validate and normalize
          //REVISIT: do we need SchemaDateTimeException?
          validateDateTime(date);
  
          if ( date[utc]!=0 && date[utc]!='Z' ) {
              normalize(date);
          }
          return date;
      }
  
  }
  
  
  
  
  
  1.1                  xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/DatatypeMessageProvider.java
  
  Index: DatatypeMessageProvider.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999, 2000 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    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
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    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,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 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
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.xerces.impl.v2.new_datatypes;
  
  import java.util.ListResourceBundle;
  import java.util.Locale;
  import java.util.ResourceBundle;
  import java.util.MissingResourceException;
  import org.apache.xerces.util.MessageFormatter;
  
  
  
  /**
   *
   * @author Jeffrey Rodriguez
   * @version $Id: DatatypeMessageProvider.java,v 1.1 2001/11/09 00:30:37 sandygao Exp $
   */
  public class DatatypeMessageProvider implements MessageFormatter {
      /**
       * The domain of messages concerning the XML Schema: Datatypes specification.
       */
      public static final String DATATYPE_DOMAIN = "http://www.w3.org/TR/xml-schema-2";
  
      /**
       * Set the locale used for error messages
       *
       * @param locale the new locale
       */
      public void setLocale(Locale locale) {
          fLocale = locale;
      }
      /**
       * get the local used for error messages
       *
       * @return the locale
       */
      public Locale getLocale() {
          return fLocale;
      }
  
      //
      // MessageFormatter methods
      //
  
      /**
       * Formats a message with the specified arguments using the given
       * locale information.
       *
       * @param locale    The locale of the message.
       * @param key       The message key.
       * @param arguments The message replacement text arguments. The order
       *                  of the arguments must match that of the placeholders
       *                  in the actual message.
       *
       * @return Returns the formatted message.
       *
       * @throws MissingResourceException Thrown if the message with the
       *                                  specified key cannot be found.
       */
      public String formatMessage(Locale locale, String key, Object[] args)
          throws MissingResourceException {
          boolean throwex = false;
          if ( fResourceBundle == null || locale != fLocale ) {
              if ( locale != null )
                  fResourceBundle = ListResourceBundle.getBundle("org.apache.xerces.impl.msg.DatatypeMessages", locale);
              if ( fResourceBundle == null )
                  fResourceBundle = ListResourceBundle.getBundle("org.apache.xerces.impl.msg.DatatypeMessages");
          }
          int majorCode = -1;
          for (int i = 0; i < fgMessageKeys.length; i++) {
              if (fgMessageKeys[i].equals(key)) {
                  majorCode = i;
                  break;
              }
          }
          if (majorCode == -1) {
              majorCode = MSG_BAD_MAJORCODE;
              throwex = true;
          }
          String msgKey = fgMessageKeys[majorCode];
          String msg = fResourceBundle.getString(msgKey);
          if ( args != null ) {
              try {
                  msg = java.text.MessageFormat.format(msg, args);
              }
              catch ( Exception e ) {
                  msg = fResourceBundle.getString(fgMessageKeys[MSG_FORMAT_FAILURE]);
                  msg += " " + fResourceBundle.getString(msgKey);
              }
          }
  
          if ( throwex ) {
              throw new RuntimeException(msg);
          }
          return msg;
      }
      //
      //
      //
      private Locale fLocale = null;
      private ResourceBundle fResourceBundle = null;
      //
      // Major Codes
      //
      private static int counter = 0;
      public static final int
      MSG_BAD_MAJORCODE  = counter++,              //  majorCode parameter to createMessage was out of bounds
      MSG_FORMAT_FAILURE = counter++,             //  exception thrown during messageFormat call
      NOT_BOOLEAN        = counter++,
      NOT_DECIMAL        = counter++,
      NOT_FLOAT          = counter++,
      NOT_DOUBLE         = counter++,
      INVALID_ENUM_VALUE = counter++,
      OUT_OF_BOUNDS      = counter++,
      NOT_ENUM_VALUE      = counter++,
      FRACTION_GREATER_TOTALDIGITS   = counter++,
      FRACTION_EXCEEDED      = counter++,
      TOTALDIGITS_EXCEEDED   = counter++,
      ILLEGAL_FACET_VALUE    = counter++,
      ILLEGAL_ANYURI_FACET   = counter++,
      ILLEGAL_BOOLEAN_FACET  = counter++,
      ILLEGAL_BASE64_FACET   = counter++,
      ILLEGAL_DATETIME_FACET = counter++,
      ILLEGAL_DECIMAL_FACET  = counter++,
      ILLEGAL_DOUBLE_FACET   = counter++,
      ILLEGAL_FLOAT_FACET    = counter++,
      ILLEGAL_HEXBINARY_FACET  = counter++,
      ILLEGAL_NOTATION_FACET   = counter++,
      ILLEGAL_QNAME_FACET      = counter++,
      ILLEGAL_STRING_FACET     = counter++,
      ILLEGAL_LIST_FACET       = counter++,
      ILLEGAL_UNION_FACET      = counter++,
      ILLEGAL_ANYSIMPLETYPE_FACET  = counter++,
  
      MSG_MAX_CODE = counter;
  
      //
      // Minor Codes
      //
      public static final int
      MSG_NONE = 0;
  
      public static final String[] fgMessageKeys = {
          "BadMajorCode",
          "FormatFailed",
          "NotBoolean",
          "NotDecimal",
          "NotFloat",
          "NotDouble",
          "InvalidEnumValue",
          "OutOfBounds",
          "NotAnEnumValue",
          "FractionDigitsLargerThanTotalDigits",
          "FractionDigitsExceeded",
          "TotalDigitsExceeded",
          "IllegalFacetValue",
          "IllegalAnyURIFacet",
          "IllegalBooleanFacet",
          "IllegalBase64Facet",
          "IllegalDateTimeFacet",
          "IllegalDecimalFacet",
          "IllegalDoubleFacet",
          "IllegalFloatFacet",
          "IllegalHexBinaryFacet",
          "IllegalNotationFacet",
          "IllegalQNameFacet",
          "IllegalStringFacet",
          "IllegalListFacet",
          "IllegalUnionFacet",
          "IllegalAnySimpleTypeFacet"
      };
  }
  
  
  
  1.1                  xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/BooleanDV.java
  
  Index: BooleanDV.java
  ===================================================================
  package org.apache.xerces.impl.v2.new_datatypes;
  
  import java.util.Locale;
  
  /**
   * Represent the schema type "boolean"
   *
   * @author Neeraj Bajaj, Sun Microsystems, inc.
   * @author Sandy Gao, IBM
   *
   * @version $Id: BooleanDV.java,v 1.1 2001/11/09 00:30:37 sandygao Exp $
   */
  public class BooleanDV extends TypeValidator{
  
      private static final String fValueSpace[] = {"false", "true", "0", "1"};
  
      public short getAllowedFacets(){
          return (XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_WHITESPACE);
      }
  
      public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
          Boolean ret = null;
  
          if (content.equals(fValueSpace[0]) || content.equals(fValueSpace[2]))
              ret = Boolean.FALSE;
          else if (content.equals(fValueSpace[1]) || content.equals(fValueSpace[3]))
              ret = Boolean.TRUE;
          else
              throw new InvalidDatatypeValueException(DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.NOT_BOOLEAN],
                                                      new Object[]{content});
          return ret;
      }
  
  } // class BooleanDV
  
  
  
  1.1                  xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/AnyURIDV.java
  
  Index: AnyURIDV.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    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
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    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,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 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
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.xerces.impl.v2.new_datatypes;
  
  import org.apache.xerces.util.URI;
  
  /**
   * Represent the schema type "anyURI"
   *
   * @author Neeraj Bajaj, Sun Microsystems, inc.
   * @author Sandy Gao, IBM
   *
   * @version $Id: AnyURIDV.java,v 1.1 2001/11/09 00:30:37 sandygao Exp $
   */
  public class AnyURIDV extends TypeValidator {
  
      public short getAllowedFacets(){
          return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE );
      }
  
      // before we return string we have to make sure it is correct URI as per spec.
      // for some types (string and derived), they just return the string itself
      public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
          // check 3.2.17.c0 must: URI (rfc 2396/2723)
          try {
              if( content.length() != 0 ) {
                  URI tempURI = new URI("http://www.template.com");
                  // Support for relative URLs
                  // According to Java 1.1: URLs may also be specified with a
                  // String and the URL object that it is related to.
                  new URI(tempURI, content );
              }
          } catch (  URI.MalformedURIException ex ) {
              throw new InvalidDatatypeValueException("Value '"+content+"' is a Malformed URI");
          }
  
          // REVISIT: do we need to return the new URI object?
          return content;
      }
  
      // REVISIT: do we need to compare based on URI, or based on String?
      // public boolean isEqual(Object value1, Object value2);
  
  } // class AnyURIDV
  
  
  
  1.1                  xml-xerces/java/src/org/apache/xerces/impl/v2/new_datatypes/AnySimpleDV.java
  
  Index: AnySimpleDV.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    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
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    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,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 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
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.xerces.impl.v2.new_datatypes;
  
  /**
   * Represent the schema type "anySimpleType"
   *
   * @author Neeraj Bajaj, Sun Microsystems, inc.
   * @author Sandy Gao, IBM
   *
   * @version $Id: AnySimpleDV.java,v 1.1 2001/11/09 00:30:37 sandygao Exp $
   */
  public class AnySimpleDV extends TypeValidator {
  
      public short getAllowedFacets() {
          // anySimpleType doesn't allow any facet, not even whiteSpace
          return 0;
      }
  
      public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
          return content;
      }
  
  } // class AnySimpleDV
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org