• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Schema.XmlSchemaInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



XmlSchemaInfo类属于System.Xml.Schema命名空间,在下文中一共展示了XmlSchemaInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: WhitespaceInsideElement

        public void WhitespaceInsideElement()
        {
            XmlSchemaValidator val = CreateValidator(XSDFILE_VALIDATE_TEXT);
            CValidationEventHolder holder = new CValidationEventHolder();
            XmlSchemaInfo info = new XmlSchemaInfo();

            val.ValidationEventHandler += new ValidationEventHandler(holder.CallbackA);

            val.Initialize();
            val.ValidateElement("ElementOnlyElement", "", info);
            val.ValidateEndOfAttributes(null);

            val.ValidateWhitespace(" \t\r\n");

            val.ValidateElement("child", "", info);
            val.ValidateEndOfAttributes(null);
            val.ValidateEndElement(info);

            val.ValidateWhitespace(" \t\r\n");

            val.ValidateEndElement(info);
            val.EndValidation();

            Assert.True(!holder.IsCalledA);
            Assert.Equal(info.Validity, XmlSchemaValidity.Valid);
            Assert.Equal(info.ContentType, XmlSchemaContentType.ElementOnly);

            return;
        }
开发者ID:Corillian,项目名称:corefx,代码行数:29,代码来源:ValidateWhitespace_String.cs


示例2: SanityTestForSimpleType_MultipleCallInOneContext

        public void SanityTestForSimpleType_MultipleCallInOneContext(String param)
        {
            XmlSchemaValidator val = CreateValidator(XSDFILE_VALIDATE_TEXT);
            CValidationEventHolder holder = new CValidationEventHolder();
            XmlSchemaInfo info = new XmlSchemaInfo();

            val.ValidationEventHandler += new ValidationEventHandler(holder.CallbackA);

            val.Initialize();
            val.ValidateElement("PatternElement", "", info);
            val.ValidateEndOfAttributes(null);

            if (param == "single")
                val.ValidateText(StringGetter("foo123bar"));
            else
            {
                val.ValidateText(StringGetter("foo"));
                val.ValidateText(StringGetter("123"));
                val.ValidateText(StringGetter("bar"));
            }

            val.ValidateEndElement(info);
            val.EndValidation();

            Assert.True(!holder.IsCalledA);
            Assert.Equal(info.Validity, XmlSchemaValidity.Valid);
            Assert.Equal(info.ContentType, XmlSchemaContentType.TextOnly);

            return;
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:30,代码来源:ValidateText_EndElement.cs


示例3: DefaultValueForXmlResolver_XmlUrlResolver

        public void DefaultValueForXmlResolver_XmlUrlResolver()
        {
            XmlNamespaceManager manager = new XmlNamespaceManager(new NameTable());

            manager.AddNamespace("t", "uri:tempuri");

            XmlSchemaValidator val = new XmlSchemaValidator(new NameTable(),
                                                            CreateSchemaSetFromXml("<root />"),
                                                            manager,
                                                            AllFlags);
            XmlSchemaInfo info = new XmlSchemaInfo();

            val.XmlResolver = new XmlUrlResolver(); //Adding this as the default resolver is null and not XmlUrlResolver anymore

            val.Initialize();
            val.ValidateElement("foo", "", null, "t:type1", null, "uri:tempuri " + TestData + XSDFILE_TARGET_NAMESPACE, null);
            val.ValidateEndOfAttributes(null);
            val.ValidateElement("bar", "", null);
            val.ValidateEndOfAttributes(null);
            val.ValidateEndElement(null);
            val.ValidateEndElement(info);

            Assert.Equal(info.ContentType, XmlSchemaContentType.ElementOnly);
            Assert.True(info.SchemaType != null);

            return;
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:27,代码来源:PropertiesTests.cs


示例4: PassNull_LocalName_NamespaceUri_Invalid_First_Second_Overload

        public void PassNull_LocalName_NamespaceUri_Invalid_First_Second_Overload(String type, String overload)
        {
            XmlSchemaValidator val = CreateValidator(CreateSchemaSetFromXml("<root />"));
            string name = "root";
            string ns = "";
            XmlSchemaInfo info = new XmlSchemaInfo();

            if (type == "name")
                name = null;
            else
                ns = null;

            val.Initialize();
            try
            {
                if (overload == "first")
                    val.ValidateElement(name, ns, info);
                else
                    val.ValidateElement(name, ns, info, null, null, null, null);
            }
            catch (ArgumentNullException)
            {
                return;
            }

            Assert.True(false);
        }
开发者ID:dotnet,项目名称:corefx,代码行数:27,代码来源:ValidateElement.cs


示例5: CallAtRootLevel_Without_With_PartialValidationSet

        public void CallAtRootLevel_Without_With_PartialValidationSet(bool partialValidation)
        {
            XmlSchemaValidator val;
            XmlSchemaInfo info = new XmlSchemaInfo();
            XmlSchemaSet schemas = CreateSchemaSet("", "<?xml version=\"1.0\"?>\n" +
                                                       "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n" +
                                                       "    <xs:attribute name=\"attr1\" />\n" +
                                                       "    <xs:attribute name=\"attr2\" />\n" +
                                                       "</xs:schema>");
            schemas.Compile();
            val = CreateValidator(schemas);

            if (partialValidation)
            {
                val.Initialize(schemas.GlobalAttributes[new XmlQualifiedName("attr1")]);
                CheckExpectedAttributes(val.GetExpectedAttributes(), new XmlQualifiedName[] { new XmlQualifiedName("attr1") });
            }
            else
            {
                val.Initialize();
                CheckExpectedAttributes(val.GetExpectedAttributes(), new XmlQualifiedName[] { });
            }

            return;
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:25,代码来源:GetExpectedAttributes.cs


示例6: CallForSequence_Between_After_ValidationAllSeqElements

        public void CallForSequence_Between_After_ValidationAllSeqElements(String callOn)
        {
            XmlSchemaValidator val = CreateValidator(XSDFILE_GET_EXPECTED_PARTICLES);
            XmlSchemaInfo info = new XmlSchemaInfo();

            XmlQualifiedName[] names;

            val.Initialize();
            val.ValidateElement("SequenceElement", "", info);
            val.ValidateAttribute("attr1", "", StringGetter("foo"), info);
            val.ValidateAttribute("attr2", "", StringGetter("foo"), info);
            val.ValidateEndOfAttributes(null);

            val.ValidateElement("elem1", "", info);
            val.SkipToEndElement(info);

            if (callOn == "end")
            {
                val.ValidateElement("elem2", "", info);
                val.SkipToEndElement(info);

                names = new XmlQualifiedName[] { };
            }
            else
            {
                names = new XmlQualifiedName[] { new XmlQualifiedName("elem2") };
            }

            CheckExpectedElements(val.GetExpectedParticles(), names);

            return;
        }
开发者ID:dotnet,项目名称:corefx,代码行数:32,代码来源:GetExpectedParticles.cs


示例7: SetXmlNameTableTo_Empty_Full

        public void SetXmlNameTableTo_Empty_Full(String nameTableStatus)
        {
            XmlSchemaValidator val;
            ObservedNameTable nt = new ObservedNameTable();
            XmlSchemaInfo info = new XmlSchemaInfo();
            XmlSchemaSet sch = CreateSchemaSetFromXml("<root />");

            if (nameTableStatus == "full")
            {
                nt.Add("root");
                nt.Add("foo");
                nt.IsAddCalled = false;
                nt.IsGetCalled = false;
            }

            val = new XmlSchemaValidator(nt, sch, new XmlNamespaceManager(new NameTable()), AllFlags);
            Assert.NotEqual(val, null);

            val.Initialize();
            val.ValidateElement("root", "", info);

            Assert.True(nt.IsAddCalled);
            Assert.Equal(nt.IsGetCalled, false);

            return;
        }
开发者ID:dotnet,项目名称:corefx,代码行数:26,代码来源:Constructor_AddSchema.cs


示例8: PassNullXmlSchemaInfo__Valid

        public void PassNullXmlSchemaInfo__Valid()
        {
            XmlSchemaValidator val = CreateValidator(XSDFILE_VALIDATE_ATTRIBUTE);
            XmlSchemaInfo info = new XmlSchemaInfo();

            val.Initialize();
            val.ValidateElement("OneAttributeElement", "", null);
            val.ValidateAttribute("attr", "", StringGetter("foo"), null);

            return;
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:11,代码来源:ValidateAttribute.cs


示例9: CallOnElementWith_Required_Optional_Default_Fixed_FixedRequired_AttributesAfterValidateElement

        public void CallOnElementWith_Required_Optional_Default_Fixed_FixedRequired_AttributesAfterValidateElement(String attrType)
        {
            XmlSchemaValidator val = CreateValidator(XSDFILE_GET_EXPECTED_ATTRIBUTES);
            XmlSchemaInfo info = new XmlSchemaInfo();

            val.Initialize();
            val.ValidateElement(attrType + "AttributesElement", "", info);

            CheckExpectedAttributes(val.GetExpectedAttributes(), new XmlQualifiedName[] { new XmlQualifiedName("a1"), new XmlQualifiedName("a2") });

            return;
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:12,代码来源:GetExpectedAttributes.cs


示例10: CallOnElementWithNoAttributesAfterValidateElement

        public void CallOnElementWithNoAttributesAfterValidateElement()
        {
            XmlSchemaValidator val = CreateValidator(XSDFILE_GET_EXPECTED_ATTRIBUTES);
            XmlSchemaInfo info = new XmlSchemaInfo();

            val.Initialize();
            val.ValidateElement("NoAttributesElement", "", info);

            CheckExpectedAttributes(val.GetExpectedAttributes(), new XmlQualifiedName[] { });

            return;
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:12,代码来源:GetExpectedAttributes.cs


示例11: XsdAnyToSkipAttributeValidation

		public void XsdAnyToSkipAttributeValidation ()
		{
			// bug #358408
			XmlSchemaSet schemas = new XmlSchemaSet ();
			schemas.Add (null, "Test/XmlFiles/xsd/358408.xsd");
			XmlSchemaValidator v = new XmlSchemaValidator (
				new NameTable (),
				schemas,
				new XmlNamespaceManager (new NameTable ()),
				XmlSchemaValidationFlags.ProcessIdentityConstraints);
			v.Initialize ();
			v.ValidateWhitespace (" ");
			XmlSchemaInfo info = new XmlSchemaInfo ();
			ArrayList list = new ArrayList ();

			v.ValidateElement ("configuration", "", info, null, null, null, null);
			v.GetUnspecifiedDefaultAttributes (list);
			v.ValidateEndOfAttributes (info);

			v.ValidateWhitespace (" ");

			v.ValidateElement ("host", "", info, null, null, null, null);
			v.ValidateAttribute ("auto-start", "", "true", info);
			list.Clear ();
			v.GetUnspecifiedDefaultAttributes (list);
			v.ValidateEndOfAttributes (info);
			v.ValidateEndElement (null);//info);

			v.ValidateWhitespace (" ");

			v.ValidateElement ("service-managers", "", info, null, null, null, null);
			list.Clear ();
			v.GetUnspecifiedDefaultAttributes (list);
			v.ValidateEndOfAttributes (info);

			v.ValidateWhitespace (" ");

			v.ValidateElement ("service-manager", "", info, null, null, null, null);
			list.Clear ();
			v.GetUnspecifiedDefaultAttributes (list);
			v.ValidateEndOfAttributes (info);

			v.ValidateWhitespace (" ");

			v.ValidateElement ("foo", "", info, null, null, null, null);
			v.ValidateAttribute ("bar", "", "", info);
		}
开发者ID:carrie901,项目名称:mono,代码行数:47,代码来源:XmlSchemaValidatorTests.cs


示例12: PassNullValueGetter__Invalid

        public void PassNullValueGetter__Invalid()
        {
            XmlSchemaValidator val = CreateValidator(XSDFILE_VALIDATE_ATTRIBUTE);
            XmlSchemaInfo info = new XmlSchemaInfo();

            val.Initialize();
            val.ValidateElement("OneAttributeElement", "", null);
            try
            {
                val.ValidateAttribute("attr", "", (XmlValueGetter)null, info);
            }
            catch (ArgumentNullException)
            {
                return;
            }

            Assert.True(false);
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:18,代码来源:ValidateAttribute.cs


示例13: PassNull_LocalName_NameSpace__Invalid

        public void PassNull_LocalName_NameSpace__Invalid(String localName, String nameSpace)
        {
            XmlSchemaValidator val = CreateValidator(XSDFILE_VALIDATE_ATTRIBUTE);
            XmlSchemaInfo info = new XmlSchemaInfo();

            val.Initialize();
            val.ValidateElement("OneAttributeElement", "", null);
            try
            {
                val.ValidateAttribute(localName, nameSpace, StringGetter("foo"), info);
            }
            catch (ArgumentNullException)
            {
                return;
            }

            Assert.True(false);
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:18,代码来源:ValidateAttribute.cs


示例14: InitializeShouldResetIDConstraints

        public void InitializeShouldResetIDConstraints()
        {
            XmlSchemaValidator val = CreateValidator(XSDFILE_IDENTITY_CONSTRAINS);
            XmlSchemaInfo info = new XmlSchemaInfo();

            for (int i = 0; i < 2; i++)
            {
                val.Initialize();

                val.ValidateElement("rootIDs", "", info);
                val.ValidateEndOfAttributes(null);
                val.ValidateElement("foo", "", info);
                val.ValidateAttribute("attr", "", StringGetter("a1"), info);
                val.ValidateEndOfAttributes(null);
                val.ValidateEndElement(info);
                val.ValidateEndElement(info);

                val.EndValidation();
            }

            return;
        }
开发者ID:Corillian,项目名称:corefx,代码行数:22,代码来源:Initialize_EndValidation.cs


示例15: CallAfterValidate_Element_Attribute_EndOfAttributes_ForSequence

        public void CallAfterValidate_Element_Attribute_EndOfAttributes_ForSequence(String after)
        {
            XmlSchemaValidator val = CreateValidator(XSDFILE_GET_EXPECTED_PARTICLES);
            XmlSchemaInfo info = new XmlSchemaInfo();

            val.Initialize();
            val.ValidateElement("SequenceElement", "", info);

            if (after == "attrib")
                val.ValidateAttribute("attr1", "", StringGetter("foo"), info);

            if (after == "endof")
            {
                val.ValidateAttribute("attr1", "", StringGetter("foo"), info);
                val.ValidateAttribute("attr2", "", StringGetter("foo"), info);
                val.ValidateEndOfAttributes(null);
            }

            CheckExpectedElements(val.GetExpectedParticles(), new XmlQualifiedName[] { new XmlQualifiedName("elem1") });

            return;
        }
开发者ID:dotnet,项目名称:corefx,代码行数:22,代码来源:GetExpectedParticles.cs


示例16: ProvideValidXsiType

        public void ProvideValidXsiType()
        {
            XmlSchemaValidator val;
            XmlSchemaInfo info = new XmlSchemaInfo();
            XmlNamespaceManager ns = new XmlNamespaceManager(new NameTable());
            XmlSchemaSet schemas = new XmlSchemaSet();

            schemas.Add("uri:tempuri", Path.Combine(TestData, XSDFILE_TARGET_NAMESPACE));
            val = CreateValidator(schemas, ns, 0);
            ns.AddNamespace("t", "uri:tempuri");

            val.Initialize();
            val.ValidateElement("foo", "uri:tempuri", null, "t:type1", null, null, null);

            return;
        }
开发者ID:dotnet,项目名称:corefx,代码行数:16,代码来源:ValidateElement.cs


示例17: CallWithXsiNilTrue

        public void CallWithXsiNilTrue()
        {
            XmlSchemaValidator val;
            XmlSchemaInfo info = new XmlSchemaInfo();

            val = CreateValidator(XSDFILE_VALIDATE_END_ELEMENT);

            val.Initialize();
            val.ValidateElement("NillableElement", "", info, null, "true", null, null);
            val.ValidateEndOfAttributes(null);

            val.ValidateEndElement(info);
            Assert.Equal(info.Validity, XmlSchemaValidity.Valid);

            return;
        }
开发者ID:dotnet,项目名称:corefx,代码行数:16,代码来源:ValidateElement.cs


示例18: CallWith_Null_False_XsiNil

        public void CallWith_Null_False_XsiNil(String xsiNil)
        {
            XmlSchemaValidator val;
            XmlSchemaInfo info = new XmlSchemaInfo();

            val = CreateValidator(XSDFILE_VALIDATE_END_ELEMENT);

            val.Initialize();
            val.ValidateElement("NillableElement", "", info, null, xsiNil, null, null);
            val.ValidateEndOfAttributes(null);

            try
            {
                val.ValidateEndElement(info);
            }
            catch (XmlSchemaValidationException)
            {
                //XmlExceptionVerifier.IsExceptionOk(e, new object[] { "Sch_IncompleteContentExpecting",
																//	new object[] { "Sch_ElementName", "NillableElement" },
																//	new object[] { "Sch_ElementName", "foo" } });
                return;
            }

            Assert.True(false);
        }
开发者ID:dotnet,项目名称:corefx,代码行数:25,代码来源:ValidateElement.cs


示例19: CheckNoNamespaceSchemaLocationIs_UsedWhenSpecified_NotUsedWhenFlagIsSet

        public void CheckNoNamespaceSchemaLocationIs_UsedWhenSpecified_NotUsedWhenFlagIsSet(XmlSchemaValidationFlags allFlags)
        {
            XmlSchemaValidator val;
            XmlSchemaSet schemas = new XmlSchemaSet();
            XmlSchemaInfo info = new XmlSchemaInfo();
            CValidationEventHolder holder = new CValidationEventHolder();

            schemas.Add("", XmlReader.Create(new StringReader("<?xml version=\"1.0\" ?>\n" +
                                                              "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n" +
                                                              "    <xs:element name=\"root\" />\n" +
                                                              "</xs:schema>")));
            val = CreateValidator(schemas, allFlags);
            val.XmlResolver = new XmlUrlResolver();
            val.ValidationEventHandler += new ValidationEventHandler(holder.CallbackA);

            val.Initialize();
            val.ValidateElement("root", "", info, "type1", null, null, Path.Combine(TestData, XSDFILE_NO_TARGET_NAMESPACE));

            if ((int)allFlags == (int)AllFlags)
            {
                Assert.True(!holder.IsCalledA);
                Assert.True(info.SchemaType is XmlSchemaComplexType);
            }
            else
            {
                Assert.True(holder.IsCalledA);
                //XmlExceptionVerifier.IsExceptionOk(holder.lastException);
            }

            return;
        }
开发者ID:dotnet,项目名称:corefx,代码行数:31,代码来源:ValidateElement.cs


示例20: SanityTestsForNestedElements

        public void SanityTestsForNestedElements()
        {
            XmlSchemaValidator val;
            XmlSchemaSet schemas = new XmlSchemaSet();
            XmlSchemaInfo info = new XmlSchemaInfo();

            schemas.Add("", Path.Combine(TestData, XSDFILE_VALIDATE_END_ELEMENT));
            schemas.Compile();
            val = CreateValidator(schemas);

            val.Initialize();
            val.ValidateElement("NestedElement", "", info);
            val.ValidateEndOfAttributes(null);
            Assert.Equal(info.SchemaElement.QualifiedName, new XmlQualifiedName("NestedElement"));
            Assert.True(info.SchemaType is XmlSchemaComplexType);

            val.ValidateElement("foo", "", info);
            val.ValidateEndOfAttributes(null);
            Assert.Equal(info.SchemaElement.QualifiedName, new XmlQualifiedName("foo"));
            Assert.True(info.SchemaType is XmlSchemaComplexType);

            val.ValidateElement("bar", "", info);
            Assert.Equal(info.SchemaElement.QualifiedName, new XmlQualifiedName("bar"));
            Assert.True(info.SchemaType is XmlSchemaSimpleType);
            Assert.Equal(info.SchemaType.TypeCode, XmlTypeCode.String);

            return;
        }
开发者ID:dotnet,项目名称:corefx,代码行数:28,代码来源:ValidateElement.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Schema.XmlSchemaObject类代码示例发布时间:2022-05-26
下一篇:
C# Schema.XmlSchemaGroupBase类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap