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


C# XmlSchemaSet.Schemas方法代码示例

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


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

示例1: ResolveTypeNameClashesByRenaming

        // .NET C# cannot have types with same name in the Codenamespace. If that happens a digit is appended to the typename.
        // Eg. CoreComponents and UnqualifiedDataTypes both have "IdentifierType", one gets named "IdentifierType1" :-(
        // Solution: Prepend types in CoreComponents with "cctscct" and modify references in UnqualifiedComponents
        public static void ResolveTypeNameClashesByRenaming(XmlSchemaSet schemaSet)
        {
            string ccts_cctPrefix = "cctscct";
            XmlSchema coreCompSchema = schemaSet.Schemas(Constants.CoreComponentTypeSchemaModuleTargetNamespace).OfType<XmlSchema>().Single();
            XmlSchema unqualSchema = schemaSet.Schemas(Constants.UnqualifiedDataTypesTargetNamespace).OfType<XmlSchema>().Single();

            foreach (var complexType in coreCompSchema.Items.OfType<XmlSchemaComplexType>())
            {
                complexType.Name = ccts_cctPrefix + complexType.Name;
                complexType.IsAbstract = true; // Make it abstract as well. Ain't gonna use the base, only the one derived from this type.
            }

            foreach (var complexType in unqualSchema.Items.OfType<XmlSchemaComplexType>()
                            .Where(t => t.BaseXmlSchemaType.QualifiedName.Namespace.Equals(Constants.CoreComponentTypeSchemaModuleTargetNamespace)))
            {
                var name = new XmlQualifiedName(ccts_cctPrefix + complexType.BaseXmlSchemaType.QualifiedName.Name, complexType.BaseXmlSchemaType.QualifiedName.Namespace);
                var content = complexType.ContentModel as XmlSchemaSimpleContent;
                if (content.Content is XmlSchemaSimpleContentRestriction)
                {
                    (content.Content as XmlSchemaSimpleContentRestriction).BaseTypeName = name;
                }
                else if (content.Content is XmlSchemaSimpleContentExtension)
                {
                    (content.Content as XmlSchemaSimpleContentExtension).BaseTypeName = name;
                }
            }
            schemaSet.Reprocess(coreCompSchema);
            schemaSet.Reprocess(unqualSchema);
        }
开发者ID:Gammern,项目名称:ubllarsen,代码行数:32,代码来源:UblSchemaTypeSimplificationTool.cs

示例2: EnumerateDocumentedItems

 internal static void EnumerateDocumentedItems(XmlSchemaSet xmlSchemaSet, Dictionary<string, string> documentedItems)
 {
     foreach (XmlSchema schema in xmlSchemaSet.Schemas())
     {
         EnumerateDocumentedItems(schema.Items, documentedItems);
     }
 }
开发者ID:anukat2015,项目名称:sones,代码行数:7,代码来源:WsdlUtils.cs

示例3: Validate

        private static bool Validate(String filename, XmlSchemaSet schemaSet)
        {
            Console.WriteLine("Validating XML file {0}...", filename.ToString());

            XmlSchema compiledSchema = null;

            foreach (XmlSchema schema in schemaSet.Schemas())
            {
                compiledSchema = schema;
            }

            XmlReaderSettings settings = new XmlReaderSettings();
            settings.Schemas.Add(compiledSchema);
            settings.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
            settings.ValidationType = ValidationType.Schema;

            success = true;

            //Create the schema validating reader.
            XmlReader vreader = XmlReader.Create(filename, settings);

            while (vreader.Read()) { }

            //Close the reader.
            vreader.Close();
            return success;
        }
开发者ID:quela,项目名称:myprojects,代码行数:27,代码来源:ValidateXmlAgainstXsd.cs

示例4: CoreGetSourceObject

        protected override object CoreGetSourceObject(string sourceFilePath, IDictionary<string, IList<string>> properties)
        {
            XmlSchemaSet xmlSchemaSet;
            XmlSchema xmlSchema;
            ObjectConstruct objectConstruct00;

            if ((object)sourceFilePath == null)
                throw new ArgumentNullException("sourceFilePath");

            if ((object)properties == null)
                throw new ArgumentNullException("properties");

            if (DataType.IsWhiteSpace(sourceFilePath))
                throw new ArgumentOutOfRangeException("sourceFilePath");

            sourceFilePath = Path.GetFullPath(sourceFilePath);

            objectConstruct00 = new ObjectConstruct();

            using (Stream stream = File.Open(sourceFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                xmlSchema = XmlSchema.Read(stream, ValidationCallback);

            xmlSchemaSet = new XmlSchemaSet();
            xmlSchemaSet.Add(xmlSchema);
            xmlSchemaSet.Compile();

            xmlSchema = xmlSchemaSet.Schemas().Cast<XmlSchema>().ToList()[0];

            EnumSchema(objectConstruct00, xmlSchema.Items);

            return objectConstruct00;
        }
开发者ID:sami1971,项目名称:textmetal,代码行数:32,代码来源:XmlSchemaSourceStrategy.cs

示例5: AddImportedSchemas

        private void AddImportedSchemas(XmlSchema schema, XmlSchemaSet schemaSet, List<XmlSchema> importsList)
        {
            ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "AddImportedSchemas");

            try
            {
                foreach (XmlSchemaImport import in schema.Includes)
                {
                    ICollection realSchemas = schemaSet.Schemas(import.Namespace);

                    foreach (XmlSchema ixsd in realSchemas)
                    {
                        if (!importsList.Contains(ixsd))
                        {
                            importsList.Add(ixsd);
                            AddImportedSchemas(ixsd, schemaSet, importsList);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }
        }
开发者ID:sreenandini,项目名称:test_buildscripts,代码行数:25,代码来源:WcfSingleWsdlExportEndpoint.cs

示例6: 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

示例7: ProcessSchema

        public bool ProcessSchema(string filePath)
        {
            if(String.IsNullOrWhiteSpace(filePath))
            {
                return false;
            }

            var schemaSet = new XmlSchemaSet();
            schemaSet.ValidationEventHandler += new ValidationEventHandler(ValidationCallback);
            schemaSet.Add("urn:newrelic-config", filePath);
            schemaSet.Compile();

            XmlSchema schema = null;
            foreach (XmlSchema TempSchema in schemaSet.Schemas())
            {
                schema = TempSchema;
            }

            var configurationElement = schema.Items[0] as XmlSchemaElement;
            if (configurationElement != null)
            {
                ProcessElement(configurationElement, null);
                ConfigurationFile.Xsd.RootElement = true;
            }

            return true;
        }
开发者ID:jaffinito,项目名称:dotnet_configuration,代码行数:27,代码来源:XsdReader.cs

示例8: 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

示例9: CreateXmlSchemaForIndicatorsInGroup

        /// <summary>
        /// Формируем XmlSchema для правильного отображения индикаторов группы в VGridControl
        /// </summary>
        /// <param name="elmList">названия всех по</param>
        /// <returns>Возвращаем поток в который записана XmlSchema</returns>
        public static MemoryStream CreateXmlSchemaForIndicatorsInGroup(List<string[]> elmList)
        {
            var xmlSchema = new XmlSchema();

            // <xs:element name="root">
            var elementRoot = new XmlSchemaElement();
            xmlSchema.Items.Add(elementRoot);
            elementRoot.Name = "root";
            // <xs:complexType>
            var complexType = new XmlSchemaComplexType();
            elementRoot.SchemaType = complexType;

            // <xs:choice minOccurs="0" maxOccurs="unbounded">
            var choice = new XmlSchemaChoice();
            complexType.Particle = choice;
            choice.MinOccurs = 0;
            choice.MaxOccursString = "unbounded";

            // <xs:element name="record">
            var elementRecord = new XmlSchemaElement();
            choice.Items.Add(elementRecord);
            elementRecord.Name = "record";
            // <xs:complexType>
            var complexType2 = new XmlSchemaComplexType();
            elementRecord.SchemaType = complexType2;

            // <xs:sequence>
            var sequence = new XmlSchemaSequence();
            complexType2.Particle = sequence;

            foreach (var el in elmList)
            {
                var element = new XmlSchemaElement();
                sequence.Items.Add(element);
                element.Name = el[0];
                element.SchemaTypeName = new XmlQualifiedName(el[1], "http://www.w3.org/2001/XMLSchema");
            }

            var schemaSet = new XmlSchemaSet();
            schemaSet.Add(xmlSchema);
            schemaSet.Compile();

            XmlSchema compiledSchema = null;

            foreach (XmlSchema schema1 in schemaSet.Schemas())
                compiledSchema = schema1;

            var nsmgr = new XmlNamespaceManager(new NameTable());
            nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");

            var ms = new MemoryStream();
            if (compiledSchema != null) compiledSchema.Write(ms, nsmgr);
            ms.Position = 0;

            return ms;
        }
开发者ID:Biskup,项目名称:GOATApplication,代码行数:61,代码来源:StaticData.cs

示例10: EnsureProbeMatchSchema

        public static XmlQualifiedName EnsureProbeMatchSchema(DiscoveryVersion discoveryVersion, XmlSchemaSet schemaSet)
        {
            Fx.Assert(schemaSet != null, "The schemaSet must be non null.");
            Fx.Assert(discoveryVersion != null, "The discoveryVersion must be non null.");

            // ensure that EPR is added to the schema.
            if (discoveryVersion == DiscoveryVersion.WSDiscoveryApril2005 || discoveryVersion == DiscoveryVersion.WSDiscoveryCD1)
            {
                EndpointAddressAugust2004.GetSchema(schemaSet);
            }
            else if (discoveryVersion == DiscoveryVersion.WSDiscovery11)
            {
                EndpointAddress10.GetSchema(schemaSet);
            }
            else
            {
                Fx.Assert("The discoveryVersion is not supported.");
            }

            // do not add/find Probe related schema items
            SchemaTypes typesFound = SchemaTypes.ProbeType | SchemaTypes.ResolveType;
            SchemaElements elementsFound = SchemaElements.None;         

            XmlSchema discoverySchema = null;
            ICollection discoverySchemas = schemaSet.Schemas(discoveryVersion.Namespace);
            if ((discoverySchemas == null) || (discoverySchemas.Count == 0))
            {
                discoverySchema = CreateSchema(discoveryVersion);
                AddImport(discoverySchema, discoveryVersion.Implementation.WsaNamespace);
                schemaSet.Add(discoverySchema);
            }
            else
            {                
                foreach (XmlSchema schema in discoverySchemas)
                {
                    discoverySchema = schema;
                    if (schema.SchemaTypes.Contains(discoveryVersion.Implementation.QualifiedNames.ProbeMatchType))
                    {
                        typesFound |= SchemaTypes.ProbeMatchType;
                        break;
                    }

                    LocateSchemaTypes(discoveryVersion, schema, ref typesFound);
                    LocateSchemaElements(discoveryVersion, schema, ref elementsFound);
                }
            }

            if ((typesFound & SchemaTypes.ProbeMatchType) != SchemaTypes.ProbeMatchType)
            {
                AddSchemaTypes(discoveryVersion, typesFound, discoverySchema);
                AddElements(discoveryVersion, elementsFound, discoverySchema);
                schemaSet.Reprocess(discoverySchema);
            }

            return discoveryVersion.Implementation.QualifiedNames.ProbeMatchType;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:56,代码来源:SchemaUtility.cs

示例11: v1

        public void v1()
        {
            XmlSchemaSet sc = new XmlSchemaSet();
            ICollection Col = sc.Schemas();

            CError.Compare(Col.Count, 0, "Count");
            CError.Compare(Col.IsSynchronized, false, "IsSynchronized");

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

示例12: NewXmlSchemaSet

		private XmlSchemaSet NewXmlSchemaSet ()
		{
			xss = new XmlSchemaSet ();
			foreach (MetadataSection section in metadata.MetadataSections)
				if (section.Metadata is XmlSchema)
					xss.Add (section.Metadata as XmlSchema);

			Assert.AreEqual (3, xss.Schemas ().Count, "#1");
			return xss;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:10,代码来源:XsdDataContractImporterTest.cs

示例13: v2

        public void v2()
        {
            XmlSchemaSet sc = new XmlSchemaSet();

            //remove after compile
            XmlSchema Schema1 = sc.Add(null, TestData._XsdAuthor);
            sc.Compile();
            sc.RemoveRecursive(Schema1);
            CError.Compare(sc.Count, 0, "Count");
            ICollection Col = sc.Schemas();
            CError.Compare(Col.Count, 0, "ICollection.Count");

            //remove before compile
            Schema1 = sc.Add(null, TestData._XsdAuthor);
            sc.RemoveRecursive(Schema1);
            CError.Compare(sc.Count, 0, "Count");
            Col = sc.Schemas();
            CError.Compare(Col.Count, 0, "ICollection.Count"); return;
        }
开发者ID:dotnet,项目名称:corefx,代码行数:19,代码来源:TC_SchemaSet_RemoveRecursive.cs

示例14: v3

        public void v3()
        {
            XmlSchemaSet sc = new XmlSchemaSet();
            XmlSchema Schema1 = sc.Add(null, TestData._XsdNoNs);

            ICollection Col = sc.Schemas(null);

            CError.Compare(Col.Count, 1, "Count");

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

示例15: v2

        public void v2()
        {
            XmlSchemaSet sc = new XmlSchemaSet();
            XmlSchema Schema1 = sc.Add("xsdauthor1", TestData._XsdNoNs);
            XmlSchema Schema2 = sc.Add("xsdauthor", TestData._XsdAuthor);
            ICollection Col = sc.Schemas();

            CError.Compare(Col.Count, 2, "Count");

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


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