XmlSchemaAll クラス
グループ内の要素が格納する側の要素内に任意の順で表示できる (または表示しない) ように許可します。W3C (World Wide Web Consortium) All 要素 (コンポジタ) を表します。
この型のすべてのメンバの一覧については、XmlSchemaAll メンバ を参照してください。
System.Object
System.Xml.Schema.XmlSchemaObject
System.Xml.Schema.XmlSchemaAnnotated
System.Xml.Schema.XmlSchemaParticle
System.Xml.Schema.XmlSchemaGroupBase
System.Xml.Schema.XmlSchemaAll
Public Class XmlSchemaAll
Inherits XmlSchemaGroupBase
[C#]
public class XmlSchemaAll : XmlSchemaGroupBase
[C++]
public __gc class XmlSchemaAll : public XmlSchemaGroupBase
[JScript]
public class XmlSchemaAll extends XmlSchemaGroupBase
スレッドセーフ
この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。
使用例
[Visual Basic, C#, C++] All 要素を作成する例を次に示します。
Option Strict
Option Explicit
Imports System
Imports System.Xml
Imports System.Xml.Schema
Public Class Sample
Public Shared Sub Main()
Dim schema As New XmlSchema()
Dim thing1 As New XmlSchemaElement()
thing1.Name = "thing1"
thing1.SchemaTypeName = New XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema")
schema.Items.Add(thing1)
Dim thing2 As New XmlSchemaElement()
thing2.Name = "thing2"
thing2.SchemaTypeName = New XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema")
schema.Items.Add(thing2)
Dim thing3 As New XmlSchemaElement()
thing3.Name = "thing3"
thing3.SchemaTypeName = New XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema")
schema.Items.Add(thing3)
Dim thing4 As New XmlSchemaElement()
thing4.Name = "thing4"
thing4.SchemaTypeName = New XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema")
schema.Items.Add(thing4)
Dim myAttribute As New XmlSchemaAttribute()
myAttribute.Name = "myAttribute"
myAttribute.SchemaTypeName = New XmlQualifiedName("decimal", "http://www.w3.org/2001/XMLSchema")
schema.Items.Add(myAttribute)
Dim myComplexType As New XmlSchemaComplexType()
myComplexType.Name = "myComplexType"
Dim complexType_all As New XmlSchemaAll()
Dim complexType_all_thing1 As New XmlSchemaElement()
complexType_all_thing1.RefName = New XmlQualifiedName("thing1", "")
complexType_all.Items.Add(complexType_all_thing1)
Dim complexType_all_thing2 As New XmlSchemaElement()
complexType_all_thing2.RefName = New XmlQualifiedName("thing2", "")
complexType_all.Items.Add(complexType_all_thing2)
Dim complexType_all_thing3 As New XmlSchemaElement()
complexType_all_thing3.RefName = New XmlQualifiedName("thing3", "")
complexType_all.Items.Add(complexType_all_thing3)
Dim complexType_all_thing4 As New XmlSchemaElement()
complexType_all_thing4.RefName = New XmlQualifiedName("thing4", "")
complexType_all.Items.Add(complexType_all_thing4)
myComplexType.Particle = complexType_all
Dim complexType_myAttribute As New XmlSchemaAttribute()
complexType_myAttribute.RefName = New XmlQualifiedName("myAttribute", "")
myComplexType.Attributes.Add(complexType_myAttribute)
schema.Items.Add(myComplexType)
schema.Compile(AddressOf ValidationCallbackOne)
Dim nsmgr As New XmlNamespaceManager(New NameTable())
nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema")
schema.Write(Console.Out, nsmgr)
End Sub 'Main
Private Shared Sub ValidationCallbackOne(sender As Object, args As ValidationEventArgs)
Console.WriteLine(args.Message)
End Sub 'ValidationCallbackOne
End Class 'Sample
[C#]
using System;
using System.Xml;
using System.Xml.Schema;
public class Sample {
public static void Main() {
XmlSchema schema = new XmlSchema();
XmlSchemaElement thing1 = new XmlSchemaElement();
thing1.Name = "thing1";
thing1.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");
schema.Items.Add(thing1);
XmlSchemaElement thing2 = new XmlSchemaElement();
thing2.Name = "thing2";
thing2.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");
schema.Items.Add(thing2);
XmlSchemaElement thing3 = new XmlSchemaElement();
thing3.Name = "thing3";
thing3.SchemaTypeName =
new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");
schema.Items.Add(thing3);
XmlSchemaElement thing4 = new XmlSchemaElement();
thing4.Name = "thing4";
thing4.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");
schema.Items.Add(thing4);
XmlSchemaAttribute myAttribute = new XmlSchemaAttribute();
myAttribute.Name = "myAttribute";
myAttribute.SchemaTypeName = new XmlQualifiedName("decimal", "http://www.w3.org/2001/XMLSchema");
schema.Items.Add(myAttribute);
XmlSchemaComplexType myComplexType = new XmlSchemaComplexType();
myComplexType.Name = "myComplexType";
XmlSchemaAll complexType_all = new XmlSchemaAll();
XmlSchemaElement complexType_all_thing1 = new XmlSchemaElement();
complexType_all_thing1.RefName = new XmlQualifiedName("thing1", "");
complexType_all.Items.Add(complexType_all_thing1);
XmlSchemaElement complexType_all_thing2 = new XmlSchemaElement();
complexType_all_thing2.RefName = new XmlQualifiedName("thing2", "");
complexType_all.Items.Add(complexType_all_thing2);
XmlSchemaElement complexType_all_thing3 = new XmlSchemaElement();
complexType_all_thing3.RefName = new XmlQualifiedName("thing3", "");
complexType_all.Items.Add(complexType_all_thing3);
XmlSchemaElement complexType_all_thing4 = new XmlSchemaElement();
complexType_all_thing4.RefName = new XmlQualifiedName("thing4", "");
complexType_all.Items.Add(complexType_all_thing4);
myComplexType.Particle = complexType_all;
XmlSchemaAttribute complexType_myAttribute = new XmlSchemaAttribute();
complexType_myAttribute.RefName = new XmlQualifiedName("myAttribute", "");
myComplexType.Attributes.Add(complexType_myAttribute);
schema.Items.Add(myComplexType);
schema.Compile(new ValidationEventHandler(ValidationCallbackOne));
XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());
nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");
schema.Write(Console.Out, nsmgr);
}
private static void ValidationCallbackOne(object sender, ValidationEventArgs args) {
Console.WriteLine(args.Message);
}
}
[C++]
#using <mscorlib.dll>
#using <System.Xml.dll>
using namespace System;
using namespace System::Xml;
using namespace System::Xml::Schema;
public __gc class Sample {
public:
static void main() {
XmlSchema* schema = new XmlSchema();
XmlSchemaElement* thing1 = new XmlSchemaElement();
thing1->Name = S"thing1";
thing1->SchemaTypeName = new XmlQualifiedName(S"string", S"http://www.w3.org/2001/XMLSchema");
schema->Items->Add(thing1);
XmlSchemaElement* thing2 = new XmlSchemaElement();
thing2->Name = S"thing2";
thing2->SchemaTypeName = new XmlQualifiedName(S"string", S"http://www.w3.org/2001/XMLSchema");
schema->Items->Add(thing2);
XmlSchemaElement* thing3 = new XmlSchemaElement();
thing3->Name = S"thing3";
thing3->SchemaTypeName =
new XmlQualifiedName(S"string", S"http://www.w3.org/2001/XMLSchema");
schema->Items->Add(thing3);
XmlSchemaElement* thing4 = new XmlSchemaElement();
thing4->Name = S"thing4";
thing4->SchemaTypeName = new XmlQualifiedName(S"string", S"http://www.w3.org/2001/XMLSchema");
schema->Items->Add(thing4);
XmlSchemaAttribute* myAttribute = new XmlSchemaAttribute();
myAttribute->Name = S"myAttribute";
myAttribute->SchemaTypeName = new XmlQualifiedName(S"decimal", S"http://www.w3.org/2001/XMLSchema");
schema->Items->Add(myAttribute);
XmlSchemaComplexType* myComplexType = new XmlSchemaComplexType();
myComplexType->Name = S"myComplexType";
XmlSchemaAll* complexType_all = new XmlSchemaAll();
XmlSchemaElement* complexType_all_thing1 = new XmlSchemaElement();
complexType_all_thing1->RefName = new XmlQualifiedName(S"thing1", S"");
complexType_all->Items->Add(complexType_all_thing1);
XmlSchemaElement* complexType_all_thing2 = new XmlSchemaElement();
complexType_all_thing2->RefName = new XmlQualifiedName(S"thing2", S"");
complexType_all->Items->Add(complexType_all_thing2);
XmlSchemaElement* complexType_all_thing3 = new XmlSchemaElement();
complexType_all_thing3->RefName = new XmlQualifiedName(S"thing3", S"");
complexType_all->Items->Add(complexType_all_thing3);
XmlSchemaElement* complexType_all_thing4 = new XmlSchemaElement();
complexType_all_thing4->RefName = new XmlQualifiedName(S"thing4", S"");
complexType_all->Items->Add(complexType_all_thing4);
myComplexType->Particle = complexType_all;
XmlSchemaAttribute* complexType_myAttribute = new XmlSchemaAttribute();
complexType_myAttribute->RefName = new XmlQualifiedName(S"myAttribute", S"");
myComplexType->Attributes->Add(complexType_myAttribute);
schema->Items->Add(myComplexType);
schema->Compile(new ValidationEventHandler(0, ValidationCallbackOne));
XmlNamespaceManager* nsmgr = new XmlNamespaceManager(new NameTable());
nsmgr->AddNamespace(S"xs", S"http://www.w3.org/2001/XMLSchema");
schema->Write(Console::Out,nsmgr);
}
private:
static void ValidationCallbackOne(Object* /*sender*/, ValidationEventArgs* args) {
Console::WriteLine(args->Message);
}
};
int main()
{
Sample::main();
}
[Visual Basic, C#, C++] 前述のコード例に対して生成される XML ファイルを次に示します。
<?xml version="1.0" encoding="IBM437"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="thing1" type="xs:string"/>
<xs:element name="thing2" type="xs:string"/>
<xs:element name="thing3" type="xs:string"/>
<xs:element name="thing4" type="xs:string"/>
<xs:attribute name="myAttribute" type="xs:decimal"/>
<xs:complexType name="myComplexType">
<xs:all>
<xs:element ref="thing1" />
<xs:element ref="thing2" />
<xs:element ref="thing3" />
<xs:element ref="thing4" />
</xs:all>
<xs:attribute ref="myAttribute"/>
</xs:complexType>
</xs:schema>
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
名前空間: System.Xml.Schema
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
アセンブリ: System.Xml (System.Xml.dll 内)