XmlSchemaSimpleType XmlSchemaSimpleType XmlSchemaSimpleType XmlSchemaSimpleType Class

定義

W3C (World Wide Web Consortium) によって指定された XML スキーマの単純コンテンツに対する simpleType 要素を表します。Represents the simpleType element for simple content from XML Schema as specified by the World Wide Web Consortium (W3C). このクラスは単純型を定義します。This class defines a simple type. 単純型では、テキストだけの内容を持つ属性または要素の値に関する情報や制約を指定できます。Simple types can specify information and constraints for the value of attributes or elements with text-only content.

public ref class XmlSchemaSimpleType : System::Xml::Schema::XmlSchemaType
public class XmlSchemaSimpleType : System.Xml.Schema.XmlSchemaType
type XmlSchemaSimpleType = class
    inherit XmlSchemaType
Public Class XmlSchemaSimpleType
Inherits XmlSchemaType
継承

次の例では、使用、XmlSchemaSimpleTypeクラス。The following example shows the use of the XmlSchemaSimpleType class.

#using <System.Xml.dll>

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

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

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

		// <xs:simpleType name="LotteryNumber">
		XmlSchemaSimpleType^ LotteryNumberType = gcnew XmlSchemaSimpleType();
		LotteryNumberType->Name = "LotteryNumber";

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

		// <xs:minInclusive value="1"/>
		XmlSchemaMinInclusiveFacet^ minInclusive = gcnew XmlSchemaMinInclusiveFacet();
		minInclusive->Value = "1";
		LotteryNumberRestriction->Facets->Add(minInclusive);

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

		LotteryNumberType->Content = LotteryNumberRestriction;
		schema->Items->Add(LotteryNumberType);

		// <xs:simpleType name="LotteryNumberList">
		XmlSchemaSimpleType^ LotteryNumberListType = gcnew XmlSchemaSimpleType();
		LotteryNumberListType->Name = "LotteryNumberList";

		// <xs:list itemType="LotteryNumber"/>
		XmlSchemaSimpleTypeList^ list = gcnew XmlSchemaSimpleTypeList();
		list->ItemTypeName = gcnew XmlQualifiedName("LotteryNumber", "");
		LotteryNumberListType->Content = list;

		schema->Items->Add(LotteryNumberListType);

		// <xs:simpleType name="LotteryNumbers">
		XmlSchemaSimpleType^ LotteryNumbersType = gcnew XmlSchemaSimpleType();
		LotteryNumbersType->Name = "LotteryNumbers";

		// <xs:restriction base="LotteryNumberList">
		XmlSchemaSimpleTypeRestriction^ LotteryNumbersRestriction = gcnew XmlSchemaSimpleTypeRestriction();
		LotteryNumbersRestriction->BaseTypeName = gcnew XmlQualifiedName("LotteryNumberList", "");

		// <xs:length value="5"/>
		XmlSchemaLengthFacet^ length = gcnew XmlSchemaLengthFacet();
		length->Value = "5";
		LotteryNumbersRestriction->Facets->Add(length);

		LotteryNumbersType->Content = LotteryNumbersRestriction;

		schema->Items->Add(LotteryNumbersType);

		// <xs:element name="TodaysLottery" type="LotteryNumbers">
		XmlSchemaElement^ TodaysLottery = gcnew XmlSchemaElement();
		TodaysLottery->Name = "TodaysLottery";
		TodaysLottery->SchemaTypeName = gcnew XmlQualifiedName("LotteryNumbers", "");

		schema->Items->Add(TodaysLottery);

		XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet();
		schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne);
		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()
{
	XMLSchemaExamples::Main();
	return 0;
}
using System;
using System.Xml;
using System.Xml.Schema;

class XMLSchemaExamples
{
    public static void Main()
    {

        XmlSchema schema = new XmlSchema();

        // <xs:simpleType name="LotteryNumber">
        XmlSchemaSimpleType LotteryNumberType = new XmlSchemaSimpleType();
        LotteryNumberType.Name = "LotteryNumber";

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

        // <xs:minInclusive value="1"/>
        XmlSchemaMinInclusiveFacet minInclusive = new XmlSchemaMinInclusiveFacet();
        minInclusive.Value = "1";
        LotteryNumberRestriction.Facets.Add(minInclusive);

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

        LotteryNumberType.Content = LotteryNumberRestriction;
        schema.Items.Add(LotteryNumberType);

        // <xs:simpleType name="LotteryNumberList">
        XmlSchemaSimpleType LotteryNumberListType = new XmlSchemaSimpleType();
        LotteryNumberListType.Name = "LotteryNumberList";

        // <xs:list itemType="LotteryNumber"/>
        XmlSchemaSimpleTypeList list = new XmlSchemaSimpleTypeList();
        list.ItemTypeName = new XmlQualifiedName("LotteryNumber", "");
        LotteryNumberListType.Content = list;

        schema.Items.Add(LotteryNumberListType);

        // <xs:simpleType name="LotteryNumbers">
        XmlSchemaSimpleType LotteryNumbersType = new XmlSchemaSimpleType();
        LotteryNumbersType.Name = "LotteryNumbers";

        // <xs:restriction base="LotteryNumberList">
        XmlSchemaSimpleTypeRestriction LotteryNumbersRestriction = new XmlSchemaSimpleTypeRestriction();
        LotteryNumbersRestriction.BaseTypeName = new XmlQualifiedName("LotteryNumberList", "");

        // <xs:length value="5"/>
        XmlSchemaLengthFacet length = new XmlSchemaLengthFacet();
        length.Value = "5";
        LotteryNumbersRestriction.Facets.Add(length);

        LotteryNumbersType.Content = LotteryNumbersRestriction;

        schema.Items.Add(LotteryNumbersType);

        // <xs:element name="TodaysLottery" type="LotteryNumbers">
        XmlSchemaElement TodaysLottery = new XmlSchemaElement();
        TodaysLottery.Name = "TodaysLottery";
        TodaysLottery.SchemaTypeName = new XmlQualifiedName("LotteryNumbers", "");

        schema.Items.Add(TodaysLottery);

        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 Strict On
Option Explicit On

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

Class XMLSchemaExamples

    Public Shared Sub Main()

        Dim schema As New XmlSchema()

        ' <xs:simpleType name="LotteryNumber">
        Dim LotteryNumberType As New XmlSchemaSimpleType()
        LotteryNumberType.Name = "LotteryNumber"

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

        ' <xs:minInclusive value="1"/>
        Dim minInclusive As New XmlSchemaMinInclusiveFacet()
        minInclusive.Value = "1"
        LotteryNumberRestriction.Facets.Add(minInclusive)

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

        LotteryNumberType.Content = LotteryNumberRestriction
        schema.Items.Add(LotteryNumberType)

        ' <xs:simpleType name="LotteryNumberList">
        Dim LotteryNumberListType As New XmlSchemaSimpleType()
        LotteryNumberListType.Name = "LotteryNumberList"

        ' <xs:list itemType="LotteryNumber"/>
        Dim list As New XmlSchemaSimpleTypeList()
        list.ItemTypeName = New XmlQualifiedName("LotteryNumber", "")
        LotteryNumberListType.Content = list

        schema.Items.Add(LotteryNumberListType)

        ' <xs:simpleType name="LotteryNumbers">
        Dim LotteryNumbersType As New XmlSchemaSimpleType()
        LotteryNumbersType.Name = "LotteryNumbers"

        ' <xs:restriction base="LotteryNumberList">
        Dim LotteryNumbersRestriction As New XmlSchemaSimpleTypeRestriction()
        LotteryNumbersRestriction.BaseTypeName = New XmlQualifiedName("LotteryNumberList", "")

        ' <xs:length value="5"/>
        Dim length As New XmlSchemaLengthFacet()
        length.Value = "5"
        LotteryNumbersRestriction.Facets.Add(length)

        LotteryNumbersType.Content = LotteryNumbersRestriction

        schema.Items.Add(LotteryNumbersType)

        ' <xs:element name="TodaysLottery" type="LotteryNumbers">
        Dim TodaysLottery As New XmlSchemaElement()
        TodaysLottery.Name = "TodaysLottery"
        TodaysLottery.SchemaTypeName = New XmlQualifiedName("LotteryNumbers", "")

        schema.Items.Add(TodaysLottery)

        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 'Main


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

        Console.WriteLine(args.Message)
    End Sub 'ValidationCallbackOne
End Class 'XMLSchemaExamples

上記のコード例では、次の XML ファイルが生成されます。The following XML file is generated for the preceding code example.

<?xml version="1.0" encoding="IBM437"?>
<xs:schema  xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:simpleType name="LotteryNumber">
        <xs:restriction base="xs:int">
            <xs:minInclusive value="1"/>
            <xs:maxInclusive value="99"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="LotteryNumberList">
        <xs:list itemType="LotteryNumber"/>
    </xs:simpleType>
    
    <xs:simpleType name="LotteryNumbers">
        <xs:restriction base="LotteryNumberList">
            <xs:length value="5"/>
        </xs:restriction>
    </xs:simpleType>
    
    <xs:element name="TodaysLottery" type="LotteryNumbers">
    </xs:element>
    
</xs:schema>

注釈

単純型は、既存の単純型 (組み込みデータ型および派生した単純型) から派生させて定義します。Simple types are defined by deriving them from existing simple types (built-in data types and derived simple types). 単純型には要素や属性を含めることはできません。A simple type cannot contain elements and cannot have attributes.

コンストラクター

XmlSchemaSimpleType() XmlSchemaSimpleType() XmlSchemaSimpleType() XmlSchemaSimpleType()

XmlSchemaSimpleType クラスの新しいインスタンスを初期化します。Initializes a new instance of the XmlSchemaSimpleType class.

プロパティ

Annotation Annotation Annotation Annotation

annotation プロパティを取得または設定します。Gets or sets the annotation property.

(Inherited from XmlSchemaAnnotated)
BaseSchemaType BaseSchemaType BaseSchemaType BaseSchemaType

組み込み XML スキーマ定義言語 (XSD: XML Schema Definition Language) データ型、simpleType 要素、または complexType 要素のコンパイル後のオブジェクト型を取得します。Gets the post-compilation object type or the built-in XML Schema Definition Language (XSD) data type, simpleType element, or complexType element. これは、スキーマ コンパイル後の infoset プロパティです。This is a post-schema-compilation infoset property.

(Inherited from XmlSchemaType)
BaseXmlSchemaType BaseXmlSchemaType BaseXmlSchemaType BaseXmlSchemaType

このスキーマ型の基本型に対応するコンパイル後の値を取得します。Gets the post-compilation value for the base type of this schema type.

(Inherited from XmlSchemaType)
Content Content Content Content

XmlSchemaSimpleTypeUnionXmlSchemaSimpleTypeList、または XmlSchemaSimpleTypeRestriction のいずれか 1 つを取得または設定します。Gets or sets one of XmlSchemaSimpleTypeUnion, XmlSchemaSimpleTypeList, or XmlSchemaSimpleTypeRestriction.

Datatype Datatype Datatype Datatype

複合型のデータ型に対応するコンパイル後の値を取得します。Gets the post-compilation value for the data type of the complex type.

(Inherited from XmlSchemaType)
DerivedBy DerivedBy DerivedBy DerivedBy

この要素が基本型から派生された方法に関するコンパイル後の情報を取得します。Gets the post-compilation information on how this element was derived from its base type.

(Inherited from XmlSchemaType)
Final Final Final Final

さらに派生が可能かどうかを示す、型派生の final 属性を取得または設定します。Gets or sets the final attribute of the type derivation that indicates if further derivations are allowed.

(Inherited from XmlSchemaType)
FinalResolved FinalResolved FinalResolved FinalResolved

Final プロパティのコンパイル後の値を取得します。Gets the post-compilation value of the Final property.

(Inherited from XmlSchemaType)
Id Id Id Id

文字列 ID を取得または設定します。Gets or sets the string id.

(Inherited from XmlSchemaAnnotated)
IsMixed IsMixed IsMixed IsMixed

この型が混合コンテンツ モデルを持つかどうかを示す値を取得または設定します。Gets or sets a value indicating if this type has a mixed content model. このプロパティは、複合型でだけ有効です。This property is only valid in a complex type.

(Inherited from XmlSchemaType)
LineNumber LineNumber LineNumber LineNumber

schema 要素が参照するファイルの行番号を取得または設定します。Gets or sets the line number in the file to which the schema element refers.

(Inherited from XmlSchemaObject)
LinePosition LinePosition LinePosition LinePosition

schema 要素が参照するファイルの行番号を取得または設定します。Gets or sets the line position in the file to which the schema element refers.

(Inherited from XmlSchemaObject)
Name Name Name Name

型の名前を取得または設定します。Gets or sets the name of the type.

(Inherited from XmlSchemaType)
Namespaces Namespaces Namespaces Namespaces

このスキーマ オブジェクトと一緒に使用する XmlSerializerNamespaces を取得または設定します。Gets or sets the XmlSerializerNamespaces to use with this schema object.

(Inherited from XmlSchemaObject)
Parent Parent Parent Parent

この XmlSchemaObject の親を取得または設定します。Gets or sets the parent of this XmlSchemaObject.

(Inherited from XmlSchemaObject)
QualifiedName QualifiedName QualifiedName QualifiedName

この型の Name 属性から構築された型の限定名を取得します。Gets the qualified name for the type built from the Name attribute of this type. これは、スキーマ コンパイル後のプロパティです。This is a post-schema-compilation property.

(Inherited from XmlSchemaType)
SourceUri SourceUri SourceUri SourceUri

スキーマを読み込んだファイルのソース位置を取得または設定します。Gets or sets the source location for the file that loaded the schema.

(Inherited from XmlSchemaObject)
TypeCode TypeCode TypeCode TypeCode

型の XmlTypeCode を取得します。Gets the XmlTypeCode of the type.

(Inherited from XmlSchemaType)
UnhandledAttributes UnhandledAttributes UnhandledAttributes UnhandledAttributes

現在のスキーマのターゲット名前空間に属さない、修飾された属性を取得または設定します。Gets or sets the qualified attributes that do not belong to the current schema's target namespace.

(Inherited from XmlSchemaAnnotated)

メソッド

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

指定したオブジェクトが、現在のオブジェクトと等しいかどうかを判断します。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

既定のハッシュ関数として機能します。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

現在のインスタンスの Type を取得します。Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

現在の Object の簡易コピーを作成します。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

現在のオブジェクトを表す文字列を返します。Returns a string that represents the current object.

(Inherited from Object)

適用対象