XmlSchemaAttribute 클래스

정의

W3C(World Wide Web 컨소시엄)에서 지정한 대로 XML 스키마의 attribute 요소를 나타냅니다. 특성은 다른 문서 요소에 대한 추가 정보를 제공합니다. 특성 태그는 스키마에 대한 문서 요소의 태그 사이에 중첩됩니다. XML 문서에서는 특성이 요소의 여는 태그에 명명된 항목으로 표시됩니다.

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

예제

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

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

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

class XmlSchemaExamples
{
public:

    static void Main()
    {
        XmlSchema^ schema = gcnew XmlSchema();

        // <xs:attribute name="mybaseattribute">
        XmlSchemaAttribute^ attributeBase = gcnew XmlSchemaAttribute();
        schema->Items->Add(attributeBase);
        attributeBase->Name = "mybaseattribute";

        // <xs:simpleType>
        XmlSchemaSimpleType^ simpleType = gcnew XmlSchemaSimpleType();
        attributeBase->SchemaType = simpleType;

        // <xs:restriction base="integer">
        XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction();
        simpleType->Content = restriction;
        restriction->BaseTypeName = gcnew XmlQualifiedName("integer", "http://www.w3.org/2001/XMLSchema");

        // <xs:maxInclusive value="1000"/>
        XmlSchemaMaxInclusiveFacet^ maxInclusive = gcnew XmlSchemaMaxInclusiveFacet();
        restriction->Facets->Add(maxInclusive);
        maxInclusive->Value = "1000";

        // <xs:complexType name="myComplexType">
        XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType();
        schema->Items->Add(complexType);
        complexType->Name = "myComplexType";

        // <xs:attribute ref="mybaseattribute"/>
        XmlSchemaAttribute^ attributeBaseRef = gcnew XmlSchemaAttribute();
        complexType->Attributes->Add(attributeBaseRef);
        attributeBaseRef->RefName = gcnew XmlQualifiedName("mybaseattribute");

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

        XmlSchema^ compiledSchema;

        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);
    }

    static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args)
    {
        Console::WriteLine(args->Message);
    }
};

int main()
{
    XmlSchemaExamples::Main();
    return 0;
};
using System;
using System.Xml;
using System.Xml.Schema;

class XMLSchemaExamples
{
    public static void Main()
    {

        XmlSchema schema = new XmlSchema();

        // <xs:attribute name="mybaseattribute">
        XmlSchemaAttribute attributeBase = new XmlSchemaAttribute();
        schema.Items.Add(attributeBase);
        attributeBase.Name = "mybaseattribute";

        // <xs:simpleType>
        XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType();
        attributeBase.SchemaType = simpleType;

        // <xs:restriction base="integer">
        XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
        simpleType.Content = restriction;
        restriction.BaseTypeName = new XmlQualifiedName("integer", "http://www.w3.org/2001/XMLSchema");

        // <xs:maxInclusive value="1000"/>
        XmlSchemaMaxInclusiveFacet maxInclusive = new XmlSchemaMaxInclusiveFacet();
        restriction.Facets.Add(maxInclusive);
        maxInclusive.Value = "1000";

        // <xs:complexType name="myComplexType">
        XmlSchemaComplexType complexType = new XmlSchemaComplexType();
        schema.Items.Add(complexType);
        complexType.Name = "myComplexType";

        // <xs:attribute ref="mybaseattribute"/>
        XmlSchemaAttribute attributeBaseRef = new XmlSchemaAttribute();
        complexType.Attributes.Add(attributeBaseRef);
        attributeBaseRef.RefName = new XmlQualifiedName("mybaseattribute");

        XmlSchemaSet schemaSet = new XmlSchemaSet();
        schemaSet.ValidationEventHandler += new ValidationEventHandler(ValidationCallbackOne);
        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);
    }

    public static void ValidationCallbackOne(object sender, ValidationEventArgs args)
    {

        Console.WriteLine(args.Message);
    }
}
Option Explicit On
Option Strict On

Imports System.Xml
Imports System.Xml.Schema

Class XMLSchemaExamples
    Public Shared Sub Main()
        Dim schema As New XmlSchema()

        ' <xs:attribute name="mybaseattribute">
        Dim attributeBase As New XmlSchemaAttribute()
        schema.Items.Add(attributeBase)
        attributeBase.Name = "mybaseattribute"

        ' <xs:simpleType>
        Dim simpleType As New XmlSchemaSimpleType()
        attributeBase.SchemaType = simpleType

        ' <xs:restriction base="integer">
        Dim restriction As New XmlSchemaSimpleTypeRestriction()
        simpleType.Content = restriction
        restriction.BaseTypeName = New XmlQualifiedName("integer", "http://www.w3.org/2001/XMLSchema")

        ' <xs:maxInclusive value="1000"/>
        Dim maxInclusive As New XmlSchemaMaxInclusiveFacet()
        restriction.Facets.Add(maxInclusive)
        maxInclusive.Value = "1000"

        ' <xs:complexType name="myComplexType">
        Dim complexType As New XmlSchemaComplexType()
        schema.Items.Add(complexType)
        complexType.Name = "myComplexType"

        ' <xs:attribute ref="mybaseattribute"/>
        Dim attributeBaseRef As New XmlSchemaAttribute()
        complexType.Attributes.Add(attributeBaseRef)
        attributeBaseRef.RefName = New XmlQualifiedName("mybaseattribute")

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

        schemaSet.Add(schema)
        schemaSet.Compile()

        Dim compiledSchema As XmlSchema = Nothing

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

        Dim nsmgr As New XmlNamespaceManager(New NameTable())
        nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema")
        compiledSchema.Write(Console.Out, nsmgr)
    End Sub


    Public Shared Sub ValidationCallbackOne(ByVal sender As Object, ByVal args As ValidationEventArgs)

        Console.WriteLine(args.Message)
    End Sub
End Class

다음 XML 파일은 앞의 코드 예제에 대 한 생성 됩니다.


<?xml version="1.0" encoding="IBM437"?>
<xs:schema  xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:attribute name="mybaseattribute">
        <xs:simpleType>
            <xs:restriction base="xs:integer">
                <xs:maxInclusive value="1000" />
            </xs:restriction>
        </xs:simpleType>
    </xs:attribute>
    <xs:complexType name="myComplexType">
        <xs:attribute ref="mybaseattribute" />
    </xs:complexType>
</xs:schema>

설명

특성 선언은 요소의 schema 자식 요소(전역 범위 포함) 또는 복합 형식 정의 내에 있을 수 있습니다. 복합 형식의 경우 특성 선언은 로컬 선언 또는 전역 범위의 특성에 대한 참조로 표시될 수 있습니다. 전역 및 로컬 특성 선언에는 모두 기존 단순 형식을 참조하는 선택적 형식 특성이 있습니다. 선택적 형식 특성을 사용하지 않는 경우 특성 선언(전역 또는 로컬)은 로컬 단순 형식을 정의해야 합니다.

생성자

XmlSchemaAttribute()

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

속성

Annotation

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

(다음에서 상속됨 XmlSchemaAnnotated)
AttributeSchemaType

특성의 XmlSchemaSimpleType 또는 SchemaType에 따라 특성의 형식을 나타내는 SchemaTypeName 개체를 가져옵니다.

AttributeType
사용되지 않습니다.
사용되지 않습니다.
사용되지 않습니다.

AttributeType 속성의 컴파일 이후 값을 보유하는 특성의 SchemaType 또는 SchemaTypeName을 기준으로 CLR(공용 런타임 라이브러리) 개체를 가져옵니다.

DefaultValue

특성의 기본값을 가져오거나 설정합니다.

FixedValue

특성의 고정 값을 가져오거나 설정합니다.

Form

특성의 폼을 가져오거나 설정합니다.

Id

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

(다음에서 상속됨 XmlSchemaAnnotated)
LineNumber

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

(다음에서 상속됨 XmlSchemaObject)
LinePosition

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

(다음에서 상속됨 XmlSchemaObject)
Name

특성의 이름을 가져오거나 설정합니다.

Namespaces

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

(다음에서 상속됨 XmlSchemaObject)
Parent

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

(다음에서 상속됨 XmlSchemaObject)
QualifiedName

특성에 대한 정규화된 이름을 가져옵니다.

RefName

이 스키마 또는 지정된 네임스페이스에 의해 표시되는 다른 스키마에서 선언된 특성의 이름을 가져오거나 설정합니다.

SchemaType

특성 형식을 단순 형식으로 가져오거나 설정합니다.

SchemaTypeName

이 스키마 또는 지정된 네임스페이스에 의해 표시된 다른 스키마에서 정의된 단순 형식의 이름을 가져오거나 설정합니다.

SourceUri

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

(다음에서 상속됨 XmlSchemaObject)
UnhandledAttributes

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

(다음에서 상속됨 XmlSchemaAnnotated)
Use

특성이 사용되는 방법에 대한 정보를 가져오거나 설정합니다.

메서드

Equals(Object)

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

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

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

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

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

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

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

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

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

(다음에서 상속됨 Object)

적용 대상