Export (0) Print
Expand All

XmlSchemaAll Class

Permits the elements in the group to appear (or not appear) in any order in the containing element. Represents the World Wide Web Consortium (W3C) all element (compositor).

For a list of all members of this type, see XmlSchemaAll Members.

System.Object
   System.Xml.Schema.XmlSchemaObject
      System.Xml.Schema.XmlSchemaAnnotated
         System.Xml.Schema.XmlSchemaParticle
            System.Xml.Schema.XmlSchemaGroupBase
               System.Xml.Schema.XmlSchemaAll

[Visual Basic]
Public Class XmlSchemaAll
   Inherits XmlSchemaGroupBase
[C#]
public class XmlSchemaAll : XmlSchemaGroupBase
[C++]
public __gc class XmlSchemaAll : public XmlSchemaGroupBase
[JScript]
public class XmlSchemaAll extends XmlSchemaGroupBase

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Example

[Visual Basic, C#, C++] The following example creates an all element.

[Visual Basic] 
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++] 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: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] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Xml.Schema

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System.Xml (in System.Xml.dll)

See Also

XmlSchemaAll Members | System.Xml.Schema Namespace

Show:
© 2014 Microsoft