XmlSchemaAny クラス

定義

W3C (World Wide Web Consortium) any 要素を表します。

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

次の例では、要素を作成します any

#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();

        // <element name='htmlText'>
        XmlSchemaElement^ xeHtmlText = gcnew XmlSchemaElement();
        xeHtmlText->Name = "htmlText";

        XmlSchemaComplexType^ ct = gcnew XmlSchemaComplexType();

        XmlSchemaSequence^ sequence = gcnew XmlSchemaSequence();

        // <any namespace='http://www.w3.org/1999/xhtml'
        //    minOccurs='1' maxOccurs='unbounded'
        //    processContents='lax'/>
        XmlSchemaAny^ any = gcnew XmlSchemaAny();
        any->MinOccurs = 1;
        any->MaxOccursString = "unbounded";
        any->Namespace = "http://www.w3.org/1999/xhtml";
        any->ProcessContents = XmlSchemaContentProcessing::Lax;
        sequence->Items->Add(any);

        ct->Particle = sequence;
        xeHtmlText->SchemaType = ct;

        schema->Items->Add(xeHtmlText);

        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");
        schema->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();

        // <element name='htmlText'>
        XmlSchemaElement xeHtmlText = new XmlSchemaElement();
        xeHtmlText.Name = "htmlText";

        XmlSchemaComplexType ct = new XmlSchemaComplexType();

        XmlSchemaSequence sequence = new XmlSchemaSequence();

        // <any namespace='http://www.w3.org/1999/xhtml'
        //    minOccurs='1' maxOccurs='unbounded'
        //    processContents='lax'/>
        XmlSchemaAny any = new XmlSchemaAny();
        any.MinOccurs = 1;
        any.MaxOccursString = "unbounded";
        any.Namespace = "http://www.w3.org/1999/xhtml";
        any.ProcessContents = XmlSchemaContentProcessing.Lax;
        sequence.Items.Add(any);

        ct.Particle = sequence;
        xeHtmlText.SchemaType = ct;

        schema.Items.Add(xeHtmlText);

        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");
        schema.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()

        ' <element name='htmlText'>
        Dim xeHtmlText As New XmlSchemaElement()
        xeHtmlText.Name = "htmlText"

        Dim ct As New XmlSchemaComplexType()

        Dim sequence As New XmlSchemaSequence()

        ' <any namespace='http://www.w3.org/1999/xhtml'
        '    minOccurs='1' maxOccurs='unbounded'
        '    processContents='lax'/>
        Dim any As New XmlSchemaAny()
        any.MinOccurs = 1
        any.MaxOccursString = "unbounded"
        any.Namespace = "http://www.w3.org/1999/xhtml"
        any.ProcessContents = XmlSchemaContentProcessing.Lax
        sequence.Items.Add(any)

        ct.Particle = sequence
        xeHtmlText.SchemaType = ct

        schema.Items.Add(xeHtmlText)

        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:element name='htmlText'>
      <xs:complexType>
       <xs:sequence>
         <xs:any namespace='http://www.w3.org/1999/xhtml'
              minOccurs='1' maxOccurs='unbounded'
              processContents='lax'/>
       </xs:sequence>
      </xs:complexType>
    </xs:element>
</xs:schema>

注釈

この any 要素を使用すると、指定した名前空間または名前空間の要素を含む complexType 要素に表示できます。

コンストラクター

XmlSchemaAny()

XmlSchemaAny クラスの新しいインスタンスを初期化します。

プロパティ

Annotation

annotation プロパティを取得または設定します。

(継承元 XmlSchemaAnnotated)
Id

文字列 ID を取得または設定します。

(継承元 XmlSchemaAnnotated)
LineNumber

schema 要素が参照するファイルの行番号を取得または設定します。

(継承元 XmlSchemaObject)
LinePosition

schema 要素が参照するファイルの行番号を取得または設定します。

(継承元 XmlSchemaObject)
MaxOccurs

パーティクルが発生する最大回数を取得または設定します。

(継承元 XmlSchemaParticle)
MaxOccursString

数字を文字列値として取得または設定します。 パーティクルが発生する最大回数。

(継承元 XmlSchemaParticle)
MinOccurs

パーティクルが発生する最小回数を取得または設定します。

(継承元 XmlSchemaParticle)
MinOccursString

数字を文字列値として取得または設定します。 パーティクルが発生する最小回数。

(継承元 XmlSchemaParticle)
Namespace

使用できる要素を格納している名前空間を取得または設定します。

Namespaces

このスキーマ オブジェクトと一緒に使用する XmlSerializerNamespaces を取得または設定します。

(継承元 XmlSchemaObject)
Parent

この XmlSchemaObject の親を取得または設定します。

(継承元 XmlSchemaObject)
ProcessContents

any 要素によって指定された要素の XML ドキュメントの検証が、アプリケーションつまり XML プロセッサによってどのように処理されるかについての情報を、取得または設定します。

SourceUri

スキーマを読み込んだファイルのソース位置を取得または設定します。

(継承元 XmlSchemaObject)
UnhandledAttributes

現在のスキーマのターゲット名前空間に属さない、修飾された属性を取得または設定します。

(継承元 XmlSchemaAnnotated)

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象