Inheritance: XmlSchemaDatatype
 public override bool IsDerivedFrom(XmlSchemaDatatype datatype)
 {
     if (datatype == null)
     {
         return(false);
     }
     for (DatatypeImplementation implementation = this; implementation != null; implementation = implementation.baseType)
     {
         if (implementation == datatype)
         {
             return(true);
         }
     }
     if (((DatatypeImplementation)datatype).baseType == null)
     {
         Type type = base.GetType();
         Type c    = datatype.GetType();
         if (!(c == type))
         {
             return(type.IsSubclassOf(c));
         }
         return(true);
     }
     if (((datatype.Variety == XmlSchemaDatatypeVariety.Union) && !datatype.HasLexicalFacets) && (!datatype.HasValueFacets && (this.variety != XmlSchemaDatatypeVariety.Union)))
     {
         return(((Datatype_union)datatype).IsUnionBaseOf(this));
     }
     return((((this.variety == XmlSchemaDatatypeVariety.Union) || (this.variety == XmlSchemaDatatypeVariety.List)) && (this.restriction == null)) && (datatype == anySimpleType.Datatype));
 }
Beispiel #2
0
 /// <include file='doc\XmlSchemaType.uex' path='docs/doc[@for="XmlSchemaType.GetXsdSimpleType"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public static XmlSchemaSimpleType GetBuiltInSimpleType(XmlQualifiedName qualifiedName)
 {
     if (qualifiedName == null)
     {
         throw new ArgumentNullException("qualifiedName");
     }
     return(DatatypeImplementation.GetSimpleTypeFromXsdType(qualifiedName));
 }
        internal override XmlSchemaDatatype DeriveByRestriction(XmlSchemaObjectCollection facets, XmlNameTable nameTable, XmlSchemaType schemaType)
        {
            DatatypeImplementation implementation = (DatatypeImplementation)base.MemberwiseClone();

            implementation.restriction      = this.FacetsChecker.ConstructRestriction(this, facets, nameTable);
            implementation.baseType         = this;
            implementation.parentSchemaType = schemaType;
            implementation.valueConverter   = null;
            return(implementation);
        }
 internal bool IsUnionBaseOf(DatatypeImplementation derivedType)
 {
     for (int i = 0; i < this.types.Length; i++)
     {
         if (derivedType.IsDerivedFrom(this.types[i].Datatype))
         {
             return true;
         }
     }
     return false;
 }
 internal bool IsUnionBaseOf(DatatypeImplementation derivedType)
 {
     for (int i = 0; i < this.types.Length; i++)
     {
         if (derivedType.IsDerivedFrom(this.types[i].Datatype))
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #6
0
 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;
 }
Beispiel #7
0
 public FacetsCompiler(DatatypeImplementation baseDatatype, RestrictionFacets restriction)
 {
     this.firstPattern          = true;
     this.regStr                = null;
     this.pattern_facet         = null;
     this.datatype              = baseDatatype;
     this.derivedRestriction    = restriction;
     this.baseFlags             = (this.datatype.Restriction != null) ? this.datatype.Restriction.Flags : ((RestrictionFlags)0);
     this.baseFixedFlags        = (this.datatype.Restriction != null) ? this.datatype.Restriction.FixedFlags : ((RestrictionFlags)0);
     this.validRestrictionFlags = this.datatype.ValidRestrictionFlags;
     this.nonNegativeInt        = DatatypeImplementation.GetSimpleTypeFromTypeCode(XmlTypeCode.NonNegativeInteger).Datatype;
     this.builtInEnum           = (!(this.datatype is Datatype_union) && !(this.datatype is Datatype_List)) ? this.datatype.TypeCode : XmlTypeCode.None;
     this.builtInType           = (this.builtInEnum > XmlTypeCode.None) ? DatatypeImplementation.GetSimpleTypeFromTypeCode(this.builtInEnum).Datatype : this.datatype;
 }
Beispiel #8
0
 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;
 }
Beispiel #9
0
            internal void CompileTotalDigitsFacet(XmlSchemaFacet facet)
            {
                this.CheckProhibitedFlag(facet, RestrictionFlags.TotalDigits, "Sch_TotalDigitsFacetProhibited");
                this.CheckDupFlag(facet, RestrictionFlags.TotalDigits, "Sch_DupTotalDigitsFacet");
                XmlSchemaDatatype datatype = DatatypeImplementation.GetSimpleTypeFromTypeCode(XmlTypeCode.PositiveInteger).Datatype;

                this.derivedRestriction.TotalDigits = XmlBaseConverter.DecimalToInt32((decimal)this.ParseFacetValue(datatype, facet, "Sch_TotalDigitsFacetInvalid", null, null));
                if (((this.baseFixedFlags & RestrictionFlags.TotalDigits) != 0) && !this.datatype.IsEqual(this.datatype.Restriction.TotalDigits, this.derivedRestriction.TotalDigits))
                {
                    throw new XmlSchemaException("Sch_FacetBaseFixed", facet);
                }
                if (((this.baseFlags & RestrictionFlags.TotalDigits) != 0) && (this.derivedRestriction.TotalDigits > this.datatype.Restriction.TotalDigits))
                {
                    throw new XmlSchemaException("Sch_TotalDigitsMismatch", string.Empty);
                }
                this.SetFlag(facet, RestrictionFlags.TotalDigits);
            }
        internal override XmlValueConverter CreateValueConverter(XmlSchemaType schemaType)
        {
            XmlSchemaType        baseItemType = null;
            XmlSchemaSimpleType  baseXmlSchemaType;
            XmlSchemaComplexType type3 = schemaType as XmlSchemaComplexType;

            if (type3 != null)
            {
                do
                {
                    baseXmlSchemaType = type3.BaseXmlSchemaType as XmlSchemaSimpleType;
                    if (baseXmlSchemaType != null)
                    {
                        break;
                    }
                    type3 = type3.BaseXmlSchemaType as XmlSchemaComplexType;
                    if (type3 == null)
                    {
                        break;
                    }
                }while (type3 != XmlSchemaComplexType.AnyType);
            }
            else
            {
                baseXmlSchemaType = schemaType as XmlSchemaSimpleType;
            }
            if (baseXmlSchemaType != null)
            {
                do
                {
                    XmlSchemaSimpleTypeList content = baseXmlSchemaType.Content as XmlSchemaSimpleTypeList;
                    if (content != null)
                    {
                        baseItemType = content.BaseItemType;
                        break;
                    }
                    baseXmlSchemaType = baseXmlSchemaType.BaseXmlSchemaType as XmlSchemaSimpleType;
                }while ((baseXmlSchemaType != null) && (baseXmlSchemaType != DatatypeImplementation.AnySimpleType));
            }
            if (baseItemType == null)
            {
                baseItemType = DatatypeImplementation.GetSimpleTypeFromTypeCode(schemaType.Datatype.TypeCode);
            }
            return(XmlListConverter.Create(baseItemType.ValueConverter));
        }
 static DatatypeImplementation()
 {
     DatatypeImplementation[] implementationArray = new DatatypeImplementation[13];
     implementationArray[0]  = c_string;
     implementationArray[1]  = c_ID;
     implementationArray[2]  = c_IDREF;
     implementationArray[3]  = c_IDREFS;
     implementationArray[4]  = c_ENTITY;
     implementationArray[5]  = c_ENTITIES;
     implementationArray[6]  = c_NMTOKEN;
     implementationArray[7]  = c_NMTOKENS;
     implementationArray[8]  = c_NOTATION;
     implementationArray[9]  = c_ENUMERATION;
     implementationArray[10] = c_QNameXdr;
     implementationArray[11] = c_NCName;
     c_tokenizedTypes        = implementationArray;
     DatatypeImplementation[] implementationArray2 = new DatatypeImplementation[13];
     implementationArray2[0]  = c_string;
     implementationArray2[1]  = c_ID;
     implementationArray2[2]  = c_IDREF;
     implementationArray2[3]  = c_IDREFS;
     implementationArray2[4]  = c_ENTITY;
     implementationArray2[5]  = c_ENTITIES;
     implementationArray2[6]  = c_NMTOKEN;
     implementationArray2[7]  = c_NMTOKENS;
     implementationArray2[8]  = c_NOTATION;
     implementationArray2[9]  = c_ENUMERATION;
     implementationArray2[10] = c_QName;
     implementationArray2[11] = c_NCName;
     c_tokenizedTypesXsd      = implementationArray2;
     c_XdrTypes = new SchemaDatatypeMap[] {
         new SchemaDatatypeMap("bin.base64", c_base64Binary), new SchemaDatatypeMap("bin.hex", c_hexBinary), new SchemaDatatypeMap("boolean", c_boolean), new SchemaDatatypeMap("char", c_char), new SchemaDatatypeMap("date", c_date), new SchemaDatatypeMap("dateTime", c_dateTimeNoTz), new SchemaDatatypeMap("dateTime.tz", c_dateTimeTz), new SchemaDatatypeMap("decimal", c_decimal), new SchemaDatatypeMap("entities", c_ENTITIES), new SchemaDatatypeMap("entity", c_ENTITY), new SchemaDatatypeMap("enumeration", c_ENUMERATION), new SchemaDatatypeMap("fixed.14.4", c_fixed), new SchemaDatatypeMap("float", c_doubleXdr), new SchemaDatatypeMap("float.ieee.754.32", c_floatXdr), new SchemaDatatypeMap("float.ieee.754.64", c_doubleXdr), new SchemaDatatypeMap("i1", c_byte),
         new SchemaDatatypeMap("i2", c_short), new SchemaDatatypeMap("i4", c_int), new SchemaDatatypeMap("i8", c_long), new SchemaDatatypeMap("id", c_ID), new SchemaDatatypeMap("idref", c_IDREF), new SchemaDatatypeMap("idrefs", c_IDREFS), new SchemaDatatypeMap("int", c_int), new SchemaDatatypeMap("nmtoken", c_NMTOKEN), new SchemaDatatypeMap("nmtokens", c_NMTOKENS), new SchemaDatatypeMap("notation", c_NOTATION), new SchemaDatatypeMap("number", c_doubleXdr), new SchemaDatatypeMap("r4", c_floatXdr), new SchemaDatatypeMap("r8", c_doubleXdr), new SchemaDatatypeMap("string", c_string), new SchemaDatatypeMap("time", c_timeNoTz), new SchemaDatatypeMap("time.tz", c_timeTz),
         new SchemaDatatypeMap("ui1", c_unsignedByte), new SchemaDatatypeMap("ui2", c_unsignedShort), new SchemaDatatypeMap("ui4", c_unsignedInt), new SchemaDatatypeMap("ui8", c_unsignedLong), new SchemaDatatypeMap("uri", c_anyURI), new SchemaDatatypeMap("uuid", c_uuid)
     };
     c_XsdTypes = new SchemaDatatypeMap[] {
         new SchemaDatatypeMap("ENTITIES", c_ENTITIES, 11), new SchemaDatatypeMap("ENTITY", c_ENTITY, 11), new SchemaDatatypeMap("ID", c_ID, 5), new SchemaDatatypeMap("IDREF", c_IDREF, 5), new SchemaDatatypeMap("IDREFS", c_IDREFS, 11), new SchemaDatatypeMap("NCName", c_NCName, 9), new SchemaDatatypeMap("NMTOKEN", c_NMTOKEN, 40), new SchemaDatatypeMap("NMTOKENS", c_NMTOKENS, 11), new SchemaDatatypeMap("NOTATION", c_NOTATION, 11), new SchemaDatatypeMap("Name", c_Name, 40), new SchemaDatatypeMap("QName", c_QName, 11), new SchemaDatatypeMap("anySimpleType", c_anySimpleType, -1), new SchemaDatatypeMap("anyURI", c_anyURI, 11), new SchemaDatatypeMap("base64Binary", c_base64Binary, 11), new SchemaDatatypeMap("boolean", c_boolean, 11), new SchemaDatatypeMap("byte", c_byte, 0x25),
         new SchemaDatatypeMap("date", c_date, 11), new SchemaDatatypeMap("dateTime", c_dateTime, 11), new SchemaDatatypeMap("decimal", c_decimal, 11), new SchemaDatatypeMap("double", c_double, 11), new SchemaDatatypeMap("duration", c_duration, 11), new SchemaDatatypeMap("float", c_float, 11), new SchemaDatatypeMap("gDay", c_day, 11), new SchemaDatatypeMap("gMonth", c_month, 11), new SchemaDatatypeMap("gMonthDay", c_monthDay, 11), new SchemaDatatypeMap("gYear", c_year, 11), new SchemaDatatypeMap("gYearMonth", c_yearMonth, 11), new SchemaDatatypeMap("hexBinary", c_hexBinary, 11), new SchemaDatatypeMap("int", c_int, 0x1f), new SchemaDatatypeMap("integer", c_integer, 0x12), new SchemaDatatypeMap("language", c_language, 40), new SchemaDatatypeMap("long", c_long, 0x1d),
         new SchemaDatatypeMap("negativeInteger", c_negativeInteger, 0x22), new SchemaDatatypeMap("nonNegativeInteger", c_nonNegativeInteger, 0x1d), new SchemaDatatypeMap("nonPositiveInteger", c_nonPositiveInteger, 0x1d), new SchemaDatatypeMap("normalizedString", c_normalizedString, 0x26), new SchemaDatatypeMap("positiveInteger", c_positiveInteger, 0x21), new SchemaDatatypeMap("short", c_short, 0x1c), new SchemaDatatypeMap("string", c_string, 11), new SchemaDatatypeMap("time", c_time, 11), new SchemaDatatypeMap("token", c_token, 0x23), new SchemaDatatypeMap("unsignedByte", c_unsignedByte, 0x2c), new SchemaDatatypeMap("unsignedInt", c_unsignedInt, 0x2b), new SchemaDatatypeMap("unsignedLong", c_unsignedLong, 0x21), new SchemaDatatypeMap("unsignedShort", c_unsignedShort, 0x2a)
     };
     CreateBuiltinTypes();
 }
 static DatatypeImplementation()
 {
     DatatypeImplementation[] implementationArray = new DatatypeImplementation[13];
     implementationArray[0] = c_string;
     implementationArray[1] = c_ID;
     implementationArray[2] = c_IDREF;
     implementationArray[3] = c_IDREFS;
     implementationArray[4] = c_ENTITY;
     implementationArray[5] = c_ENTITIES;
     implementationArray[6] = c_NMTOKEN;
     implementationArray[7] = c_NMTOKENS;
     implementationArray[8] = c_NOTATION;
     implementationArray[9] = c_ENUMERATION;
     implementationArray[10] = c_QNameXdr;
     implementationArray[11] = c_NCName;
     c_tokenizedTypes = implementationArray;
     DatatypeImplementation[] implementationArray2 = new DatatypeImplementation[13];
     implementationArray2[0] = c_string;
     implementationArray2[1] = c_ID;
     implementationArray2[2] = c_IDREF;
     implementationArray2[3] = c_IDREFS;
     implementationArray2[4] = c_ENTITY;
     implementationArray2[5] = c_ENTITIES;
     implementationArray2[6] = c_NMTOKEN;
     implementationArray2[7] = c_NMTOKENS;
     implementationArray2[8] = c_NOTATION;
     implementationArray2[9] = c_ENUMERATION;
     implementationArray2[10] = c_QName;
     implementationArray2[11] = c_NCName;
     c_tokenizedTypesXsd = implementationArray2;
     c_XdrTypes = new SchemaDatatypeMap[] { 
         new SchemaDatatypeMap("bin.base64", c_base64Binary), new SchemaDatatypeMap("bin.hex", c_hexBinary), new SchemaDatatypeMap("boolean", c_boolean), new SchemaDatatypeMap("char", c_char), new SchemaDatatypeMap("date", c_date), new SchemaDatatypeMap("dateTime", c_dateTimeNoTz), new SchemaDatatypeMap("dateTime.tz", c_dateTimeTz), new SchemaDatatypeMap("decimal", c_decimal), new SchemaDatatypeMap("entities", c_ENTITIES), new SchemaDatatypeMap("entity", c_ENTITY), new SchemaDatatypeMap("enumeration", c_ENUMERATION), new SchemaDatatypeMap("fixed.14.4", c_fixed), new SchemaDatatypeMap("float", c_doubleXdr), new SchemaDatatypeMap("float.ieee.754.32", c_floatXdr), new SchemaDatatypeMap("float.ieee.754.64", c_doubleXdr), new SchemaDatatypeMap("i1", c_byte), 
         new SchemaDatatypeMap("i2", c_short), new SchemaDatatypeMap("i4", c_int), new SchemaDatatypeMap("i8", c_long), new SchemaDatatypeMap("id", c_ID), new SchemaDatatypeMap("idref", c_IDREF), new SchemaDatatypeMap("idrefs", c_IDREFS), new SchemaDatatypeMap("int", c_int), new SchemaDatatypeMap("nmtoken", c_NMTOKEN), new SchemaDatatypeMap("nmtokens", c_NMTOKENS), new SchemaDatatypeMap("notation", c_NOTATION), new SchemaDatatypeMap("number", c_doubleXdr), new SchemaDatatypeMap("r4", c_floatXdr), new SchemaDatatypeMap("r8", c_doubleXdr), new SchemaDatatypeMap("string", c_string), new SchemaDatatypeMap("time", c_timeNoTz), new SchemaDatatypeMap("time.tz", c_timeTz), 
         new SchemaDatatypeMap("ui1", c_unsignedByte), new SchemaDatatypeMap("ui2", c_unsignedShort), new SchemaDatatypeMap("ui4", c_unsignedInt), new SchemaDatatypeMap("ui8", c_unsignedLong), new SchemaDatatypeMap("uri", c_anyURI), new SchemaDatatypeMap("uuid", c_uuid)
      };
     c_XsdTypes = new SchemaDatatypeMap[] { 
         new SchemaDatatypeMap("ENTITIES", c_ENTITIES, 11), new SchemaDatatypeMap("ENTITY", c_ENTITY, 11), new SchemaDatatypeMap("ID", c_ID, 5), new SchemaDatatypeMap("IDREF", c_IDREF, 5), new SchemaDatatypeMap("IDREFS", c_IDREFS, 11), new SchemaDatatypeMap("NCName", c_NCName, 9), new SchemaDatatypeMap("NMTOKEN", c_NMTOKEN, 40), new SchemaDatatypeMap("NMTOKENS", c_NMTOKENS, 11), new SchemaDatatypeMap("NOTATION", c_NOTATION, 11), new SchemaDatatypeMap("Name", c_Name, 40), new SchemaDatatypeMap("QName", c_QName, 11), new SchemaDatatypeMap("anySimpleType", c_anySimpleType, -1), new SchemaDatatypeMap("anyURI", c_anyURI, 11), new SchemaDatatypeMap("base64Binary", c_base64Binary, 11), new SchemaDatatypeMap("boolean", c_boolean, 11), new SchemaDatatypeMap("byte", c_byte, 0x25), 
         new SchemaDatatypeMap("date", c_date, 11), new SchemaDatatypeMap("dateTime", c_dateTime, 11), new SchemaDatatypeMap("decimal", c_decimal, 11), new SchemaDatatypeMap("double", c_double, 11), new SchemaDatatypeMap("duration", c_duration, 11), new SchemaDatatypeMap("float", c_float, 11), new SchemaDatatypeMap("gDay", c_day, 11), new SchemaDatatypeMap("gMonth", c_month, 11), new SchemaDatatypeMap("gMonthDay", c_monthDay, 11), new SchemaDatatypeMap("gYear", c_year, 11), new SchemaDatatypeMap("gYearMonth", c_yearMonth, 11), new SchemaDatatypeMap("hexBinary", c_hexBinary, 11), new SchemaDatatypeMap("int", c_int, 0x1f), new SchemaDatatypeMap("integer", c_integer, 0x12), new SchemaDatatypeMap("language", c_language, 40), new SchemaDatatypeMap("long", c_long, 0x1d), 
         new SchemaDatatypeMap("negativeInteger", c_negativeInteger, 0x22), new SchemaDatatypeMap("nonNegativeInteger", c_nonNegativeInteger, 0x1d), new SchemaDatatypeMap("nonPositiveInteger", c_nonPositiveInteger, 0x1d), new SchemaDatatypeMap("normalizedString", c_normalizedString, 0x26), new SchemaDatatypeMap("positiveInteger", c_positiveInteger, 0x21), new SchemaDatatypeMap("short", c_short, 0x1c), new SchemaDatatypeMap("string", c_string, 11), new SchemaDatatypeMap("time", c_time, 11), new SchemaDatatypeMap("token", c_token, 0x23), new SchemaDatatypeMap("unsignedByte", c_unsignedByte, 0x2c), new SchemaDatatypeMap("unsignedInt", c_unsignedInt, 0x2b), new SchemaDatatypeMap("unsignedLong", c_unsignedLong, 0x21), new SchemaDatatypeMap("unsignedShort", c_unsignedShort, 0x2a)
      };
     CreateBuiltinTypes();
 }
 internal Datatype_List(DatatypeImplementation type) : this(type, 0) {
 }
 internal SchemaDatatypeMap(string name, DatatypeImplementation type)
 {
     _name = name;
     _type = type;
 }
Beispiel #15
0
 internal static XmlSchemaDatatype FromXdrName(string name)
 {
     return(DatatypeImplementation.FromXdrName(name));
 }
 public FacetsCompiler(DatatypeImplementation baseDatatype, RestrictionFacets restriction)
 {
     this.firstPattern = true;
     this.regStr = null;
     this.pattern_facet = null;
     this.datatype = baseDatatype;
     this.derivedRestriction = restriction;
     this.baseFlags = (this.datatype.Restriction != null) ? this.datatype.Restriction.Flags : ((RestrictionFlags) 0);
     this.baseFixedFlags = (this.datatype.Restriction != null) ? this.datatype.Restriction.FixedFlags : ((RestrictionFlags) 0);
     this.validRestrictionFlags = this.datatype.ValidRestrictionFlags;
     this.nonNegativeInt = DatatypeImplementation.GetSimpleTypeFromTypeCode(XmlTypeCode.NonNegativeInteger).Datatype;
     this.builtInEnum = (!(this.datatype is Datatype_union) && !(this.datatype is Datatype_List)) ? this.datatype.TypeCode : XmlTypeCode.None;
     this.builtInType = (this.builtInEnum > XmlTypeCode.None) ? DatatypeImplementation.GetSimpleTypeFromTypeCode(this.builtInEnum).Datatype : this.datatype;
 }
 internal SchemaDatatypeMap(string name, DatatypeImplementation type, int parentIndex)
 {
     this.name        = name;
     this.type        = type;
     this.parentIndex = parentIndex;
 }
 internal SchemaDatatypeMap(string name, DatatypeImplementation type, int parentIndex)
 {
     _name = name;
     _type = type;
     _parentIndex = parentIndex;
 }
        internal static void CreateBuiltinTypes()
        {
            SchemaDatatypeMap      map      = c_XsdTypes[11];
            XmlQualifiedName       qname    = new XmlQualifiedName(map.Name, "http://www.w3.org/2001/XMLSchema");
            DatatypeImplementation dataType = FromTypeName(qname.Name);

            anySimpleType             = StartBuiltinType(qname, dataType);
            dataType.parentSchemaType = anySimpleType;
            builtinTypes.Add(qname, anySimpleType);
            for (int i = 0; i < c_XsdTypes.Length; i++)
            {
                if (i != 11)
                {
                    map      = c_XsdTypes[i];
                    qname    = new XmlQualifiedName(map.Name, "http://www.w3.org/2001/XMLSchema");
                    dataType = FromTypeName(qname.Name);
                    XmlSchemaSimpleType type = StartBuiltinType(qname, dataType);
                    dataType.parentSchemaType = type;
                    builtinTypes.Add(qname, type);
                    if (dataType.variety == XmlSchemaDatatypeVariety.Atomic)
                    {
                        enumToTypeCode[(int)dataType.TypeCode] = type;
                    }
                }
            }
            for (int j = 0; j < c_XsdTypes.Length; j++)
            {
                if (j != 11)
                {
                    map = c_XsdTypes[j];
                    XmlSchemaSimpleType derivedType = (XmlSchemaSimpleType)builtinTypes[new XmlQualifiedName(map.Name, "http://www.w3.org/2001/XMLSchema")];
                    if (map.ParentIndex == 11)
                    {
                        FinishBuiltinType(derivedType, anySimpleType);
                    }
                    else
                    {
                        XmlSchemaSimpleType baseType = (XmlSchemaSimpleType)builtinTypes[new XmlQualifiedName(c_XsdTypes[map.ParentIndex].Name, "http://www.w3.org/2001/XMLSchema")];
                        FinishBuiltinType(derivedType, baseType);
                    }
                }
            }
            qname         = new XmlQualifiedName("anyAtomicType", "http://www.w3.org/2003/11/xpath-datatypes");
            anyAtomicType = StartBuiltinType(qname, c_anyAtomicType);
            c_anyAtomicType.parentSchemaType = anyAtomicType;
            FinishBuiltinType(anyAtomicType, anySimpleType);
            builtinTypes.Add(qname, anyAtomicType);
            enumToTypeCode[10] = anyAtomicType;
            qname             = new XmlQualifiedName("untypedAtomic", "http://www.w3.org/2003/11/xpath-datatypes");
            untypedAtomicType = StartBuiltinType(qname, c_untypedAtomicType);
            c_untypedAtomicType.parentSchemaType = untypedAtomicType;
            FinishBuiltinType(untypedAtomicType, anyAtomicType);
            builtinTypes.Add(qname, untypedAtomicType);
            enumToTypeCode[11] = untypedAtomicType;
            qname = new XmlQualifiedName("yearMonthDuration", "http://www.w3.org/2003/11/xpath-datatypes");
            yearMonthDurationType = StartBuiltinType(qname, c_yearMonthDuration);
            c_yearMonthDuration.parentSchemaType = yearMonthDurationType;
            FinishBuiltinType(yearMonthDurationType, enumToTypeCode[0x11]);
            builtinTypes.Add(qname, yearMonthDurationType);
            enumToTypeCode[0x35] = yearMonthDurationType;
            qname = new XmlQualifiedName("dayTimeDuration", "http://www.w3.org/2003/11/xpath-datatypes");
            dayTimeDurationType = StartBuiltinType(qname, c_dayTimeDuration);
            c_dayTimeDuration.parentSchemaType = dayTimeDurationType;
            FinishBuiltinType(dayTimeDurationType, enumToTypeCode[0x11]);
            builtinTypes.Add(qname, dayTimeDurationType);
            enumToTypeCode[0x36] = dayTimeDurationType;
        }
Beispiel #20
0
 internal static XmlSchemaDatatype DeriveByUnion(XmlSchemaDatatype[] types)
 {
     return(DatatypeImplementation.DeriveByUnion(types));
 }
 internal Datatype_List(DatatypeImplementation type, int minListSize)
 {
     _itemType = type;
     _minListSize = minListSize;
 }
Beispiel #22
0
 private SchemaElementDecl ThoroughGetElementDecl(SchemaElementDecl elementDecl, XmlQualifiedName xsiType, string xsiNil)
 {
     if (elementDecl == null)
     {
         elementDecl = base.schemaInfo.GetElementDecl(base.elementName);
     }
     if (elementDecl != null)
     {
         if (xsiType.IsEmpty)
         {
             if (elementDecl.IsAbstract)
             {
                 base.SendValidationEvent("Sch_AbstractElement", XmlSchemaValidator.QNameString(base.context.LocalName, base.context.Namespace));
                 elementDecl = null;
             }
         }
         else if ((xsiNil != null) && xsiNil.Equals("true"))
         {
             base.SendValidationEvent("Sch_XsiNilAndType");
         }
         else
         {
             SchemaElementDecl decl;
             if (!base.schemaInfo.ElementDeclsByType.TryGetValue(xsiType, out decl) && (xsiType.Namespace == this.NsXs))
             {
                 XmlSchemaSimpleType simpleTypeFromXsdType = DatatypeImplementation.GetSimpleTypeFromXsdType(new XmlQualifiedName(xsiType.Name, this.NsXs));
                 if (simpleTypeFromXsdType != null)
                 {
                     decl = simpleTypeFromXsdType.ElementDecl;
                 }
             }
             if (decl == null)
             {
                 base.SendValidationEvent("Sch_XsiTypeNotFound", xsiType.ToString());
                 elementDecl = null;
             }
             else if (!XmlSchemaType.IsDerivedFrom(decl.SchemaType, elementDecl.SchemaType, elementDecl.Block))
             {
                 base.SendValidationEvent("Sch_XsiTypeBlockedEx", new string[] { xsiType.ToString(), XmlSchemaValidator.QNameString(base.context.LocalName, base.context.Namespace) });
                 elementDecl = null;
             }
             else
             {
                 elementDecl = decl;
             }
         }
         if ((elementDecl != null) && elementDecl.IsNillable)
         {
             if (xsiNil != null)
             {
                 base.context.IsNill = XmlConvert.ToBoolean(xsiNil);
                 if (base.context.IsNill && (elementDecl.DefaultValueTyped != null))
                 {
                     base.SendValidationEvent("Sch_XsiNilAndFixed");
                 }
             }
             return(elementDecl);
         }
         if (xsiNil != null)
         {
             base.SendValidationEvent("Sch_InvalidXsiNill");
         }
     }
     return(elementDecl);
 }
 internal bool IsUnionBaseOf(DatatypeImplementation derivedType) {
     foreach(XmlSchemaSimpleType st in types) {
         if (derivedType.IsDerivedFrom(st.Datatype)) {
             return true;
         }
     }
     return false;
 }
 internal SchemaDatatypeMap(string name, DatatypeImplementation type)
 {
     this.name = name;
     this.type = type;
 }
 internal Datatype_List(DatatypeImplementation type) : this(type, 0)
 {
 }
Beispiel #26
0
 internal static XmlSchemaDatatype FromXmlTokenizedTypeXsd(XmlTokenizedType token)
 {
     return(DatatypeImplementation.FromXmlTokenizedTypeXsd(token));
 }
 internal SchemaDatatypeMap(string name, DatatypeImplementation type) {
     this.name = name;
     this.type = type;
 }
Beispiel #28
0
 internal static XmlSchemaDatatype DeriveByUnion(XmlSchemaSimpleType[] types, XmlSchemaType schemaType)
 {
     return(DatatypeImplementation.DeriveByUnion(types, schemaType));
 }
        internal virtual RestrictionFacets ConstructRestriction(DatatypeImplementation datatype, XmlSchemaObjectCollection facets, XmlNameTable nameTable)
        {
            RestrictionFacets restriction = new RestrictionFacets();
            FacetsCompiler compiler = new FacetsCompiler(datatype, restriction);
            for (int i = 0; i < facets.Count; i++)
            {
                XmlSchemaFacet source = (XmlSchemaFacet) facets[i];
                if (source.Value == null)
                {
                    throw new XmlSchemaException("Sch_InvalidFacet", source);
                }
                IXmlNamespaceResolver nsmgr = new SchemaNamespaceManager(source);
                switch (source.FacetType)
                {
                    case FacetType.Length:
                        compiler.CompileLengthFacet(source);
                        break;

                    case FacetType.MinLength:
                        compiler.CompileMinLengthFacet(source);
                        break;

                    case FacetType.MaxLength:
                        compiler.CompileMaxLengthFacet(source);
                        break;

                    case FacetType.Pattern:
                        compiler.CompilePatternFacet(source as XmlSchemaPatternFacet);
                        break;

                    case FacetType.Whitespace:
                        compiler.CompileWhitespaceFacet(source);
                        break;

                    case FacetType.Enumeration:
                        compiler.CompileEnumerationFacet(source, nsmgr, nameTable);
                        break;

                    case FacetType.MinExclusive:
                        compiler.CompileMinExclusiveFacet(source);
                        break;

                    case FacetType.MinInclusive:
                        compiler.CompileMinInclusiveFacet(source);
                        break;

                    case FacetType.MaxExclusive:
                        compiler.CompileMaxExclusiveFacet(source);
                        break;

                    case FacetType.MaxInclusive:
                        compiler.CompileMaxInclusiveFacet(source);
                        break;

                    case FacetType.TotalDigits:
                        compiler.CompileTotalDigitsFacet(source);
                        break;

                    case FacetType.FractionDigits:
                        compiler.CompileFractionDigitsFacet(source);
                        break;

                    default:
                        throw new XmlSchemaException("Sch_UnknownFacet", source);
                }
            }
            compiler.FinishFacetCompile();
            compiler.CompileFacetCombinations();
            return restriction;
        }
 internal Datatype_List(DatatypeImplementation type, int minListSize)
 {
     this.itemType    = type;
     this.minListSize = minListSize;
 }
 internal object ParseUnion(string s, XmlNameTable nameTable, XmlNamespaceManager nsmgr, out DatatypeImplementation dtCorrect) {
     //Debug.WriteLineIf(CompModSwitches.XmlSchema.TraceVerbose, string.Format("\t\t\tSchemaDatatype_union.ParseValue(\"{0}\")", s));
     foreach(DatatypeImplementation dt in types) {
         try {
             dtCorrect = dt;
             return dtCorrect.ParseValue(s, nameTable, nsmgr);
         }
         catch(Exception){}
     }
     throw new XmlSchemaException(Res.Sch_UnionFailed);
 }
        internal static void CreateBuiltinTypes() {
            XmlQualifiedName qname;

            //Build anySimpleType
            SchemaDatatypeMap sdm = c_XsdTypes[anySimpleTypeIndex]; //anySimpleType
            qname = new XmlQualifiedName(sdm.Name, XmlReservedNs.NsXs);
            DatatypeImplementation dt = FromTypeName(qname.Name);
            anySimpleType = StartBuiltinType(qname, dt);
            dt.parentSchemaType = anySimpleType;
            builtinTypes.Add(qname, anySimpleType);

            // Start construction of each built-in Xsd type
            XmlSchemaSimpleType simpleType;
            for (int i = 0; i < c_XsdTypes.Length; i++) { //Create all types
                if (i == anySimpleTypeIndex) { //anySimpleType
                    continue;
                }
                sdm = c_XsdTypes[i];

                qname = new XmlQualifiedName(sdm.Name, XmlReservedNs.NsXs);
                dt = FromTypeName(qname.Name);
                simpleType = StartBuiltinType(qname, dt);
                dt.parentSchemaType = simpleType;

                builtinTypes.Add(qname, simpleType);
                if (dt.variety == XmlSchemaDatatypeVariety.Atomic) {
                    enumToTypeCode[(int)dt.TypeCode] = simpleType;
                }
            }

            // Finish construction of each built-in Xsd type
            for (int i = 0; i < c_XsdTypes.Length; i++) {
                if (i == anySimpleTypeIndex) { //anySimpleType
                    continue;
                }
                sdm = c_XsdTypes[i];
                XmlSchemaSimpleType derivedType = (XmlSchemaSimpleType) builtinTypes[new XmlQualifiedName(sdm.Name, XmlReservedNs.NsXs)];
                XmlSchemaSimpleType baseType;

                if (sdm.ParentIndex == anySimpleTypeIndex) {
                    FinishBuiltinType(derivedType, anySimpleType);
                }
                else { //derived types whose index > 0
                    baseType = (XmlSchemaSimpleType) builtinTypes[new XmlQualifiedName( ((SchemaDatatypeMap)(c_XsdTypes[sdm.ParentIndex])).Name, XmlReservedNs.NsXs)];
                    FinishBuiltinType(derivedType, baseType);
                }
            }

            // Construct xdt:anyAtomicType type (derived from xs:anySimpleType)
            qname = new XmlQualifiedName("anyAtomicType", XmlReservedNs.NsXQueryDataType);
            anyAtomicType = StartBuiltinType(qname, c_anyAtomicType);
            c_anyAtomicType.parentSchemaType = anyAtomicType;
            FinishBuiltinType(anyAtomicType, anySimpleType);
            builtinTypes.Add(qname, anyAtomicType);
            enumToTypeCode[(int)XmlTypeCode.AnyAtomicType] = anyAtomicType;

            // Construct xdt:untypedAtomic type (derived from xdt:anyAtomicType)
            qname = new XmlQualifiedName("untypedAtomic", XmlReservedNs.NsXQueryDataType);
            untypedAtomicType = StartBuiltinType(qname, c_untypedAtomicType);
            c_untypedAtomicType.parentSchemaType = untypedAtomicType;
            FinishBuiltinType(untypedAtomicType, anyAtomicType);
            builtinTypes.Add(qname, untypedAtomicType);
            enumToTypeCode[(int)XmlTypeCode.UntypedAtomic] = untypedAtomicType;

            // Construct xdt:yearMonthDuration type (derived from xs:duration)
            qname = new XmlQualifiedName("yearMonthDuration", XmlReservedNs.NsXQueryDataType);
            yearMonthDurationType = StartBuiltinType(qname, c_yearMonthDuration);
            c_yearMonthDuration.parentSchemaType = yearMonthDurationType;
            FinishBuiltinType(yearMonthDurationType, enumToTypeCode[(int) XmlTypeCode.Duration]);
            builtinTypes.Add(qname, yearMonthDurationType);
            enumToTypeCode[(int)XmlTypeCode.YearMonthDuration] = yearMonthDurationType;

            // Construct xdt:dayTimeDuration type (derived from xs:duration)
            qname = new XmlQualifiedName("dayTimeDuration", XmlReservedNs.NsXQueryDataType);
            dayTimeDurationType = StartBuiltinType(qname, c_dayTimeDuration);
            c_dayTimeDuration.parentSchemaType = dayTimeDurationType;
            FinishBuiltinType(dayTimeDurationType, enumToTypeCode[(int) XmlTypeCode.Duration]);
            builtinTypes.Add(qname, dayTimeDurationType);
            enumToTypeCode[(int)XmlTypeCode.DayTimeDuration] = dayTimeDurationType;
        }
Beispiel #33
0
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public static XmlSchemaSimpleType?GetBuiltInSimpleType(XmlQualifiedName qualifiedName)
        {
            ArgumentNullException.ThrowIfNull(qualifiedName);

            return(DatatypeImplementation.GetSimpleTypeFromXsdType(qualifiedName));
        }
 internal SchemaDatatypeMap(string name, DatatypeImplementation type, int parentIndex) {
     this.name = name;
     this.type = type;
     this.parentIndex = parentIndex;
 }
 private SchemaElementDecl ThoroughGetElementDecl(SchemaElementDecl elementDecl, XmlQualifiedName xsiType, string xsiNil)
 {
     if (elementDecl == null)
     {
         elementDecl = schemaInfo.GetElementDecl(elementName);
     }
     if (elementDecl != null)
     {
         if (xsiType.IsEmpty)
         {
             if (elementDecl.IsAbstract)
             {
                 SendValidationEvent(Res.Sch_AbstractElement, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace));
                 elementDecl = null;
             }
         }
         else if (xsiNil != null && xsiNil.Equals("true"))
         {
             SendValidationEvent(Res.Sch_XsiNilAndType);
         }
         else
         {
             SchemaElementDecl elementDeclXsi;
             if (!schemaInfo.ElementDeclsByType.TryGetValue(xsiType, out elementDeclXsi) && xsiType.Namespace == NsXs)
             {
                 XmlSchemaSimpleType simpleType = DatatypeImplementation.GetSimpleTypeFromXsdType(new XmlQualifiedName(xsiType.Name, NsXs));
                 if (simpleType != null)
                 {
                     elementDeclXsi = simpleType.ElementDecl;
                 }
             }
             if (elementDeclXsi == null)
             {
                 SendValidationEvent(Res.Sch_XsiTypeNotFound, xsiType.ToString());
                 elementDecl = null;
             }
             else if (!XmlSchemaType.IsDerivedFrom(elementDeclXsi.SchemaType, elementDecl.SchemaType, elementDecl.Block))
             {
                 SendValidationEvent(Res.Sch_XsiTypeBlockedEx, new string[] { xsiType.ToString(), XmlSchemaValidator.QNameString(context.LocalName, context.Namespace) });
                 elementDecl = null;
             }
             else
             {
                 elementDecl = elementDeclXsi;
             }
         }
         if (elementDecl != null && elementDecl.IsNillable)
         {
             if (xsiNil != null)
             {
                 context.IsNill = XmlConvert.ToBoolean(xsiNil);
                 if (context.IsNill && elementDecl.DefaultValueTyped != null)
                 {
                     SendValidationEvent(Res.Sch_XsiNilAndFixed);
                 }
             }
         }
         else if (xsiNil != null)
         {
             SendValidationEvent(Res.Sch_InvalidXsiNill);
         }
     }
     return(elementDecl);
 }
 internal Datatype_List(DatatypeImplementation type, int minListSize) {
     this.itemType = type;
     this.minListSize = minListSize;
 }
Beispiel #37
0
 /// <include file='doc\XmlSchemaType.uex' path='docs/doc[@for="XmlSchemaType.GetXsdSimpleType"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public static XmlSchemaSimpleType GetBuiltInSimpleType(XmlTypeCode typeCode)
 {
     return(DatatypeImplementation.GetSimpleTypeFromTypeCode(typeCode));
 }
Beispiel #38
0
        //Compile-time Facet Checking
        internal virtual RestrictionFacets ConstructRestriction(DatatypeImplementation datatype, XmlSchemaObjectCollection facets, XmlNameTable nameTable) {
            //Datatype is the type on which this method is called
            RestrictionFacets derivedRestriction = new RestrictionFacets();
            FacetsCompiler facetCompiler = new FacetsCompiler(datatype, derivedRestriction);

            for (int i = 0; i < facets.Count; ++i) {
                XmlSchemaFacet facet = (XmlSchemaFacet)facets[i];
                if (facet.Value == null) {
                    throw new XmlSchemaException(Res.Sch_InvalidFacet, facet);
                }
                IXmlNamespaceResolver nsmgr = new SchemaNamespaceManager(facet);
                switch(facet.FacetType) {
                    case FacetType.Length:
                        facetCompiler.CompileLengthFacet(facet);
                    break;

                    case FacetType.MinLength:
                        facetCompiler.CompileMinLengthFacet(facet);
                    break;

                    case FacetType.MaxLength:
                        facetCompiler.CompileMaxLengthFacet(facet);
                    break;
    
                    case FacetType.Pattern:
                        facetCompiler.CompilePatternFacet(facet as XmlSchemaPatternFacet);
                    break;

                    case FacetType.Enumeration:
                        facetCompiler.CompileEnumerationFacet(facet, nsmgr, nameTable);                        
                    break;

                    case FacetType.Whitespace:
                        facetCompiler.CompileWhitespaceFacet(facet);
                    break;

                    case FacetType.MinInclusive:
                        facetCompiler.CompileMinInclusiveFacet(facet);
                    break;

                    case FacetType.MinExclusive:
                        facetCompiler.CompileMinExclusiveFacet(facet);
                    break;

                    case FacetType.MaxInclusive:
                        facetCompiler.CompileMaxInclusiveFacet(facet);
                    break;

                    case FacetType.MaxExclusive:
                        facetCompiler.CompileMaxExclusiveFacet(facet);
                    break;

                    case FacetType.TotalDigits:
                        facetCompiler.CompileTotalDigitsFacet(facet);
                    break;

                    case FacetType.FractionDigits:
                        facetCompiler.CompileFractionDigitsFacet(facet);
                    break;

                    default:
                        throw new XmlSchemaException(Res.Sch_UnknownFacet, facet);
                }
            }
            facetCompiler.FinishFacetCompile();
            facetCompiler.CompileFacetCombinations();
            return derivedRestriction;
        }
Beispiel #39
0
        internal virtual RestrictionFacets ConstructRestriction(DatatypeImplementation datatype, XmlSchemaObjectCollection facets, XmlNameTable nameTable)
        {
            RestrictionFacets restriction = new RestrictionFacets();
            FacetsCompiler    compiler    = new FacetsCompiler(datatype, restriction);

            for (int i = 0; i < facets.Count; i++)
            {
                XmlSchemaFacet source = (XmlSchemaFacet)facets[i];
                if (source.Value == null)
                {
                    throw new XmlSchemaException("Sch_InvalidFacet", source);
                }
                IXmlNamespaceResolver nsmgr = new SchemaNamespaceManager(source);
                switch (source.FacetType)
                {
                case FacetType.Length:
                    compiler.CompileLengthFacet(source);
                    break;

                case FacetType.MinLength:
                    compiler.CompileMinLengthFacet(source);
                    break;

                case FacetType.MaxLength:
                    compiler.CompileMaxLengthFacet(source);
                    break;

                case FacetType.Pattern:
                    compiler.CompilePatternFacet(source as XmlSchemaPatternFacet);
                    break;

                case FacetType.Whitespace:
                    compiler.CompileWhitespaceFacet(source);
                    break;

                case FacetType.Enumeration:
                    compiler.CompileEnumerationFacet(source, nsmgr, nameTable);
                    break;

                case FacetType.MinExclusive:
                    compiler.CompileMinExclusiveFacet(source);
                    break;

                case FacetType.MinInclusive:
                    compiler.CompileMinInclusiveFacet(source);
                    break;

                case FacetType.MaxExclusive:
                    compiler.CompileMaxExclusiveFacet(source);
                    break;

                case FacetType.MaxInclusive:
                    compiler.CompileMaxInclusiveFacet(source);
                    break;

                case FacetType.TotalDigits:
                    compiler.CompileTotalDigitsFacet(source);
                    break;

                case FacetType.FractionDigits:
                    compiler.CompileFractionDigitsFacet(source);
                    break;

                default:
                    throw new XmlSchemaException("Sch_UnknownFacet", source);
                }
            }
            compiler.FinishFacetCompile();
            compiler.CompileFacetCombinations();
            return(restriction);
        }