You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2007/03/14 21:37:48 UTC

svn commit: r518314 [2/2] - /xerces/java/trunk/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java

Modified: xerces/java/trunk/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java?view=diff&rev=518314&r1=518313&r2=518314
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java Wed Mar 14 13:37:48 2007
@@ -57,326 +57,326 @@
  * @version $Id$
  */
 public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
-	
-	static final short DV_STRING        = PRIMITIVE_STRING;
-	static final short DV_BOOLEAN       = PRIMITIVE_BOOLEAN;
-	static final short DV_DECIMAL       = PRIMITIVE_DECIMAL;
-	static final short DV_FLOAT         = PRIMITIVE_FLOAT;
-	static final short DV_DOUBLE        = PRIMITIVE_DOUBLE;
-	static final short DV_DURATION      = PRIMITIVE_DURATION;
-	static final short DV_DATETIME      = PRIMITIVE_DATETIME;
-	static final short DV_TIME          = PRIMITIVE_TIME;
-	static final short DV_DATE          = PRIMITIVE_DATE;
-	static final short DV_GYEARMONTH    = PRIMITIVE_GYEARMONTH;
-	static final short DV_GYEAR         = PRIMITIVE_GYEAR;
-	static final short DV_GMONTHDAY     = PRIMITIVE_GMONTHDAY;
-	static final short DV_GDAY          = PRIMITIVE_GDAY;
-	static final short DV_GMONTH        = PRIMITIVE_GMONTH;
-	static final short DV_HEXBINARY     = PRIMITIVE_HEXBINARY;
-	static final short DV_BASE64BINARY  = PRIMITIVE_BASE64BINARY;
-	static final short DV_ANYURI        = PRIMITIVE_ANYURI;
-	static final short DV_QNAME         = PRIMITIVE_QNAME;
-	static final short DV_PRECISIONDECIMAL = PRIMITIVE_PRECISIONDECIMAL;
-	static final short DV_NOTATION      = PRIMITIVE_NOTATION;
-	
-	static final short DV_ANYSIMPLETYPE = 0;
-	static final short DV_ID            = DV_NOTATION + 1;
-	static final short DV_IDREF         = DV_NOTATION + 2;
-	static final short DV_ENTITY        = DV_NOTATION + 3;
-	static final short DV_INTEGER       = DV_NOTATION + 4;
-	static final short DV_LIST          = DV_NOTATION + 5;
-	static final short DV_UNION         = DV_NOTATION + 6;
-	static final short DV_YEARMONTHDURATION = DV_NOTATION + 7;
-	static final short DV_DAYTIMEDURATION	= DV_NOTATION + 8;
-	static final short DV_ANYATOMICTYPE = DV_NOTATION + 9;
-	
-	static final TypeValidator[] fDVs = {
-			new AnySimpleDV(),
-			new StringDV(),
-			new BooleanDV(),
-			new DecimalDV(),
-			new FloatDV(),
-			new DoubleDV(),
-			new DurationDV(),
-			new DateTimeDV(),
-			new TimeDV(),
-			new DateDV(),
-			new YearMonthDV(),
-			new YearDV(),
-			new MonthDayDV(),
-			new DayDV(),
-			new MonthDV(),
-			new HexBinaryDV(),
-			new Base64BinaryDV(),
-			new AnyURIDV(),
-			new QNameDV(),
-			new PrecisionDecimalDV(), // XML Schema 1.1 type
-			new QNameDV(),   // notation use the same one as qname
-			new IDDV(),
-			new IDREFDV(),
-			new EntityDV(),
-			new IntegerDV(),
-			new ListDV(),
-			new UnionDV(),
-			new YearMonthDurationDV(), // XML Schema 1.1 type
-			new DayTimeDurationDV(), // XML Schema 1.1 type
-			new AnyAtomicDV() // XML Schema 1.1 type
-	};
-	
-	static final short NORMALIZE_NONE = 0;
-	static final short NORMALIZE_TRIM = 1;
-	static final short NORMALIZE_FULL = 2;
-	static final short[] fDVNormalizeType = {
-			NORMALIZE_NONE, //AnySimpleDV(),
-			NORMALIZE_FULL, //StringDV(),
-			NORMALIZE_TRIM, //BooleanDV(),
-			NORMALIZE_TRIM, //DecimalDV(),
-			NORMALIZE_TRIM, //FloatDV(),
-			NORMALIZE_TRIM, //DoubleDV(),
-			NORMALIZE_TRIM, //DurationDV(),
-			NORMALIZE_TRIM, //DateTimeDV(),
-			NORMALIZE_TRIM, //TimeDV(),
-			NORMALIZE_TRIM, //DateDV(),
-			NORMALIZE_TRIM, //YearMonthDV(),
-			NORMALIZE_TRIM, //YearDV(),
-			NORMALIZE_TRIM, //MonthDayDV(),
-			NORMALIZE_TRIM, //DayDV(),
-			NORMALIZE_TRIM, //MonthDV(),
-			NORMALIZE_TRIM, //HexBinaryDV(),
-			NORMALIZE_NONE, //Base64BinaryDV(),  // Base64 know how to deal with spaces
-			NORMALIZE_TRIM, //AnyURIDV(),
-			NORMALIZE_TRIM, //QNameDV(),
-			NORMALIZE_TRIM, //PrecisionDecimalDV() (Schema 1.1)
-			NORMALIZE_TRIM, //QNameDV(),   // notation
-			NORMALIZE_TRIM, //IDDV(),
-			NORMALIZE_TRIM, //IDREFDV(),
-			NORMALIZE_TRIM, //EntityDV(),
-			NORMALIZE_TRIM, //IntegerDV(),
-			NORMALIZE_FULL, //ListDV(),
-			NORMALIZE_NONE, //UnionDV(),
-			NORMALIZE_TRIM, //YearMonthDurationDV() (Schema 1.1)
-			NORMALIZE_TRIM, //DayTimeDurationDV() (Schema 1.1)
-			NORMALIZE_NONE, //AnyAtomicDV() (Schema 1.1)
-	};
-	
-	static final short SPECIAL_PATTERN_NONE     = 0;
-	static final short SPECIAL_PATTERN_NMTOKEN  = 1;
-	static final short SPECIAL_PATTERN_NAME     = 2;
-	static final short SPECIAL_PATTERN_NCNAME   = 3;
-	
-	static final String[] SPECIAL_PATTERN_STRING   = {
-			"NONE", "NMTOKEN", "Name", "NCName"
-	};
-	
-	static final String[] WS_FACET_STRING = {
-			"preserve", "replace", "collapse"
-	};
-	
-	static final String URI_SCHEMAFORSCHEMA = "http://www.w3.org/2001/XMLSchema";
-	static final String ANY_TYPE = "anyType";
-    
+
+    static final short DV_STRING        = PRIMITIVE_STRING;
+    static final short DV_BOOLEAN       = PRIMITIVE_BOOLEAN;
+    static final short DV_DECIMAL       = PRIMITIVE_DECIMAL;
+    static final short DV_FLOAT         = PRIMITIVE_FLOAT;
+    static final short DV_DOUBLE        = PRIMITIVE_DOUBLE;
+    static final short DV_DURATION      = PRIMITIVE_DURATION;
+    static final short DV_DATETIME      = PRIMITIVE_DATETIME;
+    static final short DV_TIME          = PRIMITIVE_TIME;
+    static final short DV_DATE          = PRIMITIVE_DATE;
+    static final short DV_GYEARMONTH    = PRIMITIVE_GYEARMONTH;
+    static final short DV_GYEAR         = PRIMITIVE_GYEAR;
+    static final short DV_GMONTHDAY     = PRIMITIVE_GMONTHDAY;
+    static final short DV_GDAY          = PRIMITIVE_GDAY;
+    static final short DV_GMONTH        = PRIMITIVE_GMONTH;
+    static final short DV_HEXBINARY     = PRIMITIVE_HEXBINARY;
+    static final short DV_BASE64BINARY  = PRIMITIVE_BASE64BINARY;
+    static final short DV_ANYURI        = PRIMITIVE_ANYURI;
+    static final short DV_QNAME         = PRIMITIVE_QNAME;
+    static final short DV_PRECISIONDECIMAL = PRIMITIVE_PRECISIONDECIMAL;
+    static final short DV_NOTATION      = PRIMITIVE_NOTATION;
+
+    static final short DV_ANYSIMPLETYPE = 0;
+    static final short DV_ID            = DV_NOTATION + 1;
+    static final short DV_IDREF         = DV_NOTATION + 2;
+    static final short DV_ENTITY        = DV_NOTATION + 3;
+    static final short DV_INTEGER       = DV_NOTATION + 4;
+    static final short DV_LIST          = DV_NOTATION + 5;
+    static final short DV_UNION         = DV_NOTATION + 6;
+    static final short DV_YEARMONTHDURATION = DV_NOTATION + 7;
+    static final short DV_DAYTIMEDURATION	= DV_NOTATION + 8;
+    static final short DV_ANYATOMICTYPE = DV_NOTATION + 9;
+
+    static final TypeValidator[] fDVs = {
+        new AnySimpleDV(),
+        new StringDV(),
+        new BooleanDV(),
+        new DecimalDV(),
+        new FloatDV(),
+        new DoubleDV(),
+        new DurationDV(),
+        new DateTimeDV(),
+        new TimeDV(),
+        new DateDV(),
+        new YearMonthDV(),
+        new YearDV(),
+        new MonthDayDV(),
+        new DayDV(),
+        new MonthDV(),
+        new HexBinaryDV(),
+        new Base64BinaryDV(),
+        new AnyURIDV(),
+        new QNameDV(),
+        new PrecisionDecimalDV(), // XML Schema 1.1 type
+        new QNameDV(),   // notation use the same one as qname
+        new IDDV(),
+        new IDREFDV(),
+        new EntityDV(),
+        new IntegerDV(),
+        new ListDV(),
+        new UnionDV(),
+        new YearMonthDurationDV(), // XML Schema 1.1 type
+        new DayTimeDurationDV(), // XML Schema 1.1 type
+        new AnyAtomicDV() // XML Schema 1.1 type
+    };
+
+    static final short NORMALIZE_NONE = 0;
+    static final short NORMALIZE_TRIM = 1;
+    static final short NORMALIZE_FULL = 2;
+    static final short[] fDVNormalizeType = {
+        NORMALIZE_NONE, //AnySimpleDV(),
+        NORMALIZE_FULL, //StringDV(),
+        NORMALIZE_TRIM, //BooleanDV(),
+        NORMALIZE_TRIM, //DecimalDV(),
+        NORMALIZE_TRIM, //FloatDV(),
+        NORMALIZE_TRIM, //DoubleDV(),
+        NORMALIZE_TRIM, //DurationDV(),
+        NORMALIZE_TRIM, //DateTimeDV(),
+        NORMALIZE_TRIM, //TimeDV(),
+        NORMALIZE_TRIM, //DateDV(),
+        NORMALIZE_TRIM, //YearMonthDV(),
+        NORMALIZE_TRIM, //YearDV(),
+        NORMALIZE_TRIM, //MonthDayDV(),
+        NORMALIZE_TRIM, //DayDV(),
+        NORMALIZE_TRIM, //MonthDV(),
+        NORMALIZE_TRIM, //HexBinaryDV(),
+        NORMALIZE_NONE, //Base64BinaryDV(),  // Base64 know how to deal with spaces
+        NORMALIZE_TRIM, //AnyURIDV(),
+        NORMALIZE_TRIM, //QNameDV(),
+        NORMALIZE_TRIM, //PrecisionDecimalDV() (Schema 1.1)
+        NORMALIZE_TRIM, //QNameDV(),   // notation
+        NORMALIZE_TRIM, //IDDV(),
+        NORMALIZE_TRIM, //IDREFDV(),
+        NORMALIZE_TRIM, //EntityDV(),
+        NORMALIZE_TRIM, //IntegerDV(),
+        NORMALIZE_FULL, //ListDV(),
+        NORMALIZE_NONE, //UnionDV(),
+        NORMALIZE_TRIM, //YearMonthDurationDV() (Schema 1.1)
+        NORMALIZE_TRIM, //DayTimeDurationDV() (Schema 1.1)
+        NORMALIZE_NONE, //AnyAtomicDV() (Schema 1.1)
+    };
+
+    static final short SPECIAL_PATTERN_NONE     = 0;
+    static final short SPECIAL_PATTERN_NMTOKEN  = 1;
+    static final short SPECIAL_PATTERN_NAME     = 2;
+    static final short SPECIAL_PATTERN_NCNAME   = 3;
+
+    static final String[] SPECIAL_PATTERN_STRING   = {
+        "NONE", "NMTOKEN", "Name", "NCName"
+    };
+
+    static final String[] WS_FACET_STRING = {
+        "preserve", "replace", "collapse"
+    };
+
+    static final String URI_SCHEMAFORSCHEMA = "http://www.w3.org/2001/XMLSchema";
+    static final String ANY_TYPE = "anyType";
+
     // XML Schema 1.1 type constants
     public static final short YEARMONTHDURATION_DT      = 46;
     public static final short DAYTIMEDURATION_DT        = 47;   
     public static final short PRECISIONDECIMAL_DT       = 48;
     public static final short ANYATOMICTYPE_DT          = 49;
-	
-	// DOM Level 3 TypeInfo Derivation Method constants
-	static final int DERIVATION_ANY = 0;
-	static final int DERIVATION_RESTRICTION = 1;
-	static final int DERIVATION_EXTENSION = 2;
-	static final int DERIVATION_UNION = 4;
-	static final int DERIVATION_LIST = 8;
-	
-	static final ValidationContext fEmptyContext = new ValidationContext() {
-		public boolean needFacetChecking() {
-			return true;
-		}
-		public boolean needExtraChecking() {
-			return false;
-		}
-		public boolean needToNormalize() {
-			return true;
-		}
-		public boolean useNamespaces () {
-			return true;
-		}
-		public boolean isEntityDeclared (String name) {
-			return false;
-		}
-		public boolean isEntityUnparsed (String name) {
-			return false;
-		}
-		public boolean isIdDeclared (String name) {
-			return false;
-		}
-		public void addId(String name) {
-		}
-		public void addIdRef(String name) {
-		}
-		public String getSymbol (String symbol) {
-			return symbol.intern();
-		}
-		public String getURI(String prefix) {
-			return null;
-		}
-	};
-	
-	// this will be true if this is a static XSSimpleTypeDecl
-	// and hence must remain immutable (i.e., applyFacets
-	// may not be permitted to have any effect).
-	private boolean fIsImmutable = false;
-	
-	private XSSimpleTypeDecl fItemType;
-	private XSSimpleTypeDecl[] fMemberTypes;
-	// The most specific built-in type kind.
-	private short fBuiltInKind;
-	
-	private String fTypeName;
-	private String fTargetNamespace;
-	private short fFinalSet = 0;
-	private XSSimpleTypeDecl fBase;
-	private short fVariety = -1;
-	private short fValidationDV = -1;
-	
-	private short fFacetsDefined = 0;
-	private short fFixedFacet = 0;
-	
-	//for constraining facets
-	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 Vector fPattern;
-	private Vector fPatternStr;
-	private Vector fEnumeration;
-	private short[] fEnumerationType;
-	private ShortList[] fEnumerationItemType;   // used in case fenumerationType value is LIST or LISTOFUNION 
+
+    // DOM Level 3 TypeInfo Derivation Method constants
+    static final int DERIVATION_ANY = 0;
+    static final int DERIVATION_RESTRICTION = 1;
+    static final int DERIVATION_EXTENSION = 2;
+    static final int DERIVATION_UNION = 4;
+    static final int DERIVATION_LIST = 8;
+
+    static final ValidationContext fEmptyContext = new ValidationContext() {
+        public boolean needFacetChecking() {
+            return true;
+        }
+        public boolean needExtraChecking() {
+            return false;
+        }
+        public boolean needToNormalize() {
+            return true;
+        }
+        public boolean useNamespaces () {
+            return true;
+        }
+        public boolean isEntityDeclared (String name) {
+            return false;
+        }
+        public boolean isEntityUnparsed (String name) {
+            return false;
+        }
+        public boolean isIdDeclared (String name) {
+            return false;
+        }
+        public void addId(String name) {
+        }
+        public void addIdRef(String name) {
+        }
+        public String getSymbol (String symbol) {
+            return symbol.intern();
+        }
+        public String getURI(String prefix) {
+            return null;
+        }
+    };
+
+    // this will be true if this is a static XSSimpleTypeDecl
+    // and hence must remain immutable (i.e., applyFacets
+    // may not be permitted to have any effect).
+    private boolean fIsImmutable = false;
+
+    private XSSimpleTypeDecl fItemType;
+    private XSSimpleTypeDecl[] fMemberTypes;
+    // The most specific built-in type kind.
+    private short fBuiltInKind;
+
+    private String fTypeName;
+    private String fTargetNamespace;
+    private short fFinalSet = 0;
+    private XSSimpleTypeDecl fBase;
+    private short fVariety = -1;
+    private short fValidationDV = -1;
+
+    private short fFacetsDefined = 0;
+    private short fFixedFacet = 0;
+
+    //for constraining facets
+    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 Vector fPattern;
+    private Vector fPatternStr;
+    private Vector fEnumeration;
+    private short[] fEnumerationType;
+    private ShortList[] fEnumerationItemType;   // used in case fenumerationType value is LIST or LISTOFUNION 
     private ShortList fEnumerationTypeList;
     private ObjectList fEnumerationItemTypeList;
-	private StringList fLexicalPattern;
-	private StringList fLexicalEnumeration;
-	private ObjectList fActualEnumeration;
-	private Object fMaxInclusive;
-	private Object fMaxExclusive;
-	private Object fMinExclusive;
-	private Object fMinInclusive;
-	
-	// annotations for constraining facets
-	public XSAnnotation lengthAnnotation;
-	public XSAnnotation minLengthAnnotation;
-	public XSAnnotation maxLengthAnnotation;
-	public XSAnnotation whiteSpaceAnnotation;
-	public XSAnnotation totalDigitsAnnotation;
-	public XSAnnotation fractionDigitsAnnotation;
-	public XSObjectListImpl patternAnnotations;
-	public XSObjectList enumerationAnnotations;
-	public XSAnnotation maxInclusiveAnnotation;
-	public XSAnnotation maxExclusiveAnnotation;
-	public XSAnnotation minInclusiveAnnotation;
-	public XSAnnotation minExclusiveAnnotation;
-	
-	// facets as objects
-	private XSObjectListImpl fFacets;
-	
-	// enumeration and pattern facets
-	private XSObjectListImpl fMultiValueFacets;
-	
-	// simpleType annotations
-	private XSObjectList fAnnotations = null;
-	
-	private short fPatternType = SPECIAL_PATTERN_NONE;
-	
-	// for fundamental facets
-	private short fOrdered;
-	private boolean fFinite;
-	private boolean fBounded;
-	private boolean fNumeric;
-	
-	// default constructor
-	public XSSimpleTypeDecl(){}
-	
-	//Create a new built-in primitive types (and id/idref/entity/integer/yearMonthDuration)
-	protected XSSimpleTypeDecl(XSSimpleTypeDecl base, String name, short validateDV,
-			short ordered, boolean bounded, boolean finite,
-			boolean numeric, boolean isImmutable, short builtInKind) {
-		fIsImmutable = isImmutable;
-		fBase = base;
-		fTypeName = name;
-		fTargetNamespace = URI_SCHEMAFORSCHEMA;
-		// To simplify the code for anySimpleType, we treat it as an atomic type
-		fVariety = VARIETY_ATOMIC;
-		fValidationDV = validateDV;
-		fFacetsDefined = FACET_WHITESPACE;
-		if (validateDV == DV_STRING) {
-			fWhiteSpace = WS_PRESERVE;
-		} else {
-			fWhiteSpace = WS_COLLAPSE;
-			fFixedFacet = FACET_WHITESPACE;
-		}
-		this.fOrdered = ordered;
-		this.fBounded = bounded;
-		this.fFinite = finite;
-		this.fNumeric = numeric;
-		fAnnotations = null;
-		
-		// Specify the build in kind for this primitive type
-		fBuiltInKind = builtInKind;
-	}
-	
-	//Create a new simple type for restriction for built-in types
-	protected XSSimpleTypeDecl(XSSimpleTypeDecl base, String name, String uri, short finalSet, boolean isImmutable,
-			XSObjectList annotations, short builtInKind) {
-		this(base, name, uri, finalSet, isImmutable, annotations);
-		// Specify the build in kind for this built-in type
-		fBuiltInKind = builtInKind;
-	}
-	
-	//Create a new simple type for restriction.
-	protected XSSimpleTypeDecl(XSSimpleTypeDecl base, String name, String uri, short finalSet, boolean isImmutable,
-			XSObjectList annotations) {
-		fBase = base;
-		fTypeName = name;
-		fTargetNamespace = uri;
-		fFinalSet = finalSet;
-		fAnnotations = annotations;
-		
-		fVariety = fBase.fVariety;
-		fValidationDV = fBase.fValidationDV;
-		switch (fVariety) {
-		case VARIETY_ATOMIC:
-			break;
-		case VARIETY_LIST:
-			fItemType = fBase.fItemType;
-			break;
-		case VARIETY_UNION:
-			fMemberTypes = fBase.fMemberTypes;
-			break;
-		}
-		
-		// always inherit facets from the base.
-		// in case a type is created, but applyFacets is not called
-		fLength = fBase.fLength;
-		fMinLength = fBase.fMinLength;
-		fMaxLength = fBase.fMaxLength;
-		fPattern = fBase.fPattern;
-		fPatternStr = fBase.fPatternStr;
-		fEnumeration = fBase.fEnumeration;
-		fEnumerationType = fBase.fEnumerationType;
+    private StringList fLexicalPattern;
+    private StringList fLexicalEnumeration;
+    private ObjectList fActualEnumeration;
+    private Object fMaxInclusive;
+    private Object fMaxExclusive;
+    private Object fMinExclusive;
+    private Object fMinInclusive;
+
+    // annotations for constraining facets
+    public XSAnnotation lengthAnnotation;
+    public XSAnnotation minLengthAnnotation;
+    public XSAnnotation maxLengthAnnotation;
+    public XSAnnotation whiteSpaceAnnotation;
+    public XSAnnotation totalDigitsAnnotation;
+    public XSAnnotation fractionDigitsAnnotation;
+    public XSObjectListImpl patternAnnotations;
+    public XSObjectList enumerationAnnotations;
+    public XSAnnotation maxInclusiveAnnotation;
+    public XSAnnotation maxExclusiveAnnotation;
+    public XSAnnotation minInclusiveAnnotation;
+    public XSAnnotation minExclusiveAnnotation;
+
+    // facets as objects
+    private XSObjectListImpl fFacets;
+
+    // enumeration and pattern facets
+    private XSObjectListImpl fMultiValueFacets;
+
+    // simpleType annotations
+    private XSObjectList fAnnotations = null;
+
+    private short fPatternType = SPECIAL_PATTERN_NONE;
+
+    // for fundamental facets
+    private short fOrdered;
+    private boolean fFinite;
+    private boolean fBounded;
+    private boolean fNumeric;
+
+    // default constructor
+    public XSSimpleTypeDecl(){}
+
+    //Create a new built-in primitive types (and id/idref/entity/integer/yearMonthDuration)
+    protected XSSimpleTypeDecl(XSSimpleTypeDecl base, String name, short validateDV,
+            short ordered, boolean bounded, boolean finite,
+            boolean numeric, boolean isImmutable, short builtInKind) {
+        fIsImmutable = isImmutable;
+        fBase = base;
+        fTypeName = name;
+        fTargetNamespace = URI_SCHEMAFORSCHEMA;
+        // To simplify the code for anySimpleType, we treat it as an atomic type
+        fVariety = VARIETY_ATOMIC;
+        fValidationDV = validateDV;
+        fFacetsDefined = FACET_WHITESPACE;
+        if (validateDV == DV_STRING) {
+            fWhiteSpace = WS_PRESERVE;
+        } else {
+            fWhiteSpace = WS_COLLAPSE;
+            fFixedFacet = FACET_WHITESPACE;
+        }
+        this.fOrdered = ordered;
+        this.fBounded = bounded;
+        this.fFinite = finite;
+        this.fNumeric = numeric;
+        fAnnotations = null;
+
+        // Specify the build in kind for this primitive type
+        fBuiltInKind = builtInKind;
+    }
+
+    //Create a new simple type for restriction for built-in types
+    protected XSSimpleTypeDecl(XSSimpleTypeDecl base, String name, String uri, short finalSet, boolean isImmutable,
+            XSObjectList annotations, short builtInKind) {
+        this(base, name, uri, finalSet, isImmutable, annotations);
+        // Specify the build in kind for this built-in type
+        fBuiltInKind = builtInKind;
+    }
+
+    //Create a new simple type for restriction.
+    protected XSSimpleTypeDecl(XSSimpleTypeDecl base, String name, String uri, short finalSet, boolean isImmutable,
+            XSObjectList annotations) {
+        fBase = base;
+        fTypeName = name;
+        fTargetNamespace = uri;
+        fFinalSet = finalSet;
+        fAnnotations = annotations;
+
+        fVariety = fBase.fVariety;
+        fValidationDV = fBase.fValidationDV;
+        switch (fVariety) {
+            case VARIETY_ATOMIC:
+                break;
+            case VARIETY_LIST:
+                fItemType = fBase.fItemType;
+                break;
+            case VARIETY_UNION:
+                fMemberTypes = fBase.fMemberTypes;
+                break;
+        }
+
+        // always inherit facets from the base.
+        // in case a type is created, but applyFacets is not called
+        fLength = fBase.fLength;
+        fMinLength = fBase.fMinLength;
+        fMaxLength = fBase.fMaxLength;
+        fPattern = fBase.fPattern;
+        fPatternStr = fBase.fPatternStr;
+        fEnumeration = fBase.fEnumeration;
+        fEnumerationType = fBase.fEnumerationType;
         fEnumerationItemType = fBase.fEnumerationItemType;
-		fWhiteSpace = fBase.fWhiteSpace;
-		fMaxExclusive = fBase.fMaxExclusive;
-		fMaxInclusive = fBase.fMaxInclusive;
-		fMinExclusive = fBase.fMinExclusive;
-		fMinInclusive = fBase.fMinInclusive;
-		fTotalDigits = fBase.fTotalDigits;
-		fFractionDigits = fBase.fFractionDigits;
-		fPatternType = fBase.fPatternType;
-		fFixedFacet = fBase.fFixedFacet;
-		fFacetsDefined = fBase.fFacetsDefined;
-        
+        fWhiteSpace = fBase.fWhiteSpace;
+        fMaxExclusive = fBase.fMaxExclusive;
+        fMaxInclusive = fBase.fMaxInclusive;
+        fMinExclusive = fBase.fMinExclusive;
+        fMinInclusive = fBase.fMinInclusive;
+        fTotalDigits = fBase.fTotalDigits;
+        fFractionDigits = fBase.fFractionDigits;
+        fPatternType = fBase.fPatternType;
+        fFixedFacet = fBase.fFixedFacet;
+        fFacetsDefined = fBase.fFacetsDefined;
+
         // always inherit facet annotations in case applyFacets is not called.
         lengthAnnotation = fBase.lengthAnnotation;
         minLengthAnnotation = fBase.minLengthAnnotation;
@@ -390,922 +390,922 @@
         minInclusiveAnnotation = fBase.minInclusiveAnnotation;
         totalDigitsAnnotation = fBase.totalDigitsAnnotation;
         fractionDigitsAnnotation = fBase.fractionDigitsAnnotation;
-		
-		//we also set fundamental facets information in case applyFacets is not called.
-		calcFundamentalFacets();
-		fIsImmutable = isImmutable;
-		
-		// Inherit from the base type
-		fBuiltInKind = base.fBuiltInKind;
-	}
-	
-	//Create a new simple type for list.
-	protected XSSimpleTypeDecl(String name, String uri, short finalSet, XSSimpleTypeDecl itemType, boolean isImmutable,
-			XSObjectList annotations) {
-		fBase = fAnySimpleType;
-		fTypeName = name;
-		fTargetNamespace = uri;
-		fFinalSet = finalSet;
-		fAnnotations = annotations;
-		
-		fVariety = VARIETY_LIST;
-		fItemType = (XSSimpleTypeDecl)itemType;
-		fValidationDV = DV_LIST;
-		fFacetsDefined = FACET_WHITESPACE;
-		fFixedFacet = FACET_WHITESPACE;
-		fWhiteSpace = WS_COLLAPSE;
-		
-		//setting fundamental facets
-		calcFundamentalFacets();
-		fIsImmutable = isImmutable;
-		
-		// Values of this type are lists
-		fBuiltInKind = XSConstants.LIST_DT;
-	}
-	
-	//Create a new simple type for union.
-	protected XSSimpleTypeDecl(String name, String uri, short finalSet, XSSimpleTypeDecl[] memberTypes,
-			XSObjectList annotations) {
-		fBase = fAnySimpleType;
-		fTypeName = name;
-		fTargetNamespace = uri;
-		fFinalSet = finalSet;
-		fAnnotations = annotations;
-		
-		fVariety = VARIETY_UNION;
-		fMemberTypes = memberTypes;
-		fValidationDV = DV_UNION;
-		// even for union, we set whitespace to something
-		// this will never be used, but we can use fFacetsDefined to check
-		// whether applyFacets() is allwwed: it's not allowed
-		// if fFacetsDefined != 0
-		fFacetsDefined = FACET_WHITESPACE;
-		fWhiteSpace = WS_COLLAPSE;
-		
-		//setting fundamental facets
-		calcFundamentalFacets();
-		// none of the schema-defined types are unions, so just set
-		// fIsImmutable to false.
-		fIsImmutable = false;
-		
-		// No value can be of this type, so it's unavailable.
-		fBuiltInKind = XSConstants.UNAVAILABLE_DT;
-	}
-	
-	//set values for restriction.
-	protected XSSimpleTypeDecl setRestrictionValues(XSSimpleTypeDecl base, String name, String uri, short finalSet,
-			XSObjectList annotations) {
-		//decline to do anything if the object is immutable.
-		if(fIsImmutable) return null;
-		fBase = base;
-		fTypeName = name;
-		fTargetNamespace = uri;
-		fFinalSet = finalSet;
-		fAnnotations = annotations;
-		
-		fVariety = fBase.fVariety;
-		fValidationDV = fBase.fValidationDV;
-		switch (fVariety) {
-		case VARIETY_ATOMIC:
-			break;
-		case VARIETY_LIST:
-			fItemType = fBase.fItemType;
-			break;
-		case VARIETY_UNION:
-			fMemberTypes = fBase.fMemberTypes;
-			break;
-		}
-		
-		// always inherit facets from the base.
-		// in case a type is created, but applyFacets is not called
-		fLength = fBase.fLength;
-		fMinLength = fBase.fMinLength;
-		fMaxLength = fBase.fMaxLength;
-		fPattern = fBase.fPattern;
-		fPatternStr = fBase.fPatternStr;
-		fEnumeration = fBase.fEnumeration;
-		fEnumerationType = fBase.fEnumerationType;
+
+        //we also set fundamental facets information in case applyFacets is not called.
+        calcFundamentalFacets();
+        fIsImmutable = isImmutable;
+
+        // Inherit from the base type
+        fBuiltInKind = base.fBuiltInKind;
+    }
+
+    //Create a new simple type for list.
+    protected XSSimpleTypeDecl(String name, String uri, short finalSet, XSSimpleTypeDecl itemType, boolean isImmutable,
+            XSObjectList annotations) {
+        fBase = fAnySimpleType;
+        fTypeName = name;
+        fTargetNamespace = uri;
+        fFinalSet = finalSet;
+        fAnnotations = annotations;
+
+        fVariety = VARIETY_LIST;
+        fItemType = (XSSimpleTypeDecl)itemType;
+        fValidationDV = DV_LIST;
+        fFacetsDefined = FACET_WHITESPACE;
+        fFixedFacet = FACET_WHITESPACE;
+        fWhiteSpace = WS_COLLAPSE;
+
+        //setting fundamental facets
+        calcFundamentalFacets();
+        fIsImmutable = isImmutable;
+
+        // Values of this type are lists
+        fBuiltInKind = XSConstants.LIST_DT;
+    }
+
+    //Create a new simple type for union.
+    protected XSSimpleTypeDecl(String name, String uri, short finalSet, XSSimpleTypeDecl[] memberTypes,
+            XSObjectList annotations) {
+        fBase = fAnySimpleType;
+        fTypeName = name;
+        fTargetNamespace = uri;
+        fFinalSet = finalSet;
+        fAnnotations = annotations;
+
+        fVariety = VARIETY_UNION;
+        fMemberTypes = memberTypes;
+        fValidationDV = DV_UNION;
+        // even for union, we set whitespace to something
+        // this will never be used, but we can use fFacetsDefined to check
+        // whether applyFacets() is allwwed: it's not allowed
+        // if fFacetsDefined != 0
+        fFacetsDefined = FACET_WHITESPACE;
+        fWhiteSpace = WS_COLLAPSE;
+
+        //setting fundamental facets
+        calcFundamentalFacets();
+        // none of the schema-defined types are unions, so just set
+        // fIsImmutable to false.
+        fIsImmutable = false;
+
+        // No value can be of this type, so it's unavailable.
+        fBuiltInKind = XSConstants.UNAVAILABLE_DT;
+    }
+
+    //set values for restriction.
+    protected XSSimpleTypeDecl setRestrictionValues(XSSimpleTypeDecl base, String name, String uri, short finalSet,
+            XSObjectList annotations) {
+        //decline to do anything if the object is immutable.
+        if(fIsImmutable) return null;
+        fBase = base;
+        fTypeName = name;
+        fTargetNamespace = uri;
+        fFinalSet = finalSet;
+        fAnnotations = annotations;
+
+        fVariety = fBase.fVariety;
+        fValidationDV = fBase.fValidationDV;
+        switch (fVariety) {
+            case VARIETY_ATOMIC:
+                break;
+            case VARIETY_LIST:
+                fItemType = fBase.fItemType;
+                break;
+            case VARIETY_UNION:
+                fMemberTypes = fBase.fMemberTypes;
+                break;
+        }
+
+        // always inherit facets from the base.
+        // in case a type is created, but applyFacets is not called
+        fLength = fBase.fLength;
+        fMinLength = fBase.fMinLength;
+        fMaxLength = fBase.fMaxLength;
+        fPattern = fBase.fPattern;
+        fPatternStr = fBase.fPatternStr;
+        fEnumeration = fBase.fEnumeration;
+        fEnumerationType = fBase.fEnumerationType;
         fEnumerationItemType = fBase.fEnumerationItemType;
-		fWhiteSpace = fBase.fWhiteSpace;
-		fMaxExclusive = fBase.fMaxExclusive;
-		fMaxInclusive = fBase.fMaxInclusive;
-		fMinExclusive = fBase.fMinExclusive;
-		fMinInclusive = fBase.fMinInclusive;
-		fTotalDigits = fBase.fTotalDigits;
-		fFractionDigits = fBase.fFractionDigits;
-		fPatternType = fBase.fPatternType;
-		fFixedFacet = fBase.fFixedFacet;
-		fFacetsDefined = fBase.fFacetsDefined;
-		
-		//we also set fundamental facets information in case applyFacets is not called.
-		calcFundamentalFacets();
-        
+        fWhiteSpace = fBase.fWhiteSpace;
+        fMaxExclusive = fBase.fMaxExclusive;
+        fMaxInclusive = fBase.fMaxInclusive;
+        fMinExclusive = fBase.fMinExclusive;
+        fMinInclusive = fBase.fMinInclusive;
+        fTotalDigits = fBase.fTotalDigits;
+        fFractionDigits = fBase.fFractionDigits;
+        fPatternType = fBase.fPatternType;
+        fFixedFacet = fBase.fFixedFacet;
+        fFacetsDefined = fBase.fFacetsDefined;
+
+        //we also set fundamental facets information in case applyFacets is not called.
+        calcFundamentalFacets();
+
         // Inherit from the base type
         fBuiltInKind = base.fBuiltInKind;
-        
-		return this;
-	}
-	
-	//set values for list.
-	protected XSSimpleTypeDecl setListValues(String name, String uri, short finalSet, XSSimpleTypeDecl itemType,
-			XSObjectList annotations) {
-		//decline to do anything if the object is immutable.
-		if(fIsImmutable) return null;
-		fBase = fAnySimpleType;
-		fTypeName = name;
-		fTargetNamespace = uri;
-		fFinalSet = finalSet;
-		fAnnotations = annotations;
-		
-		fVariety = VARIETY_LIST;
-		fItemType = (XSSimpleTypeDecl)itemType;
-		fValidationDV = DV_LIST;
-		fFacetsDefined = FACET_WHITESPACE;
-		fFixedFacet = FACET_WHITESPACE;
-		fWhiteSpace = WS_COLLAPSE;
-		
-		//setting fundamental facets
-		calcFundamentalFacets();
-        
+
+        return this;
+    }
+
+    //set values for list.
+    protected XSSimpleTypeDecl setListValues(String name, String uri, short finalSet, XSSimpleTypeDecl itemType,
+            XSObjectList annotations) {
+        //decline to do anything if the object is immutable.
+        if(fIsImmutable) return null;
+        fBase = fAnySimpleType;
+        fTypeName = name;
+        fTargetNamespace = uri;
+        fFinalSet = finalSet;
+        fAnnotations = annotations;
+
+        fVariety = VARIETY_LIST;
+        fItemType = (XSSimpleTypeDecl)itemType;
+        fValidationDV = DV_LIST;
+        fFacetsDefined = FACET_WHITESPACE;
+        fFixedFacet = FACET_WHITESPACE;
+        fWhiteSpace = WS_COLLAPSE;
+
+        //setting fundamental facets
+        calcFundamentalFacets();
+
         // Values of this type are lists
         fBuiltInKind = XSConstants.LIST_DT;
-        
-		return this;
-	}
-	
-	//set values for union.
-	protected XSSimpleTypeDecl setUnionValues(String name, String uri, short finalSet, XSSimpleTypeDecl[] memberTypes,
-			XSObjectList annotations) {
-		//decline to do anything if the object is immutable.
-		if(fIsImmutable) return null;
-		fBase = fAnySimpleType;
-		fTypeName = name;
-		fTargetNamespace = uri;
-		fFinalSet = finalSet;
-		fAnnotations = annotations;
-		
-		fVariety = VARIETY_UNION;
-		fMemberTypes = memberTypes;
-		fValidationDV = DV_UNION;
-		// even for union, we set whitespace to something
-		// this will never be used, but we can use fFacetsDefined to check
-		// whether applyFacets() is allwwed: it's not allowed
-		// if fFacetsDefined != 0
-		fFacetsDefined = FACET_WHITESPACE;
-		fWhiteSpace = WS_COLLAPSE;
-		
-		//setting fundamental facets
-		calcFundamentalFacets();
-        
+
+        return this;
+    }
+
+    //set values for union.
+    protected XSSimpleTypeDecl setUnionValues(String name, String uri, short finalSet, XSSimpleTypeDecl[] memberTypes,
+            XSObjectList annotations) {
+        //decline to do anything if the object is immutable.
+        if(fIsImmutable) return null;
+        fBase = fAnySimpleType;
+        fTypeName = name;
+        fTargetNamespace = uri;
+        fFinalSet = finalSet;
+        fAnnotations = annotations;
+
+        fVariety = VARIETY_UNION;
+        fMemberTypes = memberTypes;
+        fValidationDV = DV_UNION;
+        // even for union, we set whitespace to something
+        // this will never be used, but we can use fFacetsDefined to check
+        // whether applyFacets() is allwwed: it's not allowed
+        // if fFacetsDefined != 0
+        fFacetsDefined = FACET_WHITESPACE;
+        fWhiteSpace = WS_COLLAPSE;
+
+        //setting fundamental facets
+        calcFundamentalFacets();
+
         // No value can be of this type, so it's unavailable.
         fBuiltInKind = XSConstants.UNAVAILABLE_DT;
-        
-		return this;
-	}
-	
-	public short getType () {
-		return XSConstants.TYPE_DEFINITION;
-	}
-	
-	public short getTypeCategory () {
-		return SIMPLE_TYPE;
-	}
-	
-	public String getName() {
-		return getAnonymous()?null:fTypeName;
-	}
-    
+
+        return this;
+    }
+
+    public short getType () {
+        return XSConstants.TYPE_DEFINITION;
+    }
+
+    public short getTypeCategory () {
+        return SIMPLE_TYPE;
+    }
+
+    public String getName() {
+        return getAnonymous()?null:fTypeName;
+    }
+
     public String getTypeName() {
         return fTypeName;
     }
-	
-	public String getNamespace() {
-		return fTargetNamespace;
-	}
-	
-	public short getFinal(){
-		return fFinalSet;
-	}
-	
-	public boolean isFinal(short derivation) {
-		return (fFinalSet & derivation) != 0;
-	}
-	
-	public XSTypeDefinition getBaseType(){
-		return fBase;
-	}
-	
-	public boolean getAnonymous() {
-		return fAnonymous || (fTypeName == null);
-	}
-	
-	public short getVariety(){
-		// for anySimpleType, return absent variaty
-		return fValidationDV == DV_ANYSIMPLETYPE ? VARIETY_ABSENT : fVariety;
-	}
-	
-	public boolean isIDType(){
-		switch (fVariety) {
-		case VARIETY_ATOMIC:
-			return fValidationDV == DV_ID;
-		case VARIETY_LIST:
-			return fItemType.isIDType();
-		case VARIETY_UNION:
-			for (int i = 0; i < fMemberTypes.length; i++) {
-				if (fMemberTypes[i].isIDType())
-					return true;
-			}
-		}
-		return false;
-	}
-	
-	public short getWhitespace() throws DatatypeException{
-		if (fVariety == VARIETY_UNION) {
-			throw new DatatypeException("dt-whitespace", new Object[]{fTypeName});
-		}
-		return fWhiteSpace;
-	}
-	
-	public short getPrimitiveKind() {
-		if (fVariety == VARIETY_ATOMIC && fValidationDV != DV_ANYSIMPLETYPE) {
-			if (fValidationDV == DV_ID || fValidationDV == DV_IDREF || fValidationDV == DV_ENTITY) {
-				return DV_STRING;
-			}
-			else if (fValidationDV == DV_INTEGER) {
-				return DV_DECIMAL;
-			}
-			else if (Constants.SCHEMA_1_1_SUPPORT && (fValidationDV == DV_YEARMONTHDURATION || fValidationDV == DV_DAYTIMEDURATION)) {
-				return DV_DURATION;
-			}
-			else {
-				return fValidationDV;
-			}
-		}
-		else {
-			// REVISIT: error situation. runtime exception?
-			return (short)0;
-		}
-	}
-	
-	/**
-	 * Returns the closest built-in type category this type represents or
-	 * derived from. For example, if this simple type is a built-in derived
-	 * type integer the <code>INTEGER_DV</code> is returned.
-	 */
-	public short getBuiltInKind() {
-		return this.fBuiltInKind;
-	}
-	
-	/**
-	 * If variety is <code>atomic</code> the primitive type definition (a
-	 * built-in primitive datatype definition or the simple ur-type
-	 * definition) is available, otherwise <code>null</code>.
-	 */
-	public XSSimpleTypeDefinition getPrimitiveType() {
-		if (fVariety == VARIETY_ATOMIC && fValidationDV != DV_ANYSIMPLETYPE) {
-			XSSimpleTypeDecl pri = this;
-			// recursively get base, until we reach anySimpleType
-			while (pri.fBase != fAnySimpleType)
-				pri = pri.fBase;
-			return pri;
-		}
-		else {
-			// REVISIT: error situation. runtime exception?
-			return null;
-		}
-	}
-	
-	/**
-	 * If variety is <code>list</code> the item type definition (an atomic or
-	 * union simple type definition) is available, otherwise
-	 * <code>null</code>.
-	 */
-	public XSSimpleTypeDefinition getItemType() {
-		if (fVariety == VARIETY_LIST) {
-			return fItemType;
-		}
-		else {
-			// REVISIT: error situation. runtime exception?
-			return null;
-		}
-	}
-	
-	/**
-	 * If variety is <code>union</code> the list of member type definitions (a
-	 * non-empty sequence of simple type definitions) is available,
-	 * otherwise an empty <code>XSObjectList</code>.
-	 */
-	public XSObjectList getMemberTypes() {
-		if (fVariety == VARIETY_UNION) {
-			return new XSObjectListImpl(fMemberTypes, fMemberTypes.length);
-		}
-		else {
-			return XSObjectListImpl.EMPTY_LIST;
-		}
-	}
-	
-	/**
-	 * If <restriction> is chosen
-	 */
-	public void applyFacets(XSFacets facets, short presentFacet, short fixedFacet, ValidationContext context)
-	throws InvalidDatatypeFacetException {
-		applyFacets(facets, presentFacet, fixedFacet, SPECIAL_PATTERN_NONE, context);
-	}
-	
-	/**
-	 * built-in derived types by restriction
-	 */
-	void applyFacets1(XSFacets facets, short presentFacet, short fixedFacet) {
-		
-		try {
-			applyFacets(facets, presentFacet, fixedFacet, SPECIAL_PATTERN_NONE, fDummyContext);
-		} catch (InvalidDatatypeFacetException e) {
-			// should never gets here, internel error
-			throw new RuntimeException("internal error");
-		}
-		// we've now applied facets; so lock this object:
-		fIsImmutable = true;
-	}
-	
-	/**
-	 * built-in derived types by restriction
-	 */
-	void applyFacets1(XSFacets facets, short presentFacet, short fixedFacet, short patternType) {
-		
-		try {
-			applyFacets(facets, presentFacet, fixedFacet, patternType, fDummyContext);
-		} catch (InvalidDatatypeFacetException e) {
-			// should never gets here, internel error
-			throw new RuntimeException("internal error");
-		}
-		// we've now applied facets; so lock this object:
-		fIsImmutable = true;
-	}
-	
-	/**
-	 * If <restriction> is chosen, or built-in derived types by restriction
-	 */
-	void applyFacets(XSFacets facets, short presentFacet, short fixedFacet, short patternType, ValidationContext context)
-	throws InvalidDatatypeFacetException {
-		
-		// if the object is immutable, should not apply facets...
-		if(fIsImmutable) return;
-		ValidatedInfo tempInfo = new ValidatedInfo();
-		
-		// clear facets. because we always inherit facets in the constructor
-		// REVISIT: in fact, we don't need to clear them.
-		// we can convert 5 string values (4 bounds + 1 enum) to actual values,
-		// store them somewhere, then do facet checking at once, instead of
-		// going through the following steps. (lots of checking are redundant:
-		// for example, ((presentFacet & FACET_XXX) != 0))
-		
-		fFacetsDefined = 0;
-		fFixedFacet = 0;
-		
-		int result = 0 ;
-		
-		// step 1: parse present facets
-		short allowedFacet = fDVs[fValidationDV].getAllowedFacets();
-		
-		// length
-		if ((presentFacet & FACET_LENGTH) != 0) {
-			if ((allowedFacet & FACET_LENGTH) == 0) {
-				reportError("cos-applicable-facets", new Object[]{"length", fTypeName});
-			} else {
-				fLength = facets.length;
-				lengthAnnotation = facets.lengthAnnotation;
-				fFacetsDefined |= FACET_LENGTH;
-				if ((fixedFacet & FACET_LENGTH) != 0)
-					fFixedFacet |= FACET_LENGTH;
-			}
-		}
-		// minLength
-		if ((presentFacet & FACET_MINLENGTH) != 0) {
-			if ((allowedFacet & FACET_MINLENGTH) == 0) {
-				reportError("cos-applicable-facets", new Object[]{"minLength", fTypeName});
-			} else {
-				fMinLength = facets.minLength;
-				minLengthAnnotation = facets.minLengthAnnotation;
-				fFacetsDefined |= FACET_MINLENGTH;
-				if ((fixedFacet & FACET_MINLENGTH) != 0)
-					fFixedFacet |= FACET_MINLENGTH;
-			}
-		}
-		// maxLength
-		if ((presentFacet & FACET_MAXLENGTH) != 0) {
-			if ((allowedFacet & FACET_MAXLENGTH) == 0) {
-				reportError("cos-applicable-facets", new Object[]{"maxLength", fTypeName});
-			} else {
-				fMaxLength = facets.maxLength;
-				maxLengthAnnotation = facets.maxLengthAnnotation;
-				fFacetsDefined |= FACET_MAXLENGTH;
-				if ((fixedFacet & FACET_MAXLENGTH) != 0)
-					fFixedFacet |= FACET_MAXLENGTH;
-			}
-		}
-		// pattern
-		if ((presentFacet & FACET_PATTERN) != 0) {
-			if ((allowedFacet & FACET_PATTERN) == 0) {
-				reportError("cos-applicable-facets", new Object[]{"pattern", fTypeName});
-			} else {
-				patternAnnotations = facets.patternAnnotations;
-				RegularExpression regex = null;
-				try {
-					regex = new RegularExpression(facets.pattern, "X");
-				} catch (Exception e) {
-					reportError("InvalidRegex", new Object[]{facets.pattern, e.getLocalizedMessage()});
-				}
-				if (regex != null) {
-					fPattern = new Vector();
-					fPattern.addElement(regex);
-					fPatternStr = new Vector();
-					fPatternStr.addElement(facets.pattern);
-					fFacetsDefined |= FACET_PATTERN;
-					if ((fixedFacet & FACET_PATTERN) != 0)
-						fFixedFacet |= FACET_PATTERN;
-				}
-			}
-		}
-		
-		// enumeration
-		if ((presentFacet & FACET_ENUMERATION) != 0) {
-			if ((allowedFacet & FACET_ENUMERATION) == 0) {
-				reportError("cos-applicable-facets", new Object[]{"enumeration", fTypeName});
-			} else {
-				fEnumeration = new Vector();
-				Vector enumVals = facets.enumeration;
-				fEnumerationType = new short[enumVals.size()];
+
+    public String getNamespace() {
+        return fTargetNamespace;
+    }
+
+    public short getFinal(){
+        return fFinalSet;
+    }
+
+    public boolean isFinal(short derivation) {
+        return (fFinalSet & derivation) != 0;
+    }
+
+    public XSTypeDefinition getBaseType(){
+        return fBase;
+    }
+
+    public boolean getAnonymous() {
+        return fAnonymous || (fTypeName == null);
+    }
+
+    public short getVariety(){
+        // for anySimpleType, return absent variaty
+        return fValidationDV == DV_ANYSIMPLETYPE ? VARIETY_ABSENT : fVariety;
+    }
+
+    public boolean isIDType(){
+        switch (fVariety) {
+            case VARIETY_ATOMIC:
+                return fValidationDV == DV_ID;
+            case VARIETY_LIST:
+                return fItemType.isIDType();
+            case VARIETY_UNION:
+                for (int i = 0; i < fMemberTypes.length; i++) {
+                    if (fMemberTypes[i].isIDType())
+                        return true;
+                }
+        }
+        return false;
+    }
+
+    public short getWhitespace() throws DatatypeException{
+        if (fVariety == VARIETY_UNION) {
+            throw new DatatypeException("dt-whitespace", new Object[]{fTypeName});
+        }
+        return fWhiteSpace;
+    }
+
+    public short getPrimitiveKind() {
+        if (fVariety == VARIETY_ATOMIC && fValidationDV != DV_ANYSIMPLETYPE) {
+            if (fValidationDV == DV_ID || fValidationDV == DV_IDREF || fValidationDV == DV_ENTITY) {
+                return DV_STRING;
+            }
+            else if (fValidationDV == DV_INTEGER) {
+                return DV_DECIMAL;
+            }
+            else if (Constants.SCHEMA_1_1_SUPPORT && (fValidationDV == DV_YEARMONTHDURATION || fValidationDV == DV_DAYTIMEDURATION)) {
+                return DV_DURATION;
+            }
+            else {
+                return fValidationDV;
+            }
+        }
+        else {
+            // REVISIT: error situation. runtime exception?
+            return (short)0;
+        }
+    }
+
+    /**
+     * Returns the closest built-in type category this type represents or
+     * derived from. For example, if this simple type is a built-in derived
+     * type integer the <code>INTEGER_DV</code> is returned.
+     */
+    public short getBuiltInKind() {
+        return this.fBuiltInKind;
+    }
+
+    /**
+     * If variety is <code>atomic</code> the primitive type definition (a
+     * built-in primitive datatype definition or the simple ur-type
+     * definition) is available, otherwise <code>null</code>.
+     */
+    public XSSimpleTypeDefinition getPrimitiveType() {
+        if (fVariety == VARIETY_ATOMIC && fValidationDV != DV_ANYSIMPLETYPE) {
+            XSSimpleTypeDecl pri = this;
+            // recursively get base, until we reach anySimpleType
+            while (pri.fBase != fAnySimpleType)
+                pri = pri.fBase;
+            return pri;
+        }
+        else {
+            // REVISIT: error situation. runtime exception?
+            return null;
+        }
+    }
+
+    /**
+     * If variety is <code>list</code> the item type definition (an atomic or
+     * union simple type definition) is available, otherwise
+     * <code>null</code>.
+     */
+    public XSSimpleTypeDefinition getItemType() {
+        if (fVariety == VARIETY_LIST) {
+            return fItemType;
+        }
+        else {
+            // REVISIT: error situation. runtime exception?
+            return null;
+        }
+    }
+
+    /**
+     * If variety is <code>union</code> the list of member type definitions (a
+     * non-empty sequence of simple type definitions) is available,
+     * otherwise an empty <code>XSObjectList</code>.
+     */
+    public XSObjectList getMemberTypes() {
+        if (fVariety == VARIETY_UNION) {
+            return new XSObjectListImpl(fMemberTypes, fMemberTypes.length);
+        }
+        else {
+            return XSObjectListImpl.EMPTY_LIST;
+        }
+    }
+
+    /**
+     * If <restriction> is chosen
+     */
+    public void applyFacets(XSFacets facets, short presentFacet, short fixedFacet, ValidationContext context)
+    throws InvalidDatatypeFacetException {
+        applyFacets(facets, presentFacet, fixedFacet, SPECIAL_PATTERN_NONE, context);
+    }
+
+    /**
+     * built-in derived types by restriction
+     */
+    void applyFacets1(XSFacets facets, short presentFacet, short fixedFacet) {
+
+        try {
+            applyFacets(facets, presentFacet, fixedFacet, SPECIAL_PATTERN_NONE, fDummyContext);
+        } catch (InvalidDatatypeFacetException e) {
+            // should never gets here, internel error
+            throw new RuntimeException("internal error");
+        }
+        // we've now applied facets; so lock this object:
+        fIsImmutable = true;
+    }
+
+    /**
+     * built-in derived types by restriction
+     */
+    void applyFacets1(XSFacets facets, short presentFacet, short fixedFacet, short patternType) {
+
+        try {
+            applyFacets(facets, presentFacet, fixedFacet, patternType, fDummyContext);
+        } catch (InvalidDatatypeFacetException e) {
+            // should never gets here, internel error
+            throw new RuntimeException("internal error");
+        }
+        // we've now applied facets; so lock this object:
+        fIsImmutable = true;
+    }
+
+    /**
+     * If <restriction> is chosen, or built-in derived types by restriction
+     */
+    void applyFacets(XSFacets facets, short presentFacet, short fixedFacet, short patternType, ValidationContext context)
+    throws InvalidDatatypeFacetException {
+
+        // if the object is immutable, should not apply facets...
+        if(fIsImmutable) return;
+        ValidatedInfo tempInfo = new ValidatedInfo();
+
+        // clear facets. because we always inherit facets in the constructor
+        // REVISIT: in fact, we don't need to clear them.
+        // we can convert 5 string values (4 bounds + 1 enum) to actual values,
+        // store them somewhere, then do facet checking at once, instead of
+        // going through the following steps. (lots of checking are redundant:
+        // for example, ((presentFacet & FACET_XXX) != 0))
+
+        fFacetsDefined = 0;
+        fFixedFacet = 0;
+
+        int result = 0 ;
+
+        // step 1: parse present facets
+        short allowedFacet = fDVs[fValidationDV].getAllowedFacets();
+
+        // length
+        if ((presentFacet & FACET_LENGTH) != 0) {
+            if ((allowedFacet & FACET_LENGTH) == 0) {
+                reportError("cos-applicable-facets", new Object[]{"length", fTypeName});
+            } else {
+                fLength = facets.length;
+                lengthAnnotation = facets.lengthAnnotation;
+                fFacetsDefined |= FACET_LENGTH;
+                if ((fixedFacet & FACET_LENGTH) != 0)
+                    fFixedFacet |= FACET_LENGTH;
+            }
+        }
+        // minLength
+        if ((presentFacet & FACET_MINLENGTH) != 0) {
+            if ((allowedFacet & FACET_MINLENGTH) == 0) {
+                reportError("cos-applicable-facets", new Object[]{"minLength", fTypeName});
+            } else {
+                fMinLength = facets.minLength;
+                minLengthAnnotation = facets.minLengthAnnotation;
+                fFacetsDefined |= FACET_MINLENGTH;
+                if ((fixedFacet & FACET_MINLENGTH) != 0)
+                    fFixedFacet |= FACET_MINLENGTH;
+            }
+        }
+        // maxLength
+        if ((presentFacet & FACET_MAXLENGTH) != 0) {
+            if ((allowedFacet & FACET_MAXLENGTH) == 0) {
+                reportError("cos-applicable-facets", new Object[]{"maxLength", fTypeName});
+            } else {
+                fMaxLength = facets.maxLength;
+                maxLengthAnnotation = facets.maxLengthAnnotation;
+                fFacetsDefined |= FACET_MAXLENGTH;
+                if ((fixedFacet & FACET_MAXLENGTH) != 0)
+                    fFixedFacet |= FACET_MAXLENGTH;
+            }
+        }
+        // pattern
+        if ((presentFacet & FACET_PATTERN) != 0) {
+            if ((allowedFacet & FACET_PATTERN) == 0) {
+                reportError("cos-applicable-facets", new Object[]{"pattern", fTypeName});
+            } else {
+                patternAnnotations = facets.patternAnnotations;
+                RegularExpression regex = null;
+                try {
+                    regex = new RegularExpression(facets.pattern, "X");
+                } catch (Exception e) {
+                    reportError("InvalidRegex", new Object[]{facets.pattern, e.getLocalizedMessage()});
+                }
+                if (regex != null) {
+                    fPattern = new Vector();
+                    fPattern.addElement(regex);
+                    fPatternStr = new Vector();
+                    fPatternStr.addElement(facets.pattern);
+                    fFacetsDefined |= FACET_PATTERN;
+                    if ((fixedFacet & FACET_PATTERN) != 0)
+                        fFixedFacet |= FACET_PATTERN;
+                }
+            }
+        }
+
+        // enumeration
+        if ((presentFacet & FACET_ENUMERATION) != 0) {
+            if ((allowedFacet & FACET_ENUMERATION) == 0) {
+                reportError("cos-applicable-facets", new Object[]{"enumeration", fTypeName});
+            } else {
+                fEnumeration = new Vector();
+                Vector enumVals = facets.enumeration;
+                fEnumerationType = new short[enumVals.size()];
                 fEnumerationItemType = new ShortList[enumVals.size()];
-				Vector enumNSDecls = facets.enumNSDecls;
-				ValidationContextImpl ctx = new ValidationContextImpl(context);
-				enumerationAnnotations = facets.enumAnnotations;
-				for (int i = 0; i < enumVals.size(); i++) {
-					if (enumNSDecls != null)
-						ctx.setNSContext((NamespaceContext)enumNSDecls.elementAt(i));
-					try {
-						ValidatedInfo info = this.fBase.validateWithInfo((String)enumVals.elementAt(i), ctx, tempInfo);
-						// check 4.3.5.c0 must: enumeration values from the value space of base
-						fEnumeration.addElement(info.actualValue);
-						fEnumerationType[i] = info.actualValueType;
+                Vector enumNSDecls = facets.enumNSDecls;
+                ValidationContextImpl ctx = new ValidationContextImpl(context);
+                enumerationAnnotations = facets.enumAnnotations;
+                for (int i = 0; i < enumVals.size(); i++) {
+                    if (enumNSDecls != null)
+                        ctx.setNSContext((NamespaceContext)enumNSDecls.elementAt(i));
+                    try {
+                        ValidatedInfo info = this.fBase.validateWithInfo((String)enumVals.elementAt(i), ctx, tempInfo);
+                        // check 4.3.5.c0 must: enumeration values from the value space of base
+                        fEnumeration.addElement(info.actualValue);
+                        fEnumerationType[i] = info.actualValueType;
                         fEnumerationItemType[i] = info.itemValueTypes;
-					} catch (InvalidDatatypeValueException ide) {
-						reportError("enumeration-valid-restriction", new Object[]{enumVals.elementAt(i), this.getBaseType().getName()});
-					}
-				}
-				fFacetsDefined |= FACET_ENUMERATION;
-				if ((fixedFacet & FACET_ENUMERATION) != 0)
-					fFixedFacet |= FACET_ENUMERATION;
-			}
-		}
-		// whiteSpace
-		if ((presentFacet & FACET_WHITESPACE) != 0) {
-			if ((allowedFacet & FACET_WHITESPACE) == 0) {
-				reportError("cos-applicable-facets", new Object[]{"whiteSpace", fTypeName});
-			} else {
-				fWhiteSpace = facets.whiteSpace;
-				whiteSpaceAnnotation = facets.whiteSpaceAnnotation;
-				fFacetsDefined |= FACET_WHITESPACE;
-				if ((fixedFacet & FACET_WHITESPACE) != 0)
-					fFixedFacet |= FACET_WHITESPACE;
-			}
-		}
-		
-		// maxInclusive
-		if ((presentFacet & FACET_MAXINCLUSIVE) != 0) {
-			if ((allowedFacet & FACET_MAXINCLUSIVE) == 0) {
-				reportError("cos-applicable-facets", new Object[]{"maxInclusive", fTypeName});
-			} else {
-				maxInclusiveAnnotation = facets.maxInclusiveAnnotation;
-				try {
-					fMaxInclusive = fBase.getActualValue(facets.maxInclusive, context, tempInfo, true);
-					fFacetsDefined |= FACET_MAXINCLUSIVE;
-					if ((fixedFacet & FACET_MAXINCLUSIVE) != 0)
-						fFixedFacet |= FACET_MAXINCLUSIVE;
-				} catch (InvalidDatatypeValueException ide) {
-					reportError(ide.getKey(), ide.getArgs());
-					reportError("FacetValueFromBase", new Object[]{fTypeName, facets.maxInclusive,
-							"maxInclusive", fBase.getName()});
-				}
-				
-				// check against fixed value in base
-				if (((fBase.fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
-					if ((fBase.fFixedFacet & FACET_MAXINCLUSIVE) != 0) {
-						if (fDVs[fValidationDV].compare(fMaxInclusive, fBase.fMaxInclusive) != 0)
-							reportError( "FixedFacetValue", new Object[]{"maxInclusive", fMaxInclusive, fBase.fMaxInclusive, fTypeName});
-					}
-				}
-				// maxInclusive from base
-				try {
-					fBase.validate(context, tempInfo);
-				} catch (InvalidDatatypeValueException ide) {
-					reportError(ide.getKey(), ide.getArgs());
-					reportError("FacetValueFromBase", new Object[]{fTypeName, facets.maxInclusive,
-							"maxInclusive", fBase.getName()});
-				}
-			}
-		}
-		
-		// maxExclusive
-		boolean needCheckBase = true;
-		if ((presentFacet & FACET_MAXEXCLUSIVE) != 0) {
-			if ((allowedFacet & FACET_MAXEXCLUSIVE) == 0) {
-				reportError("cos-applicable-facets", new Object[]{"maxExclusive", fTypeName});
-			} else {
-				maxExclusiveAnnotation = facets.maxExclusiveAnnotation;
-				try {
-					fMaxExclusive = fBase.getActualValue(facets.maxExclusive, context, tempInfo, true);
-					fFacetsDefined |= FACET_MAXEXCLUSIVE;
-					if ((fixedFacet & FACET_MAXEXCLUSIVE) != 0)
-						fFixedFacet |= FACET_MAXEXCLUSIVE;
-				} catch (InvalidDatatypeValueException ide) {
-					reportError(ide.getKey(), ide.getArgs());
-					reportError("FacetValueFromBase", new Object[]{fTypeName, facets.maxExclusive,
-							"maxExclusive", fBase.getName()});
-				}
-				
-				// check against fixed value in base
-				if (((fBase.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0)) {
-					result = fDVs[fValidationDV].compare(fMaxExclusive, fBase.fMaxExclusive);
-					if ((fBase.fFixedFacet & FACET_MAXEXCLUSIVE) != 0 && result != 0) {
-						reportError( "FixedFacetValue", new Object[]{"maxExclusive", facets.maxExclusive, fBase.fMaxExclusive, fTypeName});
-					}
-					if (result == 0) {
-						needCheckBase = false;
-					}
-				}
-				// maxExclusive from base
-				if (needCheckBase) {
-					try {
-						fBase.validate(context, tempInfo);
-					} catch (InvalidDatatypeValueException ide) {
-						reportError(ide.getKey(), ide.getArgs());
-						reportError("FacetValueFromBase", new Object[]{fTypeName, facets.maxExclusive,
-								"maxExclusive", fBase.getName()});
-					}
-				}
-				// If maxExclusive == base.maxExclusive, then we only need to check
-				// maxExclusive <= base.maxInclusive
-				else if (((fBase.fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
-					if (fDVs[fValidationDV].compare(fMaxExclusive, fBase.fMaxInclusive) > 0) {
-						reportError( "maxExclusive-valid-restriction.2", new Object[]{facets.maxExclusive, fBase.fMaxInclusive});
-					}
-				}
-			}
-		}
-		// minExclusive
-		needCheckBase = true;
-		if ((presentFacet & FACET_MINEXCLUSIVE) != 0) {
-			if ((allowedFacet & FACET_MINEXCLUSIVE) == 0) {
-				reportError("cos-applicable-facets", new Object[]{"minExclusive", fTypeName});
-			} else {
-				minExclusiveAnnotation = facets.minExclusiveAnnotation;
-				try {
-					fMinExclusive = fBase.getActualValue(facets.minExclusive, context, tempInfo, true);
-					fFacetsDefined |= FACET_MINEXCLUSIVE;
-					if ((fixedFacet & FACET_MINEXCLUSIVE) != 0)
-						fFixedFacet |= FACET_MINEXCLUSIVE;
-				} catch (InvalidDatatypeValueException ide) {
-					reportError(ide.getKey(), ide.getArgs());
-					reportError("FacetValueFromBase", new Object[]{fTypeName, facets.minExclusive,
-							"minExclusive", fBase.getName()});
-				}
-				
-				// check against fixed value in base
-				if (((fBase.fFacetsDefined & FACET_MINEXCLUSIVE) != 0)) {
-					result = fDVs[fValidationDV].compare(fMinExclusive, fBase.fMinExclusive);
-					if ((fBase.fFixedFacet & FACET_MINEXCLUSIVE) != 0 && result != 0) {
-						reportError( "FixedFacetValue", new Object[]{"minExclusive", facets.minExclusive, fBase.fMinExclusive, fTypeName});
-					}
-					if (result == 0) {
-						needCheckBase = false;
-					}
-				}
-				// minExclusive from base
-				if (needCheckBase) {
-					try {
-						fBase.validate(context, tempInfo);
-					} catch (InvalidDatatypeValueException ide) {
-						reportError(ide.getKey(), ide.getArgs());
-						reportError("FacetValueFromBase", new Object[]{fTypeName, facets.minExclusive,
-								"minExclusive", fBase.getName()});
-					}
-				}
-				// If minExclusive == base.minExclusive, then we only need to check
-				// minExclusive >= base.minInclusive
-				else if (((fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
-					if (fDVs[fValidationDV].compare(fMinExclusive, fBase.fMinInclusive) < 0) {
-						reportError( "minExclusive-valid-restriction.3", new Object[]{facets.minExclusive, fBase.fMinInclusive});
-					}
-				}
-			}
-		}
-		// minInclusive
-		if ((presentFacet & FACET_MININCLUSIVE) != 0) {
-			if ((allowedFacet & FACET_MININCLUSIVE) == 0) {
-				reportError("cos-applicable-facets", new Object[]{"minInclusive", fTypeName});
-			} else {
-				minInclusiveAnnotation = facets.minInclusiveAnnotation;
-				try {
-					fMinInclusive = fBase.getActualValue(facets.minInclusive, context, tempInfo, true);
-					fFacetsDefined |= FACET_MININCLUSIVE;
-					if ((fixedFacet & FACET_MININCLUSIVE) != 0)
-						fFixedFacet |= FACET_MININCLUSIVE;
-				} catch (InvalidDatatypeValueException ide) {
-					reportError(ide.getKey(), ide.getArgs());
-					reportError("FacetValueFromBase", new Object[]{fTypeName, facets.minInclusive,
-							"minInclusive", fBase.getName()});
-				}
-				
-				// check against fixed value in base
-				if (((fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
-					if ((fBase.fFixedFacet & FACET_MININCLUSIVE) != 0) {
-						if (fDVs[fValidationDV].compare(fMinInclusive, fBase.fMinInclusive) != 0)
-							reportError( "FixedFacetValue", new Object[]{"minInclusive", facets.minInclusive, fBase.fMinInclusive, fTypeName});
-					}
-				}
-				// minInclusive from base
-				try {
-					fBase.validate(context, tempInfo);
-				} catch (InvalidDatatypeValueException ide) {
-					reportError(ide.getKey(), ide.getArgs());
-					reportError("FacetValueFromBase", new Object[]{fTypeName, facets.minInclusive,
-							"minInclusive", fBase.getName()});
-				}
-			}
-		}
-		
-		// totalDigits
-		if ((presentFacet & FACET_TOTALDIGITS) != 0) {
-			if ((allowedFacet & FACET_TOTALDIGITS) == 0) {
-				reportError("cos-applicable-facets", new Object[]{"totalDigits", fTypeName});
-			} else {
-				totalDigitsAnnotation = facets.totalDigitsAnnotation;
-				fTotalDigits = facets.totalDigits;
-				fFacetsDefined |= FACET_TOTALDIGITS;
-				if ((fixedFacet & FACET_TOTALDIGITS) != 0)
-					fFixedFacet |= FACET_TOTALDIGITS;
-			}
-		}
-		// fractionDigits
-		if ((presentFacet & FACET_FRACTIONDIGITS) != 0) {
-			if ((allowedFacet & FACET_FRACTIONDIGITS) == 0) {
-				reportError("cos-applicable-facets", new Object[]{"fractionDigits", fTypeName});
-			} else {
-				fFractionDigits = facets.fractionDigits;
-				fractionDigitsAnnotation = facets.fractionDigitsAnnotation;
-				fFacetsDefined |= FACET_FRACTIONDIGITS;
-				if ((fixedFacet & FACET_FRACTIONDIGITS) != 0)
-					fFixedFacet |= FACET_FRACTIONDIGITS;
-			}
-		}
-		
-		// token type: internal use, so do less checking
-		if (patternType != SPECIAL_PATTERN_NONE) {
-			fPatternType = patternType;
-		}
-		
-		// step 2: check facets against each other: length, bounds
-		if(fFacetsDefined != 0) {
-			
-			// check 4.3.2.c1 must: minLength <= maxLength
-			if(((fFacetsDefined & FACET_MINLENGTH ) != 0 ) && ((fFacetsDefined & FACET_MAXLENGTH) != 0))
-			{
-				if(fMinLength > fMaxLength)
-					reportError("minLength-less-than-equal-to-maxLength", new Object[]{Integer.toString(fMinLength), Integer.toString(fMaxLength), fTypeName});
-			}
-			
-			// check 4.3.8.c1 error: maxInclusive + maxExclusive
-			if (((fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) && ((fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
-				reportError( "maxInclusive-maxExclusive", new Object[]{fMaxInclusive, fMaxExclusive, fTypeName});
-			}
-			
-			// check 4.3.9.c1 error: minInclusive + minExclusive
-			if (((fFacetsDefined & FACET_MINEXCLUSIVE) != 0) && ((fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
-				reportError("minInclusive-minExclusive", new Object[]{fMinInclusive, fMinExclusive, fTypeName});
-			}
-			
-			// check 4.3.7.c1 must: minInclusive <= maxInclusive
-			if (((fFacetsDefined &  FACET_MAXINCLUSIVE) != 0) && ((fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
-				result = fDVs[fValidationDV].compare(fMinInclusive, fMaxInclusive);
-				if (result != -1 && result != 0)
-					reportError("minInclusive-less-than-equal-to-maxInclusive", new Object[]{fMinInclusive, fMaxInclusive, fTypeName});
-			}
-			
-			// check 4.3.8.c2 must: minExclusive <= maxExclusive ??? minExclusive < maxExclusive
-			if (((fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) && ((fFacetsDefined & FACET_MINEXCLUSIVE) != 0)) {
-				result = fDVs[fValidationDV].compare(fMinExclusive, fMaxExclusive);
-				if (result != -1 && result != 0)
-					reportError( "minExclusive-less-than-equal-to-maxExclusive", new Object[]{fMinExclusive, fMaxExclusive, fTypeName});
-			}
-			
-			// check 4.3.9.c2 must: minExclusive < maxInclusive
-			if (((fFacetsDefined & FACET_MAXINCLUSIVE) != 0) && ((fFacetsDefined & FACET_MINEXCLUSIVE) != 0)) {
-				if (fDVs[fValidationDV].compare(fMinExclusive, fMaxInclusive) != -1)
-					reportError( "minExclusive-less-than-maxInclusive", new Object[]{fMinExclusive, fMaxInclusive, fTypeName});
-			}
-			
-			// check 4.3.10.c1 must: minInclusive < maxExclusive
-			if (((fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) && ((fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
-				if (fDVs[fValidationDV].compare(fMinInclusive, fMaxExclusive) != -1)
-					reportError( "minInclusive-less-than-maxExclusive", new Object[]{fMinInclusive, fMaxExclusive, fTypeName});
-			}
-			
-			// check 4.3.12.c1 must: fractionDigits <= totalDigits
-			if (((fFacetsDefined & FACET_FRACTIONDIGITS) != 0) &&
-					((fFacetsDefined & FACET_TOTALDIGITS) != 0)) {
-				if (fFractionDigits > fTotalDigits)
-					reportError( "fractionDigits-totalDigits", new Object[]{Integer.toString(fFractionDigits), Integer.toString(fTotalDigits), fTypeName});
-			}
-			
-			// step 3: check facets against base
-			// check 4.3.1.c1 error: length & (fBase.maxLength | fBase.minLength)
-			if((fFacetsDefined & FACET_LENGTH) != 0 ){
-				if ((fBase.fFacetsDefined & FACET_MINLENGTH) != 0 &&
-						fLength < fBase.fMinLength) {
-					// length, fBase.minLength and fBase.maxLength defined
-					reportError("length-minLength-maxLength.1.1", new Object[]{fTypeName, Integer.toString(fLength), Integer.toString(fBase.fMinLength)});
-				}
-				if ((fBase.fFacetsDefined & FACET_MAXLENGTH) != 0 &&
-						fLength > fBase.fMaxLength) {
-					// length and fBase.maxLength defined
-					reportError("length-minLength-maxLength.2.1", new Object[]{fTypeName, Integer.toString(fLength), Integer.toString(fBase.fMaxLength)});
-				}
-				if ( (fBase.fFacetsDefined & FACET_LENGTH) != 0 ) {
-					// check 4.3.1.c2 error: length != fBase.length
-					if ( fLength != fBase.fLength )
-						reportError( "length-valid-restriction", new Object[]{Integer.toString(fLength), Integer.toString(fBase.fLength), fTypeName});
-				}
-			}
-			
-			// check 4.3.1.c1 error: fBase.length & (maxLength | minLength)
-			if((fBase.fFacetsDefined & FACET_LENGTH) != 0 || (fFacetsDefined & FACET_LENGTH) != 0){
-				if ((fFacetsDefined & FACET_MINLENGTH) != 0){
-					if (fBase.fLength < fMinLength) {
-						// fBase.length, minLength and maxLength defined
-						reportError("length-minLength-maxLength.1.1", new Object[]{fTypeName, Integer.toString(fBase.fLength), Integer.toString(fMinLength)});
-					}
-					if ((fBase.fFacetsDefined & FACET_MINLENGTH) == 0){ 
-						reportError("length-minLength-maxLength.1.2.a", new Object[]{fTypeName});  
-					}
-					if (fMinLength != fBase.fMinLength){
-						reportError("length-minLength-maxLength.1.2.b", new Object[]{fTypeName, Integer.toString(fMinLength), Integer.toString(fBase.fMinLength)}); 
-					}
-				}
-				if ((fFacetsDefined & FACET_MAXLENGTH) != 0){
-					if (fBase.fLength > fMaxLength) {
-						// fBase.length, minLength and maxLength defined
-						reportError("length-minLength-maxLength.2.1", new Object[]{fTypeName, Integer.toString(fBase.fLength), Integer.toString(fMaxLength)});
-					}
-					if ((fBase.fFacetsDefined & FACET_MAXLENGTH) == 0){ 
-						reportError("length-minLength-maxLength.2.2.a", new Object[]{fTypeName});  
-					}
-					if (fMaxLength != fBase.fMaxLength){
-						reportError("length-minLength-maxLength.2.2.b", new Object[]{fTypeName, Integer.toString(fMaxLength), Integer.toString(fBase.fBase.fMaxLength)}); 
-					}
-				}
-			}
-			
-			// 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("minLength-less-than-equal-to-maxLength", new Object[]{Integer.toString(fMinLength), Integer.toString(fBase.fMaxLength), fTypeName});
-					}
-				}
-				else if ( (fBase.fFacetsDefined & FACET_MINLENGTH) != 0 ) {
-					if ( (fBase.fFixedFacet & FACET_MINLENGTH) != 0 && fMinLength != fBase.fMinLength ) {
-						reportError( "FixedFacetValue", new Object[]{"minLength", Integer.toString(fMinLength), Integer.toString(fBase.fMinLength), fTypeName});
-					}
-					
-					// check 4.3.2.c2 error: minLength < fBase.minLength
-					if ( fMinLength < fBase.fMinLength ) {
-						reportError( "minLength-valid-restriction", new Object[]{Integer.toString(fMinLength), Integer.toString(fBase.fMinLength), fTypeName});
-					}
-				}
-			}
-			
-			
-			// check 4.3.2.c1 must: maxLength < fBase.minLength
-			if ( ((fFacetsDefined & FACET_MAXLENGTH ) != 0 ) && ((fBase.fFacetsDefined & FACET_MINLENGTH ) != 0 )) {
-				if ( fMaxLength < fBase.fMinLength) {
-					reportError("minLength-less-than-equal-to-maxLength", new Object[]{Integer.toString(fBase.fMinLength), Integer.toString(fMaxLength)});
-				}
-			}
-			
-			// 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( "FixedFacetValue", new Object[]{"maxLength", Integer.toString(fMaxLength), Integer.toString(fBase.fMaxLength), fTypeName});
-					}
-					if ( fMaxLength > fBase.fMaxLength ) {
-						reportError( "maxLength-valid-restriction", new Object[]{Integer.toString(fMaxLength), Integer.toString(fBase.fMaxLength), fTypeName});
-					}
-				}
-			}
-			
-			/*          // 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[fValidationDV].compare(fMaxInclusive, fBase.fMaxInclusive);
-			     if ((fBase.fFixedFacet & FACET_MAXINCLUSIVE) != 0 && result != 0) {
-			     reportError( "FixedFacetValue", new Object[]{"maxInclusive", fMaxInclusive, fBase.fMaxInclusive, fTypeName});
-			     }
-			     if (result != -1 && result != 0) {
-			     reportError( "maxInclusive-valid-restriction.1", new Object[]{fMaxInclusive, fBase.fMaxInclusive, fTypeName});
-			     }
-			     }
-			     if (((fBase.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) &&
-			     fDVs[fValidationDV].compare(fMaxInclusive, fBase.fMaxExclusive) != -1){
-			     reportError( "maxInclusive-valid-restriction.1", new Object[]{fMaxInclusive, fBase.fMaxExclusive, fTypeName});
-			     }
-			     
-			     if ((( fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
-			     result = fDVs[fValidationDV].compare(fMaxInclusive, fBase.fMinInclusive);
-			     if (result != 1 && result != 0) {
-			     reportError( "maxInclusive-valid-restriction.1", new Object[]{fMaxInclusive, fBase.fMinInclusive, fTypeName});
-			     }
-			     }
-			     
-			     if ((( fBase.fFacetsDefined & FACET_MINEXCLUSIVE) != 0) &&
-			     fDVs[fValidationDV].compare(fMaxInclusive, fBase.fMinExclusive ) != 1)
-			     reportError( "maxInclusive-valid-restriction.1", new Object[]{fMaxInclusive, fBase.fMinExclusive, fTypeName});
-			     }
-			     
-			     // 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[fValidationDV].compare(fMaxExclusive, fBase.fMaxExclusive);
-			          if ((fBase.fFixedFacet & FACET_MAXEXCLUSIVE) != 0 &&  result != 0) {
-			          reportError( "FixedFacetValue", new Object[]{"maxExclusive", fMaxExclusive, fBase.fMaxExclusive, fTypeName});
-			          }
-			          if (result != -1 && result != 0) {
-			          reportError( "maxExclusive-valid-restriction.1", new Object[]{fMaxExclusive, fBase.fMaxExclusive, fTypeName});
-			          }
-			          }
-			          
-			          if ((( fBase.fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
-			          result= fDVs[fValidationDV].compare(fMaxExclusive, fBase.fMaxInclusive);
-			          if (result != -1 && result != 0) {
-			          reportError( "maxExclusive-valid-restriction.2", new Object[]{fMaxExclusive, fBase.fMaxInclusive, fTypeName});
-			          }
-			          }
-			          
-			          if ((( fBase.fFacetsDefined & FACET_MINEXCLUSIVE) != 0) &&
-			          fDVs[fValidationDV].compare(fMaxExclusive, fBase.fMinExclusive ) != 1)
-			          reportError( "maxExclusive-valid-restriction.3", new Object[]{fMaxExclusive, fBase.fMinExclusive, fTypeName});
-			          
-			          if ((( fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0) &&
-			          fDVs[fValidationDV].compare(fMaxExclusive, fBase.fMinInclusive) != 1)
-			          reportError( "maxExclusive-valid-restriction.4", new Object[]{fMaxExclusive, fBase.fMinInclusive, fTypeName});
-			          }
-			          
-			          // check 4.3.9.c3 error:
-			           // minExclusive < fBase.minExclusive
-			            // minExclusive > fBase.maxInclusive
-			             // minExclusive < fBase.minInclusive
-			              // minExclusive >= fBase.maxExclusive
-			               if (((fFacetsDefined & FACET_MINEXCLUSIVE) != 0)) {
-			               if ((( fBase.fFacetsDefined & FACET_MINEXCLUSIVE) != 0)) {
-			               result= fDVs[fValidationDV].compare(fMinExclusive, fBase.fMinExclusive);
-			               if ((fBase.fFixedFacet & FACET_MINEXCLUSIVE) != 0 && result != 0) {
-			               reportError( "FixedFacetValue", new Object[]{"minExclusive", fMinExclusive, fBase.fMinExclusive, fTypeName});
-			               }
-			               if (result != 1 && result != 0) {
-			               reportError( "minExclusive-valid-restriction.1", new Object[]{fMinExclusive, fBase.fMinExclusive, fTypeName});
-			               }
-			               }
-			               
-			               if ((( fBase.fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
-			               result=fDVs[fValidationDV].compare(fMinExclusive, fBase.fMaxInclusive);
-			               
-			               if (result != -1 && result != 0) {
-			               reportError( "minExclusive-valid-restriction.2", new Object[]{fMinExclusive, fBase.fMaxInclusive, fTypeName});
-			               }
-			               }
-			               
+                    } catch (InvalidDatatypeValueException ide) {
+                        reportError("enumeration-valid-restriction", new Object[]{enumVals.elementAt(i), this.getBaseType().getName()});
+                    }
+                }
+                fFacetsDefined |= FACET_ENUMERATION;
+                if ((fixedFacet & FACET_ENUMERATION) != 0)
+                    fFixedFacet |= FACET_ENUMERATION;
+            }
+        }
+        // whiteSpace
+        if ((presentFacet & FACET_WHITESPACE) != 0) {
+            if ((allowedFacet & FACET_WHITESPACE) == 0) {
+                reportError("cos-applicable-facets", new Object[]{"whiteSpace", fTypeName});
+            } else {
+                fWhiteSpace = facets.whiteSpace;
+                whiteSpaceAnnotation = facets.whiteSpaceAnnotation;
+                fFacetsDefined |= FACET_WHITESPACE;
+                if ((fixedFacet & FACET_WHITESPACE) != 0)
+                    fFixedFacet |= FACET_WHITESPACE;
+            }
+        }
+
+        // maxInclusive
+        if ((presentFacet & FACET_MAXINCLUSIVE) != 0) {
+            if ((allowedFacet & FACET_MAXINCLUSIVE) == 0) {
+                reportError("cos-applicable-facets", new Object[]{"maxInclusive", fTypeName});
+            } else {
+                maxInclusiveAnnotation = facets.maxInclusiveAnnotation;
+                try {
+                    fMaxInclusive = fBase.getActualValue(facets.maxInclusive, context, tempInfo, true);
+                    fFacetsDefined |= FACET_MAXINCLUSIVE;
+                    if ((fixedFacet & FACET_MAXINCLUSIVE) != 0)
+                        fFixedFacet |= FACET_MAXINCLUSIVE;
+                } catch (InvalidDatatypeValueException ide) {
+                    reportError(ide.getKey(), ide.getArgs());
+                    reportError("FacetValueFromBase", new Object[]{fTypeName, facets.maxInclusive,
+                            "maxInclusive", fBase.getName()});
+                }
+
+                // check against fixed value in base
+                if (((fBase.fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
+                    if ((fBase.fFixedFacet & FACET_MAXINCLUSIVE) != 0) {
+                        if (fDVs[fValidationDV].compare(fMaxInclusive, fBase.fMaxInclusive) != 0)
+                            reportError( "FixedFacetValue", new Object[]{"maxInclusive", fMaxInclusive, fBase.fMaxInclusive, fTypeName});
+                    }
+                }
+                // maxInclusive from base
+                try {
+                    fBase.validate(context, tempInfo);
+                } catch (InvalidDatatypeValueException ide) {
+                    reportError(ide.getKey(), ide.getArgs());
+                    reportError("FacetValueFromBase", new Object[]{fTypeName, facets.maxInclusive,
+                            "maxInclusive", fBase.getName()});
+                }
+            }
+        }
+
+        // maxExclusive
+        boolean needCheckBase = true;
+        if ((presentFacet & FACET_MAXEXCLUSIVE) != 0) {
+            if ((allowedFacet & FACET_MAXEXCLUSIVE) == 0) {
+                reportError("cos-applicable-facets", new Object[]{"maxExclusive", fTypeName});
+            } else {
+                maxExclusiveAnnotation = facets.maxExclusiveAnnotation;
+                try {
+                    fMaxExclusive = fBase.getActualValue(facets.maxExclusive, context, tempInfo, true);
+                    fFacetsDefined |= FACET_MAXEXCLUSIVE;
+                    if ((fixedFacet & FACET_MAXEXCLUSIVE) != 0)
+                        fFixedFacet |= FACET_MAXEXCLUSIVE;
+                } catch (InvalidDatatypeValueException ide) {
+                    reportError(ide.getKey(), ide.getArgs());
+                    reportError("FacetValueFromBase", new Object[]{fTypeName, facets.maxExclusive,
+                            "maxExclusive", fBase.getName()});
+                }
+
+                // check against fixed value in base
+                if (((fBase.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0)) {
+                    result = fDVs[fValidationDV].compare(fMaxExclusive, fBase.fMaxExclusive);
+                    if ((fBase.fFixedFacet & FACET_MAXEXCLUSIVE) != 0 && result != 0) {
+                        reportError( "FixedFacetValue", new Object[]{"maxExclusive", facets.maxExclusive, fBase.fMaxExclusive, fTypeName});
+                    }
+                    if (result == 0) {
+                        needCheckBase = false;
+                    }
+                }
+                // maxExclusive from base
+                if (needCheckBase) {
+                    try {
+                        fBase.validate(context, tempInfo);
+                    } catch (InvalidDatatypeValueException ide) {
+                        reportError(ide.getKey(), ide.getArgs());
+                        reportError("FacetValueFromBase", new Object[]{fTypeName, facets.maxExclusive,
+                                "maxExclusive", fBase.getName()});
+                    }
+                }
+                // If maxExclusive == base.maxExclusive, then we only need to check
+                // maxExclusive <= base.maxInclusive
+                else if (((fBase.fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
+                    if (fDVs[fValidationDV].compare(fMaxExclusive, fBase.fMaxInclusive) > 0) {
+                        reportError( "maxExclusive-valid-restriction.2", new Object[]{facets.maxExclusive, fBase.fMaxInclusive});
+                    }
+                }
+            }
+        }
+        // minExclusive
+        needCheckBase = true;
+        if ((presentFacet & FACET_MINEXCLUSIVE) != 0) {
+            if ((allowedFacet & FACET_MINEXCLUSIVE) == 0) {
+                reportError("cos-applicable-facets", new Object[]{"minExclusive", fTypeName});
+            } else {
+                minExclusiveAnnotation = facets.minExclusiveAnnotation;
+                try {
+                    fMinExclusive = fBase.getActualValue(facets.minExclusive, context, tempInfo, true);
+                    fFacetsDefined |= FACET_MINEXCLUSIVE;
+                    if ((fixedFacet & FACET_MINEXCLUSIVE) != 0)
+                        fFixedFacet |= FACET_MINEXCLUSIVE;
+                } catch (InvalidDatatypeValueException ide) {
+                    reportError(ide.getKey(), ide.getArgs());
+                    reportError("FacetValueFromBase", new Object[]{fTypeName, facets.minExclusive,
+                            "minExclusive", fBase.getName()});
+                }
+
+                // check against fixed value in base
+                if (((fBase.fFacetsDefined & FACET_MINEXCLUSIVE) != 0)) {
+                    result = fDVs[fValidationDV].compare(fMinExclusive, fBase.fMinExclusive);
+                    if ((fBase.fFixedFacet & FACET_MINEXCLUSIVE) != 0 && result != 0) {
+                        reportError( "FixedFacetValue", new Object[]{"minExclusive", facets.minExclusive, fBase.fMinExclusive, fTypeName});
+                    }
+                    if (result == 0) {
+                        needCheckBase = false;
+                    }
+                }
+                // minExclusive from base
+                if (needCheckBase) {
+                    try {
+                        fBase.validate(context, tempInfo);
+                    } catch (InvalidDatatypeValueException ide) {
+                        reportError(ide.getKey(), ide.getArgs());
+                        reportError("FacetValueFromBase", new Object[]{fTypeName, facets.minExclusive,
+                                "minExclusive", fBase.getName()});
+                    }
+                }
+                // If minExclusive == base.minExclusive, then we only need to check
+                // minExclusive >= base.minInclusive
+                else if (((fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
+                    if (fDVs[fValidationDV].compare(fMinExclusive, fBase.fMinInclusive) < 0) {
+                        reportError( "minExclusive-valid-restriction.3", new Object[]{facets.minExclusive, fBase.fMinInclusive});
+                    }
+                }
+            }
+        }
+        // minInclusive
+        if ((presentFacet & FACET_MININCLUSIVE) != 0) {
+            if ((allowedFacet & FACET_MININCLUSIVE) == 0) {
+                reportError("cos-applicable-facets", new Object[]{"minInclusive", fTypeName});
+            } else {
+                minInclusiveAnnotation = facets.minInclusiveAnnotation;
+                try {
+                    fMinInclusive = fBase.getActualValue(facets.minInclusive, context, tempInfo, true);
+                    fFacetsDefined |= FACET_MININCLUSIVE;
+                    if ((fixedFacet & FACET_MININCLUSIVE) != 0)
+                        fFixedFacet |= FACET_MININCLUSIVE;
+                } catch (InvalidDatatypeValueException ide) {
+                    reportError(ide.getKey(), ide.getArgs());
+                    reportError("FacetValueFromBase", new Object[]{fTypeName, facets.minInclusive,
+                            "minInclusive", fBase.getName()});
+                }
+
+                // check against fixed value in base
+                if (((fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
+                    if ((fBase.fFixedFacet & FACET_MININCLUSIVE) != 0) {
+                        if (fDVs[fValidationDV].compare(fMinInclusive, fBase.fMinInclusive) != 0)
+                            reportError( "FixedFacetValue", new Object[]{"minInclusive", facets.minInclusive, fBase.fMinInclusive, fTypeName});
+                    }
+                }
+                // minInclusive from base
+                try {
+                    fBase.validate(context, tempInfo);
+                } catch (InvalidDatatypeValueException ide) {
+                    reportError(ide.getKey(), ide.getArgs());
+                    reportError("FacetValueFromBase", new Object[]{fTypeName, facets.minInclusive,
+                            "minInclusive", fBase.getName()});
+                }
+            }
+        }
+
+        // totalDigits
+        if ((presentFacet & FACET_TOTALDIGITS) != 0) {
+            if ((allowedFacet & FACET_TOTALDIGITS) == 0) {
+                reportError("cos-applicable-facets", new Object[]{"totalDigits", fTypeName});
+            } else {
+                totalDigitsAnnotation = facets.totalDigitsAnnotation;
+                fTotalDigits = facets.totalDigits;
+                fFacetsDefined |= FACET_TOTALDIGITS;
+                if ((fixedFacet & FACET_TOTALDIGITS) != 0)
+                    fFixedFacet |= FACET_TOTALDIGITS;
+            }
+        }
+        // fractionDigits
+        if ((presentFacet & FACET_FRACTIONDIGITS) != 0) {
+            if ((allowedFacet & FACET_FRACTIONDIGITS) == 0) {
+                reportError("cos-applicable-facets", new Object[]{"fractionDigits", fTypeName});
+            } else {
+                fFractionDigits = facets.fractionDigits;
+                fractionDigitsAnnotation = facets.fractionDigitsAnnotation;
+                fFacetsDefined |= FACET_FRACTIONDIGITS;
+                if ((fixedFacet & FACET_FRACTIONDIGITS) != 0)
+                    fFixedFacet |= FACET_FRACTIONDIGITS;
+            }
+        }
+
+        // token type: internal use, so do less checking
+        if (patternType != SPECIAL_PATTERN_NONE) {
+            fPatternType = patternType;
+        }
+
+        // step 2: check facets against each other: length, bounds
+        if(fFacetsDefined != 0) {
+
+            // check 4.3.2.c1 must: minLength <= maxLength
+            if(((fFacetsDefined & FACET_MINLENGTH ) != 0 ) && ((fFacetsDefined & FACET_MAXLENGTH) != 0))
+            {
+                if(fMinLength > fMaxLength)
+                    reportError("minLength-less-than-equal-to-maxLength", new Object[]{Integer.toString(fMinLength), Integer.toString(fMaxLength), fTypeName});
+            }
+
+            // check 4.3.8.c1 error: maxInclusive + maxExclusive
+            if (((fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) && ((fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
+                reportError( "maxInclusive-maxExclusive", new Object[]{fMaxInclusive, fMaxExclusive, fTypeName});
+            }
+
+            // check 4.3.9.c1 error: minInclusive + minExclusive
+            if (((fFacetsDefined & FACET_MINEXCLUSIVE) != 0) && ((fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
+                reportError("minInclusive-minExclusive", new Object[]{fMinInclusive, fMinExclusive, fTypeName});
+            }
+
+            // check 4.3.7.c1 must: minInclusive <= maxInclusive
+            if (((fFacetsDefined &  FACET_MAXINCLUSIVE) != 0) && ((fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
+                result = fDVs[fValidationDV].compare(fMinInclusive, fMaxInclusive);
+                if (result != -1 && result != 0)
+                    reportError("minInclusive-less-than-equal-to-maxInclusive", new Object[]{fMinInclusive, fMaxInclusive, fTypeName});
+            }
+
+            // check 4.3.8.c2 must: minExclusive <= maxExclusive ??? minExclusive < maxExclusive
+            if (((fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) && ((fFacetsDefined & FACET_MINEXCLUSIVE) != 0)) {
+                result = fDVs[fValidationDV].compare(fMinExclusive, fMaxExclusive);
+                if (result != -1 && result != 0)
+                    reportError( "minExclusive-less-than-equal-to-maxExclusive", new Object[]{fMinExclusive, fMaxExclusive, fTypeName});
+            }
+
+            // check 4.3.9.c2 must: minExclusive < maxInclusive
+            if (((fFacetsDefined & FACET_MAXINCLUSIVE) != 0) && ((fFacetsDefined & FACET_MINEXCLUSIVE) != 0)) {
+                if (fDVs[fValidationDV].compare(fMinExclusive, fMaxInclusive) != -1)
+                    reportError( "minExclusive-less-than-maxInclusive", new Object[]{fMinExclusive, fMaxInclusive, fTypeName});
+            }
+

[... 3925 lines stripped ...]


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