XmlSchemaInclude クラス
アセンブリ: System.Xml (system.xml.dll 内)


インクルードされるスキーマ ドキュメントは、次の条件のいずれか 1 つを満たしている必要があります。
インクルードされるスキーマは、それを格納するスキーマ ドキュメントと同じターゲット名前空間を持っている必要があります。
OR
インクルードされるスキーマは、指定した targetNamespace を持つことができません。つまり、targetNamespace 属性が null である必要があります。
XmlSchemaInclude は、同じターゲット名前空間を持つ (または指定したターゲット名前空間がない) インクルードされるスキーマの、すべてのスキーマ コンポーネントを、格納するスキーマに追加します。

Imports System Imports System.Collections Imports System.IO Imports System.Xml Imports System.Xml.Xsl Imports System.Xml.Schema Public Class ImportIncludeSample Private Shared Sub ValidationCallBack(ByVal sender As Object, ByVal args As ValidationEventArgs) If args.Severity = XmlSeverityType.Warning Then Console.Write("WARNING: ") Else If args.Severity = XmlSeverityType.Error Then Console.Write("ERROR: ") End If End If Console.WriteLine(args.Message) End Sub 'ValidationCallBack Public Shared Sub Main() Dim schema As New XmlSchema() schema.ElementFormDefault = XmlSchemaForm.Qualified schema.TargetNamespace = "http://www.w3.org/2001/05/XMLInfoset" ' <xs:import namespace="http://www.example.com/IPO" /> Dim import As New XmlSchemaImport() import.Namespace = "http://www.example.com/IPO" schema.Includes.Add(import) ' <xs:include schemaLocation="example.xsd" /> Dim include As New XmlSchemaInclude() include.SchemaLocation = "example.xsd" schema.Includes.Add(include) Dim schemaSet As New XmlSchemaSet() AddHandler schemaSet.ValidationEventHandler, AddressOf ValidationCallBack schemaSet.Add(schema) schemaSet.Compile() Dim compiledSchema As XmlSchema = Nothing For Each schema1 As XmlSchema In schemaSet.Schemas() compiledSchema = schema1 Next Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(New NameTable()) nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema") compiledSchema.Write(Console.Out, nsmgr) End Sub 'Main End Class 'ImportIncludeSample ' Main() 'ImportIncludeSample
using System; using System.Collections; using System.IO; using System.Xml; using System.Xml.Xsl; using System.Xml.Schema; public class ImportIncludeSample { private static void ValidationCallBack(object sender, ValidationEventArgs args) { if (args.Severity == XmlSeverityType.Warning) Console.Write("WARNING: "); else if (args.Severity == XmlSeverityType.Error) Console.Write("ERROR: "); Console.WriteLine(args.Message); } public static void Main() { XmlSchema schema = new XmlSchema(); schema.ElementFormDefault = XmlSchemaForm.Qualified; schema.TargetNamespace = "http://www.w3.org/2001/05/XMLInfoset"; // <xs:import namespace="http://www.example.com/IPO" /> XmlSchemaImport import = new XmlSchemaImport(); import.Namespace = "http://www.example.com/IPO"; schema.Includes.Add(import); // <xs:include schemaLocation="example.xsd" /> XmlSchemaInclude include = new XmlSchemaInclude(); include.SchemaLocation = "example.xsd"; schema.Includes.Add(include); XmlSchemaSet schemaSet = new XmlSchemaSet(); schemaSet.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack); schemaSet.Add(schema); schemaSet.Compile(); XmlSchema compiledSchema = null; foreach (XmlSchema schema1 in schemaSet.Schemas()) { compiledSchema = schema1; } XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable()); nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); compiledSchema.Write(Console.Out, nsmgr); }/* Main() */ } //ImportIncludeSample

System.Xml.Schema.XmlSchemaObject
System.Xml.Schema.XmlSchemaExternal
System.Xml.Schema.XmlSchemaInclude


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- XmlSchemaInclude クラスのページへのリンク