当前位置: 首页>>代码示例>>C#>>正文


C# XmlSchemaElement.SetElementType方法代码示例

本文整理汇总了C#中System.Xml.Schema.XmlSchemaElement.SetElementType方法的典型用法代码示例。如果您正苦于以下问题:C# XmlSchemaElement.SetElementType方法的具体用法?C# XmlSchemaElement.SetElementType怎么用?C# XmlSchemaElement.SetElementType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.Schema.XmlSchemaElement的用法示例。


在下文中一共展示了XmlSchemaElement.SetElementType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CompileElement

        private void CompileElement(XmlSchemaElement xe) {
            if (xe.IsProcessing) {
                SendValidationEvent(Res.Sch_ElementCircularRef, xe);
                return;
            }
            if (xe.ElementDecl != null) {
                return;
            }
            xe.IsProcessing = true;
            SchemaElementDecl decl = null;
            try {
                if (!xe.RefName.IsEmpty) {
                    XmlSchemaElement e = (XmlSchemaElement)elements[xe.RefName];
                    if (e == null) {
                        throw new XmlSchemaException(Res.Sch_UndeclaredElement, xe.RefName.ToString(), xe);
                    }  
                    CompileElement(e);
                    if (e.ElementDecl == null) {
                        throw new XmlSchemaException(Res.Sch_RefInvalidElement, xe.RefName.ToString(), xe);
                    }
                    xe.SetElementType(e.ElementSchemaType);
                    decl = e.ElementDecl.Clone();
                }
                else {
                    if (xe.SchemaType != null) {
                        xe.SetElementType(xe.SchemaType);
                    }
                    else if (!xe.SchemaTypeName.IsEmpty) {
                        xe.SetElementType(GetAnySchemaType(xe.SchemaTypeName));
                        if (xe.ElementSchemaType == null) {
                            throw new XmlSchemaException(Res.Sch_UndeclaredType, xe.SchemaTypeName.ToString(), xe);   
                        }
                    }
                    else  if (!xe.SubstitutionGroup.IsEmpty) {
                        XmlSchemaElement examplar = (XmlSchemaElement)elements[xe.SubstitutionGroup];
                        if (examplar == null) {
                            throw new XmlSchemaException(Res.Sch_UndeclaredEquivClass, xe.SubstitutionGroup.Name.ToString(CultureInfo.InvariantCulture), xe);   
                        }
                        if (examplar.IsProcessing) { //Circular subst group; already detected by now
                            return;
                        }
                        CompileElement(examplar);
                        if (examplar.ElementDecl == null) { //If head is invalid, fall back to AnyType
                            xe.SetElementType(XmlSchemaComplexType.AnyType);
                            decl = XmlSchemaComplexType.AnyType.ElementDecl.Clone();
                        }
                        else {
                            xe.SetElementType(examplar.ElementSchemaType);
                            decl = examplar.ElementDecl.Clone();
                        }
                    }
                    else {
                        xe.SetElementType(XmlSchemaComplexType.AnyType);
                        decl = XmlSchemaComplexType.AnyType.ElementDecl.Clone();
                    }
            
                    if (decl == null) {
                        Debug.Assert(xe.ElementSchemaType != null);
                        if (xe.ElementSchemaType is XmlSchemaComplexType) {
                            XmlSchemaComplexType complexType = (XmlSchemaComplexType)xe.ElementSchemaType;
                            CompileComplexType(complexType);
                            if (complexType.ElementDecl != null) {
                                decl = complexType.ElementDecl.Clone();
//                                decl.LocalElements = complexType.LocalElementDecls;
                            }
                        } 
                        else if (xe.ElementSchemaType is XmlSchemaSimpleType) {
                            XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType)xe.ElementSchemaType;
                            CompileSimpleType(simpleType);
                            if (simpleType.ElementDecl != null) {
                                decl = simpleType.ElementDecl.Clone();
                            }
                        } 
                    }
                    Debug.Assert(decl != null);
                    decl.Name = xe.QualifiedName;
                    decl.IsAbstract = xe.IsAbstract;
                    XmlSchemaComplexType ct = xe.ElementSchemaType as XmlSchemaComplexType;
                    if (ct != null) {
                        decl.IsAbstract |= ct.IsAbstract; 
                    }
                    decl.IsNillable = xe.IsNillable;
                    decl.Block |= xe.BlockResolved;
                }
                if (decl.Datatype != null) {
                    decl.Datatype.VerifySchemaValid(notations, xe);
                }

                if (xe.DefaultValue != null || xe.FixedValue != null) {
                    if (decl.ContentValidator != null) {
                        if (decl.ContentValidator.ContentType == XmlSchemaContentType.TextOnly || (decl.ContentValidator.ContentType == XmlSchemaContentType.Mixed && decl.ContentValidator.IsEmptiable)) {
                            if (xe.DefaultValue != null) {
                                decl.Presence = SchemaDeclBase.Use.Default; 
                                decl.DefaultValueRaw = xe.DefaultValue;
                            }
                            else {
                                decl.Presence = SchemaDeclBase.Use.Fixed; 
                                decl.DefaultValueRaw = xe.FixedValue;
                            }
                            if (decl.Datatype != null) {
//.........这里部分代码省略.........
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:101,代码来源:SchemaSetCompiler.cs

示例2: CompileElement

 private void CompileElement(XmlSchemaElement xe)
 {
     if (xe.IsProcessing)
     {
         base.SendValidationEvent("Sch_ElementCircularRef", xe);
     }
     else if (xe.ElementDecl == null)
     {
         xe.IsProcessing = true;
         SchemaElementDecl decl = null;
         try
         {
             if (!xe.RefName.IsEmpty)
             {
                 XmlSchemaElement element = (XmlSchemaElement) this.schema.Elements[xe.RefName];
                 if (element == null)
                 {
                     throw new XmlSchemaException("Sch_UndeclaredElement", xe.RefName.ToString(), xe);
                 }
                 this.CompileElement(element);
                 if (element.ElementDecl == null)
                 {
                     throw new XmlSchemaException("Sch_RefInvalidElement", xe.RefName.ToString(), xe);
                 }
                 xe.SetElementType(element.ElementSchemaType);
                 decl = element.ElementDecl.Clone();
             }
             else
             {
                 if (xe.SchemaType != null)
                 {
                     xe.SetElementType(xe.SchemaType);
                 }
                 else if (!xe.SchemaTypeName.IsEmpty)
                 {
                     xe.SetElementType(this.GetAnySchemaType(xe.SchemaTypeName));
                     if (xe.ElementSchemaType == null)
                     {
                         throw new XmlSchemaException("Sch_UndeclaredType", xe.SchemaTypeName.ToString(), xe);
                     }
                 }
                 else if (!xe.SubstitutionGroup.IsEmpty)
                 {
                     XmlSchemaElement element2 = (XmlSchemaElement) this.schema.Elements[xe.SubstitutionGroup];
                     if (element2 == null)
                     {
                         throw new XmlSchemaException("Sch_UndeclaredEquivClass", xe.SubstitutionGroup.Name.ToString(CultureInfo.InvariantCulture), xe);
                     }
                     if (element2.IsProcessing)
                     {
                         return;
                     }
                     this.CompileElement(element2);
                     if (element2.ElementDecl == null)
                     {
                         xe.SetElementType(XmlSchemaComplexType.AnyType);
                         decl = XmlSchemaComplexType.AnyType.ElementDecl.Clone();
                     }
                     else
                     {
                         xe.SetElementType(element2.ElementSchemaType);
                         decl = element2.ElementDecl.Clone();
                     }
                 }
                 else
                 {
                     xe.SetElementType(XmlSchemaComplexType.AnyType);
                     decl = XmlSchemaComplexType.AnyType.ElementDecl.Clone();
                 }
                 if (decl == null)
                 {
                     if (xe.ElementSchemaType is XmlSchemaComplexType)
                     {
                         XmlSchemaComplexType complexType = (XmlSchemaComplexType) xe.ElementSchemaType;
                         this.CompileComplexType(complexType);
                         if (complexType.ElementDecl != null)
                         {
                             decl = complexType.ElementDecl.Clone();
                         }
                     }
                     else if (xe.ElementSchemaType is XmlSchemaSimpleType)
                     {
                         XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType) xe.ElementSchemaType;
                         this.CompileSimpleType(simpleType);
                         if (simpleType.ElementDecl != null)
                         {
                             decl = simpleType.ElementDecl.Clone();
                         }
                     }
                 }
                 decl.Name = xe.QualifiedName;
                 decl.IsAbstract = xe.IsAbstract;
                 XmlSchemaComplexType elementSchemaType = xe.ElementSchemaType as XmlSchemaComplexType;
                 if (elementSchemaType != null)
                 {
                     decl.IsAbstract |= elementSchemaType.IsAbstract;
                 }
                 decl.IsNillable = xe.IsNillable;
                 decl.Block |= xe.BlockResolved;
             }
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:SchemaCollectionCompiler.cs

示例3: CompileElement

        private void CompileElement(XmlSchemaElement xe) {
            if (xe.Validating) {
                SendValidationEvent(Res.Sch_ElementCircularRef, xe);
                return;
            }
            if (xe.ElementDecl != null) {
                return;
            }
            xe.Validating = true;
            SchemaElementDecl decl = null;
            try {
                if (!xe.RefName.IsEmpty) {
                    XmlSchemaElement e = (XmlSchemaElement)this.schema.Elements[xe.RefName];
                    if (e == null) {
                        throw new XmlSchemaException(Res.Sch_UndeclaredElement, xe.RefName.ToString(), xe);
                    }  
                    CompileElement(e);
                    if (e.ElementDecl == null) {
                        throw new XmlSchemaException(Res.Sch_RefInvalidElement, xe.RefName.ToString(), xe);
                    }
                    xe.SetElementType(e.ElementType);
                    decl = e.ElementDecl.Clone();
                }
                else {
                    if (xe.SchemaType != null) {
                        xe.SetElementType(xe.SchemaType);
                    }
                    else if (!xe.SchemaTypeName.IsEmpty) {
                        XmlSchemaDatatype datatype;
                        xe.SetElementType(GetAnySchemaType(xe.SchemaTypeName, out datatype));
                        if (xe.ElementType == null) {
                            throw new XmlSchemaException(Res.Sch_UndeclaredType, xe.SchemaTypeName.ToString(), xe);   
                        }
                    }
                    else  if (!xe.SubstitutionGroup.IsEmpty) {
                        XmlSchemaElement examplar = (XmlSchemaElement)this.schema.Elements[xe.SubstitutionGroup];
                        if (examplar == null) {
                            throw new XmlSchemaException(Res.Sch_UndeclaredEquivClass, xe.SubstitutionGroup.Name.ToString(), xe);   
                        }
                        CompileElement(examplar);
                        xe.SetElementType(examplar.ElementType);
                        decl = examplar.ElementDecl.Clone();
                    }
                    else {
                        xe.SetElementType(XmlSchemaDatatype.AnyType);
                        decl = SchemaElementDecl.CreateAnyTypeElementDecl();
                    }
            
                    if (decl == null) {
                        Debug.Assert(xe.ElementType != null);
                        if (xe.ElementType is XmlSchemaComplexType) {
                            XmlSchemaComplexType complexType = (XmlSchemaComplexType)xe.ElementType;
                            CompileComplexType(complexType);
                            if (complexType.ElementDecl != null) {
                                decl = complexType.ElementDecl.Clone();
                                decl.LocalElements = complexType.LocalElementDecls;
                            }
                        } 
                        else if (xe.ElementType is XmlSchemaSimpleType) {
                            XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType)xe.ElementType;
                            CompileSimpleType(simpleType);
                            if (simpleType.ElementDecl != null) {
                                decl = simpleType.ElementDecl.Clone();
                            }
                        } 
                        else {
                            decl = new SchemaElementDecl((XmlSchemaDatatype)xe.ElementType, this.schemaNames);
                        }
                    }
                    decl.Name = xe.QualifiedName;
                    decl.IsAbstract = xe.IsAbstract;
                    XmlSchemaComplexType ct = xe.ElementType as XmlSchemaComplexType;
                    if (ct != null) {
                        decl.IsAbstract |= ct.IsAbstract; 
                    }
                    decl.IsNillable = xe.IsNillable;
                    decl.Block |= xe.BlockResolved;
                }
                if (decl.Datatype != null) {
                    decl.Datatype.VerifySchemaValid(this.schema, xe);
                }

                if (xe.DefaultValue != null || xe.FixedValue != null) {
                    if (decl.Content.ContentType == CompiledContentModel.Type.Text) {
                        if (xe.DefaultValue != null) {
                            decl.Presence = SchemaDeclBase.Use.Default; 
                            decl.DefaultValueTyped = decl.Datatype.ParseValue(xe.DefaultValue, this.nameTable, this.namespaceManager);
                        }
                        else {
                            decl.Presence = SchemaDeclBase.Use.Fixed; 
                            decl.DefaultValueTyped = decl.Datatype.ParseValue(xe.FixedValue, this.nameTable, this.namespaceManager);
                        }
                    }
                    else if (decl.Content.ContentType != CompiledContentModel.Type.Mixed || !decl.Content.IsEmptiable) {
                        throw new XmlSchemaException(Res.Sch_ElementCannotHaveValue, xe);
                    }            
                }
                if (xe.HasConstraints) {
                    XmlSchemaObjectCollection constraints = xe.Constraints;
                    CompiledIdentityConstraint[] compiledConstraints = new CompiledIdentityConstraint[constraints.Count];
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:compiler.cs


注:本文中的System.Xml.Schema.XmlSchemaElement.SetElementType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。