Esempio n. 1
0
        internal override int Validate(ValidationEventHandler h, XmlSchema schema)
        {
            if (IsValidated(schema.ValidationId))
            {
                return(errorCount);
            }

            // ListItemType
            XmlSchemaSimpleType type = itemType;

            if (type == null)
            {
                type = schema.FindSchemaType(itemTypeName) as XmlSchemaSimpleType;
            }
            if (type != null)
            {
                errorCount           += type.Validate(h, schema);
                validatedListItemType = type;
            }
            else if (itemTypeName == XmlSchemaComplexType.AnyTypeName)
            {
                validatedListItemType = XmlSchemaSimpleType.AnySimpleType;
            }
            else if (XmlSchemaUtil.IsBuiltInDatatypeName(itemTypeName))
            {
                validatedListItemType = XmlSchemaDatatype.FromName(itemTypeName);
                if (validatedListItemType == null)
                {
                    error(h, "Invalid schema type name was specified: " + itemTypeName);
                }
            }
            // otherwise, it might be missing sub components.
            else if (!schema.IsNamespaceAbsent(itemTypeName.Namespace))
            {
                error(h, "Referenced base list item schema type " + itemTypeName + " was not found.");
            }

#if NET_2_0
            XmlSchemaSimpleType st = validatedListItemType as XmlSchemaSimpleType;
            if (st == null && validatedListItemType != null)
            {
                st = XmlSchemaType.GetBuiltInSimpleType(((XmlSchemaDatatype)validatedListItemType).TypeCode);
            }
            validatedListItemSchemaType = st;
#endif

            ValidationId = schema.ValidationId;
            return(errorCount);
        }
Esempio n. 2
0
        internal override int Validate(ValidationEventHandler h, XmlSchema schema)
        {
            if (base.IsValidated(schema.ValidationId))
            {
                return(this.errorCount);
            }
            XmlSchemaSimpleType xmlSchemaSimpleType = this.itemType;

            if (xmlSchemaSimpleType == null)
            {
                xmlSchemaSimpleType = (schema.FindSchemaType(this.itemTypeName) as XmlSchemaSimpleType);
            }
            if (xmlSchemaSimpleType != null)
            {
                this.errorCount           += xmlSchemaSimpleType.Validate(h, schema);
                this.validatedListItemType = xmlSchemaSimpleType;
            }
            else if (this.itemTypeName == XmlSchemaComplexType.AnyTypeName)
            {
                this.validatedListItemType = XmlSchemaSimpleType.AnySimpleType;
            }
            else if (XmlSchemaUtil.IsBuiltInDatatypeName(this.itemTypeName))
            {
                this.validatedListItemType = XmlSchemaDatatype.FromName(this.itemTypeName);
                if (this.validatedListItemType == null)
                {
                    base.error(h, "Invalid schema type name was specified: " + this.itemTypeName);
                }
            }
            else if (!schema.IsNamespaceAbsent(this.itemTypeName.Namespace))
            {
                base.error(h, "Referenced base list item schema type " + this.itemTypeName + " was not found.");
            }
            XmlSchemaSimpleType xmlSchemaSimpleType2 = this.validatedListItemType as XmlSchemaSimpleType;

            if (xmlSchemaSimpleType2 == null && this.validatedListItemType != null)
            {
                xmlSchemaSimpleType2 = XmlSchemaType.GetBuiltInSimpleType(((XmlSchemaDatatype)this.validatedListItemType).TypeCode);
            }
            this.validatedListItemSchemaType = xmlSchemaSimpleType2;
            this.ValidationId = schema.ValidationId;
            return(this.errorCount);
        }
        internal override int Validate(ValidationEventHandler h, XmlSchema schema)
        {
            if (IsValidated(schema.ValidationId))
            {
                return(errorCount);
            }

            if (baseType != null)
            {
                baseType.Validate(h, schema);
                actualBaseSchemaType = baseType;
            }
            else if (baseTypeName != XmlQualifiedName.Empty)
            {
                XmlSchemaType st = schema.FindSchemaType(baseTypeName);
                if (st != null)
                {
                    st.Validate(h, schema);
                    actualBaseSchemaType = st;
                }
                else if (baseTypeName == XmlSchemaComplexType.AnyTypeName)
                {
                    actualBaseSchemaType = XmlSchemaComplexType.AnyType;
                }
                else if (XmlSchemaUtil.IsBuiltInDatatypeName(baseTypeName))
                {
                    actualBaseSchemaType = XmlSchemaDatatype.FromName(baseTypeName);
                    if (actualBaseSchemaType == null)
                    {
                        error(h, "Invalid schema datatype name is specified.");
                    }
                }
                // otherwise, it might be missing sub components.
                else if (!schema.IsNamespaceAbsent(baseTypeName.Namespace))
                {
                    error(h, "Referenced base schema type " + baseTypeName + " was not found in the corresponding schema.");
                }
            }

            ValidationId = schema.ValidationId;
            return(errorCount);
        }
        internal override int Validate(ValidationEventHandler h, XmlSchema schema)
        {
            if (base.IsValidated(schema.ValidationId))
            {
                return(this.errorCount);
            }
            ArrayList arrayList = new ArrayList();

            if (this.MemberTypes != null)
            {
                foreach (XmlQualifiedName xmlQualifiedName in this.MemberTypes)
                {
                    object        obj           = null;
                    XmlSchemaType xmlSchemaType = schema.FindSchemaType(xmlQualifiedName) as XmlSchemaSimpleType;
                    if (xmlSchemaType != null)
                    {
                        this.errorCount += xmlSchemaType.Validate(h, schema);
                        obj              = xmlSchemaType;
                    }
                    else if (xmlQualifiedName == XmlSchemaComplexType.AnyTypeName)
                    {
                        obj = XmlSchemaSimpleType.AnySimpleType;
                    }
                    else if (xmlQualifiedName.Namespace == "http://www.w3.org/2001/XMLSchema" || xmlQualifiedName.Namespace == "http://www.w3.org/2003/11/xpath-datatypes")
                    {
                        obj = XmlSchemaDatatype.FromName(xmlQualifiedName);
                        if (obj == null)
                        {
                            base.error(h, "Invalid schema type name was specified: " + xmlQualifiedName);
                        }
                    }
                    else if (!schema.IsNamespaceAbsent(xmlQualifiedName.Namespace))
                    {
                        base.error(h, "Referenced base schema type " + xmlQualifiedName + " was not found in the corresponding schema.");
                    }
                    arrayList.Add(obj);
                }
            }
            if (this.BaseTypes != null)
            {
                foreach (XmlSchemaObject xmlSchemaObject in this.BaseTypes)
                {
                    XmlSchemaSimpleType xmlSchemaSimpleType = (XmlSchemaSimpleType)xmlSchemaObject;
                    xmlSchemaSimpleType.Validate(h, schema);
                    arrayList.Add(xmlSchemaSimpleType);
                }
            }
            this.validatedTypes = arrayList.ToArray();
            if (this.validatedTypes != null)
            {
                this.validatedSchemaTypes = new XmlSchemaSimpleType[this.validatedTypes.Length];
                for (int j = 0; j < this.validatedTypes.Length; j++)
                {
                    object obj2 = this.validatedTypes[j];
                    XmlSchemaSimpleType xmlSchemaSimpleType2 = obj2 as XmlSchemaSimpleType;
                    if (xmlSchemaSimpleType2 == null && obj2 != null)
                    {
                        xmlSchemaSimpleType2 = XmlSchemaType.GetBuiltInSimpleType(((XmlSchemaDatatype)obj2).TypeCode);
                    }
                    this.validatedSchemaTypes[j] = xmlSchemaSimpleType2;
                }
            }
            this.ValidationId = schema.ValidationId;
            return(this.errorCount);
        }