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

C# Schema.XmlSchemaSet类代码示例

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

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



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

示例1: GetXml

        public string GetXml(bool validate)
        {
            XNamespace ns = "http://sd.ic.gc.ca/SLDR_Schema_Definition_en";

            var spectrum_licences = getLicences();

            XDocument doc = new XDocument(new XElement("spectrum_licence_data_registry", spectrum_licences));

            foreach (XElement e in doc.Root.DescendantsAndSelf())
            {
                if (e.Name.Namespace == "")
                    e.Name = ns + e.Name.LocalName;
            }

            var errors = new StringBuilder();

            if (validate)
            {
                XmlSchemaSet set = new XmlSchemaSet();
                var schema = getMainSchema();
                set.Add(null, schema);

                doc.Validate(set, (sender, args) => { errors.AppendLine(args.Message); });
            }

            //return errors.Length > 0 ? errors.ToString() : doc.ToString();
            var  result = errors.Length > 0 ? "Validation Errors: " + errors.ToString() : getDocumentAsString(doc);
            return result;
        }
开发者ID:mathewvance,项目名称:Silo,代码行数:29,代码来源:SldrTechnicalDataService.cs


示例2: AddElementToSchema

        void AddElementToSchema(XmlSchemaElement element, string elementNs, XmlSchemaSet schemaSet)
        {
            OperationDescription parentOperation = this.operation;
            if (parentOperation.OperationMethod != null)
            {
                XmlQualifiedName qname = new XmlQualifiedName(element.Name, elementNs);

                OperationElement existingElement;
                if (ExportedMessages.ElementTypes.TryGetValue(qname, out existingElement))
                {
                    if (existingElement.Operation.OperationMethod == parentOperation.OperationMethod)
                        return;
                    if (!SchemaHelper.IsMatch(element, existingElement.Element))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.CannotHaveTwoOperationsWithTheSameElement5, parentOperation.OperationMethod.DeclaringType, parentOperation.OperationMethod.Name, qname, existingElement.Operation.OperationMethod.DeclaringType, existingElement.Operation.Name)));
                    }
                    return;
                }
                else
                {
                    ExportedMessages.ElementTypes.Add(qname, new OperationElement(element, parentOperation));
                }
            }
            SchemaHelper.AddElementToSchema(element, SchemaHelper.GetSchema(elementNs, schemaSet), schemaSet);
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:25,代码来源:MessageContractExporter.cs


示例3: ValidateXml

        public bool ValidateXml(string inputXML, string xsdUri)
        {
            stringBuilder = new StringBuilder();

            bool validated = false;

            // Create the XmlSchemaSet class.
            XmlSchemaSet sc = new XmlSchemaSet();

            // Add the schema to the collection.
            sc.Add(null, xsdUri);

            // Set the validation settings.
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.ValidationType = ValidationType.Schema;
            settings.Schemas = sc;
            settings.ConformanceLevel = ConformanceLevel.Auto;
            settings.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);

            XmlTextReader reader = new XmlTextReader(new StringReader(inputXML));
            while (reader.Read())
            { }

            if (stringBuilder.ToString() == String.Empty)
                validated = true;

            return validated;
        }
开发者ID:shariqatariq,项目名称:profiles-rns,代码行数:28,代码来源:XmlValidate.cs


示例4: v2

        public void v2()
        {
            XmlSchemaSet sc = new XmlSchemaSet();
            try
            {
                XmlSchema Schema1 = sc.Add(null, TestData._XsdAuthor);
                CError.Compare(sc.Count, 1, "AddCount");
                CError.Compare(sc.Contains(Schema1), true, "AddContains");
                CError.Compare(sc.IsCompiled, false, "AddIsCompiled");

                XmlSchema Schema2 = XmlSchema.Read(new StreamReader(new FileStream(TestData._XsdNoNs, FileMode.Open, FileAccess.Read)), null);

                sc.Compile();
                CError.Compare(sc.Count, 1, "Compile");
                CError.Compare(sc.Contains(Schema1), true, "Contains");

                sc.Reprocess(Schema2);
                CError.Compare(sc.Count, 1, "Reprocess");
                CError.Compare(sc.Contains(Schema2), true, "Contains");
            }
            catch (ArgumentException e)
            {
                _output.WriteLine(e.ToString());
                CError.Compare(sc.Count, 1, "AE");
                return;
            }
            Assert.True(false);
        }
开发者ID:Corillian,项目名称:corefx,代码行数:28,代码来源:TC_SchemaSet_Reprocess.cs


示例5: IsXmlValid

        public static bool IsXmlValid(string schemaFile, string xmlFile)
        {
            try
            {
                var valid = true;
                var sc = new XmlSchemaSet();
                sc.Add(string.Empty, schemaFile);
                var settings = new XmlReaderSettings { ValidationType = ValidationType.Schema, Schemas = sc };
                settings.ValidationEventHandler += delegate { valid = false; };
                settings.ValidationFlags = XmlSchemaValidationFlags.ReportValidationWarnings;
                settings.IgnoreWhitespace = true;
                var reader = XmlReader.Create(xmlFile, settings);

                try
                {
                    while (reader.Read()) {}
                }
                catch (XmlException xmlException)
                {
                    Console.WriteLine(xmlException);
                }
                return valid;
            }
            catch
            {
                return false;
            }
        }
开发者ID:juan2202,项目名称:LeagueSharp-Standalones,代码行数:28,代码来源:Utils.cs


示例6: GetSchema

 public static XmlQualifiedName GetSchema(XmlSchemaSet xmlSchemaSet)
 {
     if (xmlSchemaSet == null)
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("xmlSchemaSet");
     XmlQualifiedName eprType = EprType;
     XmlSchema eprSchema = GetEprSchema();
     ICollection schemas = xmlSchemaSet.Schemas(Addressing200408Strings.Namespace);
     if (schemas == null || schemas.Count == 0)
         xmlSchemaSet.Add(eprSchema);
     else
     {
         XmlSchema schemaToAdd = null;
         foreach (XmlSchema xmlSchema in schemas)
         {
             if (xmlSchema.SchemaTypes.Contains(eprType))
             {
                 schemaToAdd = null;
                 break;
             }
             else
                 schemaToAdd = xmlSchema;
         }
         if (schemaToAdd != null)
         {
             foreach (XmlQualifiedName prefixNsPair in eprSchema.Namespaces.ToArray())
                 schemaToAdd.Namespaces.Add(prefixNsPair.Name, prefixNsPair.Namespace);
             foreach (XmlSchemaObject schemaObject in eprSchema.Items)
                 schemaToAdd.Items.Add(schemaObject);
             xmlSchemaSet.Reprocess(schemaToAdd);
         }
     }
     return eprType;
 }
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:33,代码来源:EndpointAddressAugust2004.cs


示例7: Add

		public void Add ()
		{
			XmlSchemaSet ss = new XmlSchemaSet ();
			XmlDocument doc = new XmlDocument ();
			doc.LoadXml ("<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' />");
			ss.Add (null, new XmlNodeReader (doc)); // null targetNamespace
			ss.Compile ();

			// same document, different targetNamespace
			ss.Add ("ab", new XmlNodeReader (doc));

			// Add(null, xmlReader) -> targetNamespace in the schema
			doc.LoadXml ("<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='urn:foo' />");
			ss.Add (null, new XmlNodeReader (doc));

			Assert.AreEqual (3, ss.Count);

			bool chameleon = false;
			bool ab = false;
			bool urnfoo = false;

			foreach (XmlSchema schema in ss.Schemas ()) {
				if (schema.TargetNamespace == null)
					chameleon = true;
				else if (schema.TargetNamespace == "ab")
					ab = true;
				else if (schema.TargetNamespace == "urn:foo")
					urnfoo = true;
			}
			Assert.IsTrue (chameleon, "chameleon schema missing");
			Assert.IsTrue (ab, "target-remapped schema missing");
			Assert.IsTrue (urnfoo, "target specified in the schema ignored");
		}
开发者ID:user277,项目名称:mono,代码行数:33,代码来源:XmlSchemaSetTests.cs


示例8: v2

 //[Variation(Desc = "v2 - Contains with non existing ns", Priority = 0)]
 public void v2()
 {
     XmlSchemaSet sc = new XmlSchemaSet();
     sc.Add("xsdauthor", TestData._XsdAuthor);
     Assert.Equal(sc.Contains("test"), false);
     return;
 }
开发者ID:geoffkizer,项目名称:corefx,代码行数:8,代码来源:TC_SchemaSet_Contains_ns.cs


示例9: GenerateMapping

        public ClrMappingInfo GenerateMapping(XmlSchemaSet schemas)
        {
            if (schemas == null)
            {
                throw new ArgumentNullException("schemas");
            }
            schemas.ValidationEventHandler += new ValidationEventHandler(Validationcallback);
            schemas.Compile();

            this.schemas = schemas;
            if (schemaErrorCount > 0)
            {
                Console.WriteLine("Schema cannot be compiled. Class generation aborted");
                return null;
            }

            // Execute transformations
            try
            {
                Xml.Fxt.FxtLinq2XsdInterpreter.Run(schemas, configSettings.trafo);
            }
            catch (Xml.Fxt.FxtException)
            {
                Console.WriteLine("Schema cannot be transformed. Class generation aborted");
                return null;
            }
            return GenerateMetaModel();
        }
开发者ID:dipdapdop,项目名称:linqtoxsd,代码行数:28,代码来源:XsdToTypesConverter.cs


示例10: Validate

 private string Validate(string path)
 {
     var sc = new XmlSchemaSet();
     string dir = @"..\..\..\..\Schemas\Collada\";
     sc.Add("http://www.collada.org/2008/03/COLLADASchema", dir + "collada_schema_1_5.xsd");
     return Validate(path, sc);
 }
开发者ID:BEEden,项目名称:Diplomarbeit,代码行数:7,代码来源:ColladaExporterTests.cs


示例11: Import

        public void Import(XmlSchemaSet schemas)
        {
            if (schemas == null)
                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("schemas"));

            InternalImport(schemas, null, null, null);
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:7,代码来源:XsdDataContractImporter.cs


示例12: validate

        public bool validate()
        {

            try
            {
                XmlSchemaSet sc = new XmlSchemaSet();
                // Add the schema to the collection.

                sc.Add("urn:mites-schema", this.xsdFile);
                // Set the validation settings.    
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.ValidationType = ValidationType.Schema;
                settings.Schemas = sc;
                settings.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
                // Create the XmlReader object.
                XmlReader reader = XmlReader.Create(this.xmlFile, settings);
                // Parse the file. 
                while (reader.Read())
                {
                    ;
                }
                return true;
            }
            catch (Exception e)
            {
                throw new Exception("Error in (SXML.ConfigurationReader,validate):" + e.ToString());
            }

        }
开发者ID:intille,项目名称:mitessoftware,代码行数:29,代码来源:ProtocolsReader.cs


示例13: IsValid

        public bool IsValid(Stream template)
        {
            if (template == null)
            {
                throw new ArgumentNullException("template");
            }

            // Load the template into an XDocument
            XDocument xml = XDocument.Load(template);

            // Load the XSD embedded resource
            Stream stream = typeof(XMLPnPSchemaV201508Formatter)
                .Assembly
                .GetManifestResourceStream("OfficeDevPnP.Core.Framework.Provisioning.Providers.Xml.ProvisioningSchema-2015-08.xsd");

            // Prepare the XML Schema Set
            XmlSchemaSet schemas = new XmlSchemaSet();
            schemas.Add(XMLConstants.PROVISIONING_SCHEMA_NAMESPACE_2015_08,
                new XmlTextReader(stream));

            Boolean result = true;
            xml.Validate(schemas, (o, e) =>
            {
                Diagnostics.Log.Error(e.Exception, "SchemaFormatter", "Template is not valid: {0}", e.Message);
                result = false;
            });

            return (result);
        }
开发者ID:LiyeXu,项目名称:PnP-Sites-Core,代码行数:29,代码来源:XMLPnPSchemaV201508Formatter.cs


示例14: ValidateSave

        public void ValidateSave()
        {
            WorldEntity world = createTestWorld();

            XElement xElement = WorldTransformer.Instance.ToXElement(world, TransformerSettings.WorldNamespace + "World");

            xElement.Save("unittestsave.xml", SaveOptions.OmitDuplicateNamespaces);

            XmlSchemaSet schemaSet = new XmlSchemaSet();

            schemaSet.Add(null, "WorldSchema1.xsd");

            XDocument xDocument = new XDocument(xElement);
            xDocument.AddAnnotation(SaveOptions.OmitDuplicateNamespaces);
            xDocument.Save("unittest2.xml", SaveOptions.OmitDuplicateNamespaces);

            XElement x1 = new XElement(TransformerSettings.WorldNamespace + "Outer");
            x1.Add(new XElement(TransformerSettings.WorldNamespace + "Inner"));
            x1.Save("unittest3.xml", SaveOptions.OmitDuplicateNamespaces);
            string val = "";
            xDocument.Validate(schemaSet, (o, vea) => {
                val += o.GetType().Name + "\n";
                val += vea.Message + "\n";
            }, true);

            Assert.AreEqual("", val);
        }
开发者ID:neaket,项目名称:Dragonfly,代码行数:27,代码来源:WorldTests.cs


示例15: Main

        public static void Main()
        {
            XmlSchemaSet schemas = new XmlSchemaSet();
            schemas.Add("urn:catalogue", "..//..//xml/catalogue.xsd");

            XDocument XmlDocument = XDocument.Load("..//..//xml/catalogue.xml");

            List<string> errorMessages = new List<string>();

            XmlDocument.Validate(schemas, (obj, error) =>
            {
                errorMessages.Add(error.Message);
            });

            IPrinter printer = new ConsolePrinter();

            if (errorMessages.Count == 0)
            {
                printer.Print("Valid catalogue.xml");
            }
            else
            {
                printer.Print(errorMessages);
            }
        }
开发者ID:VDGone,项目名称:TelerikAcademy-1,代码行数:25,代码来源:EntryPoint.cs


示例16: Load

        public DatabaseVersionSetup Load(TextReader reader)
        {
            var versionSetup = new DatabaseVersionSetup();

            var shemas = new XmlSchemaSet();
            Assembly assem = typeof(DatabaseVersionSetup).Assembly;
            using (Stream stream = assem.GetManifestResourceStream("DatabaseVersionControl.Core.Xsd.DVCSchema.xsd"))
            {
                if (stream != null){
                    shemas.Add("", XmlReader.Create(stream));
                }
                else{
                    throw new Exception("Could not load embedded resource Xsd.DVCSchema.xsd");
                }
            }
            XDocument element = XDocument.Load(reader);
            element.Validate(shemas, (sender, e) =>
                                         { if (_exception != null) _exception(e); }, true);
            var profiles = element.XPathSelectElements("//profiles/profile");
            versionSetup.DefaultProfile = element.Root.Attribute("defaultProfile").Value;
            LoadProfiles(versionSetup, profiles);
            var databases = element.XPathSelectElements("//repositories/repository");
            LoadRepositories(versionSetup, databases);
            return versionSetup;
        }
开发者ID:rolfwessels,项目名称:databaseversioncontrol,代码行数:25,代码来源:XmlConfigFileLoader.cs


示例17: ValidateXml

 private static void ValidateXml(XDocument document, XmlSchemaSet schema)
 {
     document.Validate(schema, (obj, ev) =>
         {
             Console.WriteLine("{0}", ev.Message);
         });
 }
开发者ID:antonpopov,项目名称:Databases,代码行数:7,代码来源:Program.cs


示例18: SoapEditorProxy

    public SoapEditorProxy(Connections.ConnectionData connData, ServiceDescription description, XmlSchemaSet schemas)
    {
      _connData = connData;
      _descrip = description;
      _schemas = schemas;
      _helper = new XmlCompletionDataProvider(schemas, "http://schemas.xmlsoap.org/soap/envelope/"
        , "soapenv", () => "xmlns:soap=\"" + description.TargetNamespace + "\""
        , e => (e.Name == "Envelope" && e.QualifiedName.Namespace == "http://schemas.xmlsoap.org/soap/envelope/")
          || TypeMatchesAction(e.QualifiedName, this.Action));

      _baseUrl = new Uri(_connData.Url).GetLeftPart(UriPartial.Path);
      switch (_connData.Authentication)
      {
        case Connections.Authentication.Windows:
          _cred = CredentialCache.DefaultNetworkCredentials;
          break;
        case Connections.Authentication.Explicit:
          _cred = new NetworkCredential(_connData.UserName, _connData.Password);
          break;
      }

      _actionUrls = _descrip.Services.OfType<Service>()
        .SelectMany(s => s.Ports.OfType<Port>().Where(SoapPort))
        .SelectMany(p => _descrip.Bindings[p.Binding.Name].Operations.OfType<OperationBinding>())
        .Select(o => new { Name = o.Name, Address = o.Extensions.OfType<SoapOperationBinding>().First().SoapAction })
        .Distinct()
        .ToDictionary(a => a.Name, a => a.Address);
    }
开发者ID:cornelius90,项目名称:InnovatorAdmin,代码行数:28,代码来源:SoapEditorProxy.cs


示例19: v1

        //[Variation(Desc = "v1 - Contains with null")]
        public void v1()
        {
            XmlSchemaSet sc = new XmlSchemaSet();
            Assert.Equal(sc.Contains((String)null), false);

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


示例20: LoadAndValidateInvoice

        private static void LoadAndValidateInvoice(string xmlFilename, XmlSchemaSet invoiceSchemaSet)
        {
            UblLarsen.Ubl2.InvoiceType invoice = null;
            using (FileStream fs = File.OpenRead(xmlFilename))
            {
                Console.WriteLine($"Processing {xmlFilename} ...");
                // XDocument can contain any valid xml, don't know if it is an ubl invoice yet
                XDocument xmlInvoice = XDocument.Load(fs);
                if (!ValidateUblInvoiceDocument(xmlInvoice, invoiceSchemaSet))
                {
                    Console.WriteLine("Invalid ubl invoice document, but I will try and read it anyway...");
                }

                // Reuse filestream and load into an InvoiceType instance by using XmlSerializer
                fs.Position = 0;
                XmlSerializer xs = new XmlSerializer(typeof(UblLarsen.Ubl2.InvoiceType));
                try
                {
                    invoice = (UblLarsen.Ubl2.InvoiceType)xs.Deserialize(fs);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Deserialize: " + ex.Message);
                }
            }

            if (invoice != null)
            {
                ShowInvoice(invoice);
            }
        }
开发者ID:Gammern,项目名称:ubllarsen,代码行数:31,代码来源:Program.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Schema.XmlSchemaSimpleType类代码示例发布时间:2022-05-26
下一篇:
C# Schema.XmlSchemaSequence类代码示例发布时间: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