internal static XmlSchemaSimpleType StartBuiltinType(XmlQualifiedName qname, XmlSchemaDatatype dataType)
        {
            XmlSchemaSimpleType type = new XmlSchemaSimpleType();

            type.SetQualifiedName(qname);
            type.SetDatatype(dataType);
            type.ElementDecl            = new SchemaElementDecl(dataType);
            type.ElementDecl.SchemaType = type;
            return(type);
        }
 private void PreprocessSimpleType(XmlSchemaSimpleType simpleType, bool local)
 {
     if (local)
     {
         if (simpleType.Name != null)
         {
             base.SendValidationEvent("Sch_ForbiddenAttribute", "name", simpleType);
         }
     }
     else
     {
         if (simpleType.Name != null)
         {
             this.ValidateNameAttribute(simpleType);
             simpleType.SetQualifiedName(new XmlQualifiedName(simpleType.Name, this.targetNamespace));
         }
         else
         {
             base.SendValidationEvent("Sch_MissRequiredAttribute", "name", simpleType);
         }
         if (simpleType.Final == XmlSchemaDerivationMethod.All)
         {
             simpleType.SetFinalResolved(XmlSchemaDerivationMethod.All);
         }
         else if (simpleType.Final == XmlSchemaDerivationMethod.None)
         {
             if (this.finalDefault == XmlSchemaDerivationMethod.All)
             {
                 simpleType.SetFinalResolved(XmlSchemaDerivationMethod.All);
             }
             else
             {
                 simpleType.SetFinalResolved(this.finalDefault & (XmlSchemaDerivationMethod.Union | XmlSchemaDerivationMethod.List | XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Extension));
             }
         }
         else
         {
             if ((simpleType.Final & ~(XmlSchemaDerivationMethod.Union | XmlSchemaDerivationMethod.List | XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Extension)) != XmlSchemaDerivationMethod.Empty)
             {
                 base.SendValidationEvent("Sch_InvalidSimpleTypeFinalValue", simpleType);
             }
             simpleType.SetFinalResolved(simpleType.Final & (XmlSchemaDerivationMethod.Union | XmlSchemaDerivationMethod.List | XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Extension));
         }
     }
     if (simpleType.Content == null)
     {
         base.SendValidationEvent("Sch_NoSimpleTypeContent", simpleType);
     }
     else if (simpleType.Content is XmlSchemaSimpleTypeRestriction)
     {
         XmlSchemaSimpleTypeRestriction content = (XmlSchemaSimpleTypeRestriction) simpleType.Content;
         this.SetParent(content, simpleType);
         for (int i = 0; i < content.Facets.Count; i++)
         {
             this.SetParent(content.Facets[i], content);
         }
         if (content.BaseType != null)
         {
             if (!content.BaseTypeName.IsEmpty)
             {
                 base.SendValidationEvent("Sch_SimpleTypeRestRefBase", content);
             }
             this.PreprocessSimpleType(content.BaseType, true);
         }
         else if (content.BaseTypeName.IsEmpty)
         {
             base.SendValidationEvent("Sch_SimpleTypeRestRefBaseNone", content);
         }
         else
         {
             this.ValidateQNameAttribute(content, "base", content.BaseTypeName);
         }
         this.PreprocessAnnotation(content);
         this.ValidateIdAttribute(content);
     }
     else if (simpleType.Content is XmlSchemaSimpleTypeList)
     {
         XmlSchemaSimpleTypeList child = (XmlSchemaSimpleTypeList) simpleType.Content;
         this.SetParent(child, simpleType);
         if (child.ItemType != null)
         {
             if (!child.ItemTypeName.IsEmpty)
             {
                 base.SendValidationEvent("Sch_SimpleTypeListRefBase", child);
             }
             this.SetParent(child.ItemType, child);
             this.PreprocessSimpleType(child.ItemType, true);
         }
         else if (child.ItemTypeName.IsEmpty)
         {
             base.SendValidationEvent("Sch_SimpleTypeListRefBaseNone", child);
         }
         else
         {
             this.ValidateQNameAttribute(child, "itemType", child.ItemTypeName);
         }
         this.PreprocessAnnotation(child);
         this.ValidateIdAttribute(child);
     }
     else
     {
         XmlSchemaSimpleTypeUnion union = (XmlSchemaSimpleTypeUnion) simpleType.Content;
         this.SetParent(union, simpleType);
         int count = union.BaseTypes.Count;
         if (union.MemberTypes != null)
         {
             count += union.MemberTypes.Length;
             XmlQualifiedName[] memberTypes = union.MemberTypes;
             for (int k = 0; k < memberTypes.Length; k++)
             {
                 this.ValidateQNameAttribute(union, "memberTypes", memberTypes[k]);
             }
         }
         if (count == 0)
         {
             base.SendValidationEvent("Sch_SimpleTypeUnionNoBase", union);
         }
         for (int j = 0; j < union.BaseTypes.Count; j++)
         {
             XmlSchemaSimpleType type = (XmlSchemaSimpleType) union.BaseTypes[j];
             this.SetParent(type, union);
             this.PreprocessSimpleType(type, true);
         }
         this.PreprocessAnnotation(union);
         this.ValidateIdAttribute(union);
     }
     this.ValidateIdAttribute(simpleType);
 }
        /// <summary>
        /// Begin the creation of an XmlSchemaSimpleType object that will be used to represent a static built-in type.
        /// Once StartBuiltinType has been called for all built-in types, FinishBuiltinType should be called in order
        /// to create links between the types.
        /// </summary>
        internal static XmlSchemaSimpleType StartBuiltinType(XmlQualifiedName qname, XmlSchemaDatatype dataType) {
            XmlSchemaSimpleType simpleType;
            Debug.Assert(qname != null && dataType != null);

            simpleType = new XmlSchemaSimpleType();
            simpleType.SetQualifiedName(qname);
            simpleType.SetDatatype(dataType);
            simpleType.ElementDecl = new SchemaElementDecl(dataType);
            simpleType.ElementDecl.SchemaType = simpleType;

            return simpleType;
        }
예제 #4
0
        private void PreprocessSimpleType(XmlSchemaSimpleType simpleType, bool local) {
            if (local) {
                if (simpleType.Name != null) {
                    SendValidationEvent(Res.Sch_ForbiddenAttribute, "name", simpleType);
                }
            }
            else {
                if (simpleType.Name != null) {
                    ValidateNameAttribute(simpleType);
                    simpleType.SetQualifiedName(new XmlQualifiedName(simpleType.Name, this.targetNamespace));
                }
                else {
                    SendValidationEvent(Res.Sch_MissRequiredAttribute, "name", simpleType);
                }

                if (simpleType.Final == XmlSchemaDerivationMethod.All) {
                    simpleType.SetFinalResolved(XmlSchemaDerivationMethod.All);
                }
                else if (simpleType.Final == XmlSchemaDerivationMethod.None) {
                    if (this.finalDefault == XmlSchemaDerivationMethod.All) {
                        simpleType.SetFinalResolved(XmlSchemaDerivationMethod.All);
                    }
                    else {
                        simpleType.SetFinalResolved(this.finalDefault & simpleTypeFinalAllowed);
                    }
                }
                else {
                    if ((simpleType.Final & ~simpleTypeFinalAllowed) != 0) {
                        SendValidationEvent(Res.Sch_InvalidSimpleTypeFinalValue, simpleType);
                    }
                    simpleType.SetFinalResolved(simpleType.Final & simpleTypeFinalAllowed);
                }
            }

            if (simpleType.Content == null) {
                SendValidationEvent(Res.Sch_NoSimpleTypeContent, simpleType);
            } 
            else if (simpleType.Content is XmlSchemaSimpleTypeRestriction) {
                XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction)simpleType.Content;
                //SetParent
                SetParent(restriction, simpleType);
                for (int i = 0; i < restriction.Facets.Count; ++i) {
                    SetParent(restriction.Facets[i], restriction);
                }

                if (restriction.BaseType != null) {
                    if (!restriction.BaseTypeName.IsEmpty) {
                        SendValidationEvent(Res.Sch_SimpleTypeRestRefBase, restriction);
                    }
                    PreprocessSimpleType(restriction.BaseType, true);
                } 
                else {
                    if (restriction.BaseTypeName.IsEmpty) {
                        SendValidationEvent(Res.Sch_SimpleTypeRestRefBaseNone, restriction);
                    }
                    else {
                        ValidateQNameAttribute(restriction, "base", restriction.BaseTypeName);
                    }
                }
                PreprocessAnnotation(restriction); //set parent of annotation child of simple type restriction
                ValidateIdAttribute(restriction);
            } 
            else if (simpleType.Content is XmlSchemaSimpleTypeList) {
                XmlSchemaSimpleTypeList list = (XmlSchemaSimpleTypeList)simpleType.Content;
                SetParent(list, simpleType);

                if (list.ItemType != null) {
                    if (!list.ItemTypeName.IsEmpty) {
                        SendValidationEvent(Res.Sch_SimpleTypeListRefBase, list);
                    }
                    SetParent(list.ItemType, list);
                    PreprocessSimpleType(list.ItemType, true);
                } 
                else {
                    if (list.ItemTypeName.IsEmpty) {
                        SendValidationEvent(Res.Sch_SimpleTypeListRefBaseNone, list);
                    }
                    else {
                        ValidateQNameAttribute(list, "itemType", list.ItemTypeName);
                    }
                }
                PreprocessAnnotation(list); //set parent of annotation child of simple type list
                ValidateIdAttribute(list);
            } 
            else { // union
                XmlSchemaSimpleTypeUnion union1 = (XmlSchemaSimpleTypeUnion)simpleType.Content;
                SetParent(union1, simpleType);

                int baseTypeCount = union1.BaseTypes.Count;
                if (union1.MemberTypes != null) {
                    baseTypeCount += union1.MemberTypes.Length;
                    XmlQualifiedName[] qNames = union1.MemberTypes;
                    for (int i = 0; i < qNames.Length; ++i) {
                        ValidateQNameAttribute(union1, "memberTypes", qNames[i]);
                    }
                }
                if (baseTypeCount == 0) {
                    SendValidationEvent(Res.Sch_SimpleTypeUnionNoBase, union1);
                }
                for (int i = 0; i < union1.BaseTypes.Count; ++i) {
                    XmlSchemaSimpleType type = (XmlSchemaSimpleType)union1.BaseTypes[i];
                    SetParent(type, union1);
                    PreprocessSimpleType(type, true);
                }
                PreprocessAnnotation(union1); //set parent of annotation child of simple type union
                ValidateIdAttribute(union1);
            }
            ValidateIdAttribute(simpleType);
        }
예제 #5
0
파일: compiler.cs 프로젝트: ArildF/masters
        private void PreprocessSimpleType(XmlSchemaSimpleType simpleType, bool local) {
            if (local) {
                if (simpleType.Name != null) {
                    SendValidationEvent(Res.Sch_ForbiddenAttribute, "name", simpleType);
                }
            }
            else {
                if (simpleType.Name != null) {
                    ValidateNameAttribute(simpleType);
                    simpleType.SetQualifiedName(new XmlQualifiedName(simpleType.Name, this.targetNamespace));
                }
                else {
                    SendValidationEvent(Res.Sch_MissRequiredAttribute, "name", simpleType);
                }

                if (simpleType.Final == XmlSchemaDerivationMethod.All) {
                    simpleType.SetFinalResolved(XmlSchemaDerivationMethod.All);
                }
                else if (simpleType.Final == XmlSchemaDerivationMethod.None) {
                    if (this.finalDefault == XmlSchemaDerivationMethod.All) {
                        simpleType.SetFinalResolved(XmlSchemaDerivationMethod.All);
                    }
                    else {
                        simpleType.SetFinalResolved(this.finalDefault & simpleTypeFinalAllowed);
                    }
                }
                else {
                    if ((simpleType.Final & ~simpleTypeFinalAllowed) != 0) {
                        SendValidationEvent(Res.Sch_InvalidSimpleTypeFinalValue, simpleType);
                    }
                    simpleType.SetFinalResolved(simpleType.Final & simpleTypeFinalAllowed);
                }
            }

            if (simpleType.Content == null) {
                SendValidationEvent(Res.Sch_NoSimpleTypeContent, simpleType);
            } 
            else if (simpleType.Content is XmlSchemaSimpleTypeRestriction) {
                XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction)simpleType.Content;
                if (restriction.BaseType != null) {
                    if (!restriction.BaseTypeName.IsEmpty) {
                        SendValidationEvent(Res.Sch_SimpleTypeRestRefBase, restriction);
                    }
                    PreprocessSimpleType(restriction.BaseType, true);
                } 
                else {
                    if (restriction.BaseTypeName.IsEmpty) {
                        SendValidationEvent(Res.Sch_SimpleTypeRestRefBase, restriction);
                    }
                    else {
                        ValidateQNameAttribute(restriction, "base", restriction.BaseTypeName);
                    }
                }
                ValidateIdAttribute(restriction);
            } 
            else if (simpleType.Content is XmlSchemaSimpleTypeList) {
                XmlSchemaSimpleTypeList list = (XmlSchemaSimpleTypeList)simpleType.Content;
                if (list.ItemType != null) {
                    if (!list.ItemTypeName.IsEmpty) {
                        SendValidationEvent(Res.Sch_SimpleTypeListRefBase, list);
                    }
                    PreprocessSimpleType(list.ItemType, true);
                } 
                else {
                    if (list.ItemTypeName.IsEmpty) {
                        SendValidationEvent(Res.Sch_SimpleTypeListRefBase, list);
                    }
                    else {
                        ValidateQNameAttribute(list, "itemType", list.ItemTypeName);
                    }
                }
                ValidateIdAttribute(list);
            } 
            else { // union
                XmlSchemaSimpleTypeUnion union1 = (XmlSchemaSimpleTypeUnion)simpleType.Content;
                int baseTypeCount = union1.BaseTypes.Count;
                if (union1.MemberTypes != null) {
                    baseTypeCount += union1.MemberTypes.Length;
                    foreach(XmlQualifiedName qname in union1.MemberTypes) {
                        ValidateQNameAttribute(union1, "memberTypes", qname);
                    }
                }
                if (baseTypeCount == 0) {
                    SendValidationEvent(Res.Sch_SimpleTypeUnionNoBase, union1);
                }
                foreach(XmlSchemaSimpleType type in union1.BaseTypes) {
                    PreprocessSimpleType(type, true);
                }
                ValidateIdAttribute(union1);
            }
            ValidateIdAttribute(simpleType);
        }
 internal static XmlSchemaSimpleType StartBuiltinType(XmlQualifiedName qname, XmlSchemaDatatype dataType)
 {
     XmlSchemaSimpleType type = new XmlSchemaSimpleType();
     type.SetQualifiedName(qname);
     type.SetDatatype(dataType);
     type.ElementDecl = new SchemaElementDecl(dataType);
     type.ElementDecl.SchemaType = type;
     return type;
 }