XmlSchemaException 클래스

정의

스키마 예외에 대한 자세한 정보를 반환합니다.

public ref class XmlSchemaException : SystemException
public class XmlSchemaException : SystemException
[System.Serializable]
public class XmlSchemaException : SystemException
type XmlSchemaException = class
    inherit SystemException
[<System.Serializable>]
type XmlSchemaException = class
    inherit SystemException
Public Class XmlSchemaException
Inherits SystemException
상속
XmlSchemaException
파생
특성

예제

다음 예제에서는 사용 된 XmlSchemaException 클래스입니다.

#using <mscorlib.dll>
#using <System.Xml.dll>

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

class ValidXsd
{
public:

    static void Main()
    {
        FileStream^ fs;
        XmlSchema^ schema;

        try
        {
            fs = gcnew FileStream("example.xsd", FileMode::Open);
            schema = XmlSchema::Read(fs, gcnew ValidationEventHandler(ShowCompileError));

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

            XmlSchema^ compiledSchema;

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

            schema = compiledSchema;

            if (schema->IsCompiled)
            {
                // Schema is successfully compiled. 
                // Do something with it here.

            }
        }
        catch (XmlSchemaException^ e)
        {
            Console::WriteLine("LineNumber = {0}", e->LineNumber);
            Console::WriteLine("LinePosition = {0}", e->LinePosition);
            Console::WriteLine("Message = {0}", e->Message);
        }

    }

    static void ShowCompileError(Object^ sender, ValidationEventArgs^ e)
    {
        Console::WriteLine("Validation Error: {0}", e->Message);
    }
};

int main()
{
    ValidXsd::Main();
    Console::ReadLine();
    return 0;
};
using System;
using System.Xml;
using System.Xml.Schema;
using System.IO;

public class ValidXSD
{
    public static int Main()
    {

        FileStream fs;
        XmlSchema schema;
        try
        {
            fs = new FileStream("example.xsd", FileMode.Open);
            schema = XmlSchema.Read(fs, new ValidationEventHandler(ShowCompileError));

            XmlSchemaSet schemaSet = new XmlSchemaSet();
            schemaSet.ValidationEventHandler += new ValidationEventHandler(ShowCompileError);
            schemaSet.Add(schema);
            schemaSet.Compile();

            XmlSchema compiledSchema = null;

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

            schema = compiledSchema;

            if (schema.IsCompiled)
            {
                // Schema is successfully compiled.
                // Do something with it here.
            }
            return 0;
        }
        catch (XmlSchemaException e)
        {
            Console.WriteLine("LineNumber = {0}", e.LineNumber);
            Console.WriteLine("LinePosition = {0}", e.LinePosition);
            Console.WriteLine("Message = {0}", e.Message);
            return -1;
        }
    }

    private static void ShowCompileError(object sender, ValidationEventArgs e)
    {
        Console.WriteLine("Validation Error: {0}", e.Message);
    }
}
Option Strict On
Option Explicit On

Imports System.Xml
Imports System.Xml.Schema
Imports System.IO

Public Class ValidXSD
    Public Shared Sub Main()
        Dim fs As FileStream
        Dim schema As XmlSchema
        Try
            fs = New FileStream("example.xsd", FileMode.Open)
            schema = XmlSchema.Read(fs, New ValidationEventHandler(AddressOf ShowCompileError))

            Dim schemaSet As New XmlSchemaSet()
            AddHandler schemaSet.ValidationEventHandler, AddressOf ShowCompileError

            schemaSet.Add(schema)
            schemaSet.Compile()

            Dim compiledSchema As XmlSchema = Nothing

            For Each schema1 As XmlSchema In schemaSet.Schemas()
                compiledSchema = schema1
            Next

            schema = compiledSchema

            If schema.IsCompiled Then
                ' Schema is successfully compiled. 
                ' Do something with it here.
            End If

        Catch e As XmlSchemaException
            Console.WriteLine("LineNumber = {0}", e.LineNumber)
            Console.WriteLine("LinePosition = {0}", e.LinePosition)
            Console.WriteLine("Message = {0}", e.Message)
            Console.WriteLine("Source = {0}", e.Source)

        End Try
    End Sub


    Private Shared Sub ShowCompileError(ByVal sender As Object, ByVal e As ValidationEventArgs)
        Console.WriteLine("Validation Error: {0}", e.Message)
    End Sub
End Class

설명

중요

클래스에는 XmlSchemaException 신뢰할 수 없는 시나리오에서 노출되어서는 안 되는 중요한 정보가 포함될 수 있습니다. 예를 들어 이 속성은 SourceUri 예외를 발생시킨 스키마 파일의 URI 경로를 반환합니다. SourceUri 신뢰할 수 없는 시나리오에서는 속성을 노출해서는 안 됩니다. 이 중요한 정보가 신뢰할 수 없는 시나리오에서 노출되지 않도록 예외를 올바르게 처리해야 합니다.

생성자

XmlSchemaException()

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

XmlSchemaException(SerializationInfo, StreamingContext)

지정된 XmlSchemaExceptionSerializationInfo 정보를 사용하여 StreamingContext의 모든 속성을 포함하는 새 XmlSchemaException 개체를 만듭니다.

XmlSchemaException(String)

지정된 예외 메시지를 사용하여 XmlSchemaException 클래스의 새 인스턴스를 초기화합니다.

XmlSchemaException(String, Exception)

지정된 예외 메시지 및 예외를 발생시킨 원래 XmlSchemaException 개체를 사용하여 Exception 클래스의 새 인스턴스를 초기화합니다.

XmlSchemaException(String, Exception, Int32, Int32)

지정된 예외 메시지, 예외를 발생시킨 원래 XmlSchemaException 개체, 줄 번호 및 XML의 줄 위치를 사용하여 Exception 클래스의 새 인스턴스를 초기화합니다.

속성

Data

예외에 대한 사용자 정의 정보를 추가로 제공하는 키/값 쌍 컬렉션을 가져옵니다.

(다음에서 상속됨 Exception)
HelpLink

이 예외와 연결된 도움말 파일에 대한 링크를 가져오거나 설정합니다.

(다음에서 상속됨 Exception)
HResult

특정 예외에 할당된 코드화된 숫자 값인 HRESULT를 가져오거나 설정합니다.

(다음에서 상속됨 Exception)
InnerException

현재 예외를 발생시킨 Exception 인스턴스를 가져옵니다.

(다음에서 상속됨 Exception)
LineNumber

오류가 발생한 곳을 나타내는 줄 번호를 가져옵니다.

LinePosition

오류가 발생한 곳을 나타내는 줄 위치를 가져옵니다.

Message

이 예외의 오류 조건 설명을 가져옵니다.

Source

오류를 발생시키는 애플리케이션 또는 개체의 이름을 가져오거나 설정합니다.

(다음에서 상속됨 Exception)
SourceSchemaObject

XmlSchemaObject을 생성하는 XmlSchemaException입니다.

SourceUri

예외를 발생시킨 스키마의 URI(Uniform Resource Identifier) 위치를 가져옵니다.

StackTrace

호출 스택의 직접 실행 프레임 문자열 표현을 가져옵니다.

(다음에서 상속됨 Exception)
TargetSite

현재 예외를 throw하는 메서드를 가져옵니다.

(다음에서 상속됨 Exception)

메서드

Equals(Object)

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

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

파생 클래스에서 재정의된 경우 하나 이상의 후속 예외의 근본 원인이 되는 Exception 을 반환합니다.

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

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

(다음에서 상속됨 Object)
GetObjectData(SerializationInfo, StreamingContext)

모든 XmlSchemaException 속성을 지정한 SerializationInfoStreamingContext 클래스로 스트리밍합니다.

GetType()

현재 인스턴스의 런타임 형식을 가져옵니다.

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

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

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

현재 예외에 대한 문자열 표현을 만들고 반환합니다.

(다음에서 상속됨 Exception)

이벤트

SerializeObjectState
사용되지 않습니다.

예외에 대한 serialize된 데이터가 들어 있는 예외 상태 개체가 만들어지도록 예외가 serialize될 때 발생합니다.

(다음에서 상속됨 Exception)

적용 대상