public FacetsCompiler(DatatypeImplementation baseDatatype, RestrictionFacets restriction) {
firstPattern = true;
regStr = null;
pattern_facet = null;
datatype = baseDatatype;
derivedRestriction = restriction;
baseFlags = datatype.Restriction != null ? datatype.Restriction.Flags : 0;
baseFixedFlags = datatype.Restriction != null ? datatype.Restriction.FixedFlags : 0;
validRestrictionFlags = datatype.ValidRestrictionFlags;
nonNegativeInt = DatatypeImplementation.GetSimpleTypeFromTypeCode(XmlTypeCode.NonNegativeInteger).Datatype;
builtInEnum = !(datatype is Datatype_union || datatype is Datatype_List) ? datatype.TypeCode : 0;
builtInType = (int)builtInEnum > 0 ? DatatypeImplementation.GetSimpleTypeFromTypeCode(builtInEnum).Datatype : datatype;
}