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


C# XmlSchemaInfo.Clear方法代码示例

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


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

示例1: ValidateAttribute

        private object ValidateAttribute(string lName, string ns, XmlValueGetter attributeValueGetter, string attributeStringValue, XmlSchemaInfo schemaInfo)
        {
            if (lName == null)
            {
                throw new ArgumentNullException("localName");
            }
            if (ns == null)
            {
                throw new ArgumentNullException("namespaceUri");
            }
            ValidatorState toState = (this.validationStack.Length > 1) ? ValidatorState.Attribute : ValidatorState.TopLevelAttribute;
            this.CheckStateTransition(toState, MethodNames[(int) toState]);
            object typedValue = null;
            this.attrValid = true;
            XmlSchemaValidity notKnown = XmlSchemaValidity.NotKnown;
            XmlSchemaAttribute schemaAttribute = null;
            XmlSchemaSimpleType xmlType = null;
            ns = this.nameTable.Add(ns);
            if (Ref.Equal(ns, this.NsXmlNs))
            {
                return null;
            }
            SchemaAttDef def = null;
            SchemaElementDecl elementDecl = this.context.ElementDecl;
            XmlQualifiedName key = new XmlQualifiedName(lName, ns);
            if (this.attPresence[key] != null)
            {
                this.SendValidationEvent("Sch_DuplicateAttribute", key.ToString());
                if (schemaInfo != null)
                {
                    schemaInfo.Clear();
                }
                return null;
            }
            if (Ref.Equal(ns, this.NsXsi))
            {
                lName = this.nameTable.Add(lName);
                if ((Ref.Equal(lName, this.xsiTypeString) || Ref.Equal(lName, this.xsiNilString)) || (Ref.Equal(lName, this.xsiSchemaLocationString) || Ref.Equal(lName, this.xsiNoNamespaceSchemaLocationString)))
                {
                    this.attPresence.Add(key, SchemaAttDef.Empty);
                }
                else
                {
                    this.attrValid = false;
                    this.SendValidationEvent("Sch_NotXsiAttribute", key.ToString());
                }
            }
            else
            {
                AttributeMatchState state2;
                object obj4;
                XmlSchemaObject partialValidationType = (this.currentState == ValidatorState.TopLevelAttribute) ? this.partialValidationType : null;
                def = this.compiledSchemaInfo.GetAttributeXsd(elementDecl, key, partialValidationType, out state2);
                switch (state2)
                {
                    case AttributeMatchState.AttributeFound:
                        break;

                    case AttributeMatchState.AnyIdAttributeFound:
                        if (this.wildID != null)
                        {
                            this.SendValidationEvent("Sch_MoreThanOneWildId", string.Empty);
                        }
                        else
                        {
                            this.wildID = def;
                            XmlSchemaComplexType schemaType = elementDecl.SchemaType as XmlSchemaComplexType;
                            if (!schemaType.ContainsIdAttribute(false))
                            {
                                break;
                            }
                            this.SendValidationEvent("Sch_AttrUseAndWildId", string.Empty);
                        }
                        goto Label_0409;

                    case AttributeMatchState.UndeclaredElementAndAttribute:
                        def = this.CheckIsXmlAttribute(key);
                        if (def != null)
                        {
                            break;
                        }
                        if (((elementDecl != null) || (this.processContents != XmlSchemaContentProcessing.Strict)) || ((key.Namespace.Length == 0) || !this.compiledSchemaInfo.Contains(key.Namespace)))
                        {
                            if (this.processContents != XmlSchemaContentProcessing.Skip)
                            {
                                this.SendValidationEvent("Sch_NoAttributeSchemaFound", key.ToString(), XmlSeverityType.Warning);
                            }
                        }
                        else
                        {
                            this.attrValid = false;
                            this.SendValidationEvent("Sch_UndeclaredAttribute", key.ToString());
                        }
                        goto Label_0409;

                    case AttributeMatchState.UndeclaredAttribute:
                        def = this.CheckIsXmlAttribute(key);
                        if (def != null)
                        {
                            break;
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:XmlSchemaValidator.cs

示例2: ValidateAttribute

        private object ValidateAttribute(string lName, string ns, XmlValueGetter attributeValueGetter, string attributeStringValue, XmlSchemaInfo schemaInfo) {
            if (lName == null) {
                throw new ArgumentNullException("localName");
            }
            if (ns == null) {
                throw new ArgumentNullException("namespaceUri");
            }

            ValidatorState toState = validationStack.Length > 1 ? ValidatorState.Attribute : ValidatorState.TopLevelAttribute;
            CheckStateTransition(toState, MethodNames[(int)toState]);

            object typedVal = null;
            attrValid = true;
            XmlSchemaValidity localValidity = XmlSchemaValidity.NotKnown;
            XmlSchemaAttribute localAttribute = null;
            XmlSchemaSimpleType localMemberType = null;

            ns = nameTable.Add(ns);
            if(Ref.Equal(ns,NsXmlNs)) {
                return null;
            }

            SchemaAttDef attributeDef = null;
            SchemaElementDecl currentElementDecl = context.ElementDecl;
            XmlQualifiedName attQName = new XmlQualifiedName(lName, ns);
            if (attPresence[attQName] != null) { //this attribute already checked as it is duplicate;
                SendValidationEvent(Res.Sch_DuplicateAttribute, attQName.ToString());
                if (schemaInfo != null) {
                    schemaInfo.Clear();
                }
                return null;
            }

            if (!Ref.Equal(ns,NsXsi)) { //
                XmlSchemaObject pvtAttribute = currentState == ValidatorState.TopLevelAttribute ? partialValidationType : null;
                AttributeMatchState attributeMatchState;
                attributeDef = compiledSchemaInfo.GetAttributeXsd(currentElementDecl, attQName, pvtAttribute, out attributeMatchState);

                switch (attributeMatchState) {
                    case AttributeMatchState.UndeclaredElementAndAttribute:
                        if((attributeDef = CheckIsXmlAttribute(attQName)) != null) { //Try for xml attribute
                            goto case AttributeMatchState.AttributeFound;
                        }
                        if (currentElementDecl == null
                            && processContents == XmlSchemaContentProcessing.Strict
                            && attQName.Namespace.Length != 0
                            && compiledSchemaInfo.Contains(attQName.Namespace)
                        ) {
                            attrValid = false;
                            SendValidationEvent(Res.Sch_UndeclaredAttribute, attQName.ToString());
                        }
                        else if (processContents != XmlSchemaContentProcessing.Skip) {
                            SendValidationEvent(Res.Sch_NoAttributeSchemaFound, attQName.ToString(), XmlSeverityType.Warning);
                        }
                        break;

                    case AttributeMatchState.UndeclaredAttribute:
                        if((attributeDef = CheckIsXmlAttribute(attQName)) != null) {
                            goto case AttributeMatchState.AttributeFound;
                        }
                        else {
                            attrValid = false;
                            SendValidationEvent(Res.Sch_UndeclaredAttribute, attQName.ToString());
                        }
                        break;

                    case AttributeMatchState.ProhibitedAnyAttribute:
                        if((attributeDef = CheckIsXmlAttribute(attQName)) != null) {
                            goto case AttributeMatchState.AttributeFound;
                        }
                        else {
                            attrValid = false;
                            SendValidationEvent(Res.Sch_ProhibitedAttribute, attQName.ToString());
                        }
                        break;

                    case AttributeMatchState.ProhibitedAttribute:
                        attrValid = false;
                        SendValidationEvent(Res.Sch_ProhibitedAttribute, attQName.ToString());
                        break;

                    case AttributeMatchState.AttributeNameMismatch:
                        attrValid = false;
                        SendValidationEvent(Res.Sch_SchemaAttributeNameMismatch, new string[] { attQName.ToString(), ((XmlSchemaAttribute)pvtAttribute).QualifiedName.ToString()});
                        break;

                    case AttributeMatchState.ValidateAttributeInvalidCall:
                        Debug.Assert(currentState == ValidatorState.TopLevelAttribute); //Re-set state back to start on error with partial validation type
                        currentState = ValidatorState.Start;
                        attrValid = false;
                        SendValidationEvent(Res.Sch_ValidateAttributeInvalidCall, string.Empty);
                        break;

                    case AttributeMatchState.AnyIdAttributeFound:
                        if (wildID == null) {
                            wildID = attributeDef;
                            Debug.Assert(currentElementDecl != null);
                            XmlSchemaComplexType ct = currentElementDecl.SchemaType as XmlSchemaComplexType;
                            Debug.Assert(ct != null);
                            if (ct.ContainsIdAttribute(false)) {
//.........这里部分代码省略.........
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:101,代码来源:XmlSchemaValidator.cs


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