Share via


XmlSchemaInclude Sınıf

Tanım

include World Wide Web Konsorsiyumu (W3C) tarafından belirtilen XML Şeması öğesini temsil eder. Bu sınıf, dış şemadan gelen bildirimleri ve tanımları eklemek için kullanılır. Eklenen bildirimler ve tanımlar daha sonra içeren şemada işlenmek üzere kullanılabilir.

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
Devralma

Örnekler

Aşağıdaki örnek öğesini oluşturur 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

Bu kod örneği için aşağıdaki XML oluşturulur.

<?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>

Açıklamalar

Eklenen şema belgesi aşağıdaki koşullardan birini karşılamalıdır:

Eklenen şema, içeren şema belgesiyle aynı hedef ad alanına sahip olmalıdır.

VEYA

Eklenen şemada belirtilen targetNamespacebir şema olamaz; targetNamespace öznitelik null olmalıdır.

XmlSchemaInclude , aynı hedef ad alanına (veya belirtilen hedef ad alanına sahip olmayan) dahil edilen şemalardan tüm şema bileşenlerini içeren şemaya ekler.

Oluşturucular

XmlSchemaInclude()

XmlSchemaInclude sınıfının yeni bir örneğini başlatır.

Özellikler

Annotation

Özelliğini alır veya ayarlar annotation .

Id

Dize kimliğini alır veya ayarlar.

(Devralındığı yer: XmlSchemaExternal)
LineNumber

Öğenin başvurduğu schema dosyadaki satır numarasını alır veya ayarlar.

(Devralındığı yer: XmlSchemaObject)
LinePosition

Öğenin başvurduğu schema dosyadaki satır konumunu alır veya ayarlar.

(Devralındığı yer: XmlSchemaObject)
Namespaces

Bu şema nesnesiyle kullanılacak öğesini XmlSerializerNamespaces alır veya ayarlar.

(Devralındığı yer: XmlSchemaObject)
Parent

Bu XmlSchemaObjectöğesinin üst öğesini alır veya ayarlar.

(Devralındığı yer: XmlSchemaObject)
Schema

Başvuruda bulunan şema için öğesini XmlSchema alır veya ayarlar.

(Devralındığı yer: XmlSchemaExternal)
SchemaLocation

Şemanın fiziksel olarak nerede olduğunu şema işlemcisine bildiren Tekdüzen Kaynak Tanımlayıcısı (URI) konumunu alır veya ayarlar.

(Devralındığı yer: XmlSchemaExternal)
SourceUri

Şemayı yükleyen dosyanın kaynak konumunu alır veya ayarlar.

(Devralındığı yer: XmlSchemaObject)
UnhandledAttributes

Şema hedef ad alanına ait olmayan nitelikli öznitelikleri alır veya ayarlar.

(Devralındığı yer: XmlSchemaExternal)

Yöntemler

Equals(Object)

Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler.

(Devralındığı yer: Object)
GetHashCode()

Varsayılan karma işlevi işlevi görür.

(Devralındığı yer: Object)
GetType()

Type Geçerli örneğini alır.

(Devralındığı yer: Object)
MemberwiseClone()

Geçerli Objectöğesinin sığ bir kopyasını oluşturur.

(Devralındığı yer: Object)
ToString()

Geçerli nesneyi temsil eden dizeyi döndürür.

(Devralındığı yer: Object)

Şunlara uygulanır