XmlSchemaInclude 클래스

정의

W3C(World Wide Web 컨소시엄)에서 지정한 대로 XML 스키마의 include 요소를 나타냅니다. 이 클래스를 사용하여 외부 스키마의 선언과 정의를 포함할 수 있습니다. 그러면 포함하는 스키마에서 포함된 선언과 정의를 처리할 수 있습니다.

public ref class XmlSchemaInclude : System::Xml::Schema::XmlSchemaExternal
public class XmlSchemaInclude : System.Xml.Schema.XmlSchemaExternal
type XmlSchemaInclude = class
    inherit XmlSchemaExternal
Public Class XmlSchemaInclude
Inherits XmlSchemaExternal
상속

예제

다음 예제에서는 요소를 만듭니다 include .

#using <System.Xml.dll>

using namespace System;
using namespace System::Xml;
using namespace System::Xml::Schema;

ref 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 = gcnew XmlSchema();
        schema->ElementFormDefault = XmlSchemaForm::Qualified;
        schema->TargetNamespace = "http://www.w3.org/2001/05/XMLInfoset";

        // <xs:import namespace="http://www.example.com/IPO" />                            
        XmlSchemaImport^ import = gcnew XmlSchemaImport();
        import->Namespace = "http://www.example.com/IPO";
        schema->Includes->Add(import);

        // <xs:include schemaLocation="example.xsd" />               
        XmlSchemaInclude^ include = gcnew XmlSchemaInclude();
        include->SchemaLocation = "example.xsd";
        schema->Includes->Add(include);

        XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet();
        schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallBack);
        schemaSet->Add(schema);
        schemaSet->Compile();

        XmlSchema^ compiledSchema = nullptr;

        for each (XmlSchema^ schema1 in schemaSet->Schemas())
        {
            compiledSchema = schema1;
        }

        XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable());
        nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");
        compiledSchema->Write(Console::Out, nsmgr);
    }

};

int main()
{
    ImportIncludeSample::Main();
    return 0;
}
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
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


    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
End Class

'ImportIncludeSample

이 코드 예제에 대해 다음 XML이 생성됩니다.

<?xml version="1.0" encoding="IBM437"?>
<schema elementFormDefault="qualified" targetNamespace="http://www.w3.org/2001/05/XMLInfoset" xmlns="http://www.w3.org/2001/XMLSchema">
  <import namespace="http://www.example.com/IPO" />
  <include schemaLocation="example.xsd" />
</schema>

설명

포함된 스키마 문서는 다음 조건 중 하나를 충족해야 합니다.

포함된 스키마에는 포함된 스키마 문서와 동일한 대상 네임스페이스가 있어야 합니다.

또는

포함된 스키마에는 지정된 targetNamespace스키마가 있을 수 없습니다. 특성은 targetNamespace null이어야 합니다.

XmlSchemaInclude 는 포함된 스키마의 모든 스키마 구성 요소를 포함하는 스키마에 동일한 대상 네임스페이스(또는 지정된 대상 네임스페이스 없음)를 추가합니다.

생성자

XmlSchemaInclude()

XmlSchemaInclude 클래스의 새 인스턴스를 초기화합니다.

속성

Annotation

annotation 속성을 가져오거나 설정합니다.

Id

문자열 ID를 가져오거나 설정합니다.

(다음에서 상속됨 XmlSchemaExternal)
LineNumber

schema 요소가 참조하는 파일에서 줄 번호를 가져오거나 설정합니다.

(다음에서 상속됨 XmlSchemaObject)
LinePosition

schema 요소가 참조하는 파일에서 줄 위치를 가져오거나 설정합니다.

(다음에서 상속됨 XmlSchemaObject)
Namespaces

이 스키마 개체에 사용할 XmlSerializerNamespaces를 가져오거나 설정합니다.

(다음에서 상속됨 XmlSchemaObject)
Parent

XmlSchemaObject의 부모를 가져오거나 설정합니다.

(다음에서 상속됨 XmlSchemaObject)
Schema

참조된 스키마에 대한 XmlSchema를 가져오거나 설정합니다.

(다음에서 상속됨 XmlSchemaExternal)
SchemaLocation

스키마 프로세서에 스키마의 실제 위치를 알려 주는 스키마의 URI(Uniform Resource Identifier) 위치를 가져오거나 설정합니다.

(다음에서 상속됨 XmlSchemaExternal)
SourceUri

스키마를 로드한 파일의 소스 위치를 가져오거나 설정합니다.

(다음에서 상속됨 XmlSchemaObject)
UnhandledAttributes

스키마 대상 네임스페이스에 속하지 않는 정규화된 특성을 가져오거나 설정합니다.

(다음에서 상속됨 XmlSchemaExternal)

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상