XmlSchemaGroup Class
Represents the group element from XML Schema as specified by the . This class defines groups at the schema level that are referenced from the complex types. It groups a set of element declarations so that they can be incorporated as a group into complex type definitions.
System.Xml.Schema.XmlSchemaObject
System.Xml.Schema.XmlSchemaAnnotated
System.Xml.Schema.XmlSchemaGroup
Assembly: System.Xml (in System.Xml.dll)
The XmlSchemaGroup type exposes the following members.
| Name | Description | |
|---|---|---|
![]() ![]() | Annotation | Gets or sets the annotation property. (Inherited from XmlSchemaAnnotated.) |
![]() ![]() | Id | Gets or sets the string id. (Inherited from XmlSchemaAnnotated.) |
![]() ![]() | LineNumber | Gets or sets the line number in the file to which the schema element refers. (Inherited from XmlSchemaObject.) |
![]() ![]() | LinePosition | Gets or sets the line position in the file to which the schema element refers. (Inherited from XmlSchemaObject.) |
![]() ![]() | Name | Gets or sets the name of the schema group. |
![]() ![]() | Namespaces | Gets or sets the XmlSerializerNamespaces to use with this schema object. (Inherited from XmlSchemaObject.) |
![]() ![]() | Parent | Gets or sets the parent of this XmlSchemaObject. (Inherited from XmlSchemaObject.) |
![]() ![]() | Particle | Gets or sets one of the XmlSchemaChoice, XmlSchemaAll, or XmlSchemaSequence classes. |
![]() ![]() | QualifiedName | Gets the qualified name of the schema group. |
![]() ![]() | SourceUri | Gets or sets the source location for the file that loaded the schema. (Inherited from XmlSchemaObject.) |
![]() ![]() | UnhandledAttributes | Gets or sets the qualified attributes that do not belong to the current schema's target namespace. (Inherited from XmlSchemaAnnotated.) |
| Name | Description | |
|---|---|---|
![]() ![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() ![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() ![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() ![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() ![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() ![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
The following example shows the use of the XmlSchemaGroup class.
Option Explicit On Option Strict On Imports System Imports System.Xml Imports System.Xml.Schema Class XMLSchemaExamples Public Shared Sub Main() Dim schema As New XmlSchema() ' <xs:element name="thing1" type="xs:string"/> Dim elementThing1 As New XmlSchemaElement() schema.Items.Add(elementThing1) elementThing1.Name = "thing1" elementThing1.SchemaTypeName = New XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema") ' <xs:element name="thing2" type="xs:string"/> Dim elementThing2 As New XmlSchemaElement() schema.Items.Add(elementThing2) elementThing2.Name = "thing2" elementThing2.SchemaTypeName = New XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema") ' <xs:element name="thing3" type="xs:string"/> Dim elementThing3 As New XmlSchemaElement() schema.Items.Add(elementThing3) elementThing3.Name = "thing3" elementThing3.SchemaTypeName = New XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema") ' <xs:attribute name="myAttribute" type="xs:decimal"/> Dim myAttribute As New XmlSchemaAttribute() schema.Items.Add(myAttribute) myAttribute.Name = "myAttribute" myAttribute.SchemaTypeName = New XmlQualifiedName("decimal", "http://www.w3.org/2001/XMLSchema") ' <xs:group name="myGroupOfThings"> Dim myGroupOfThings As New XmlSchemaGroup() schema.Items.Add(myGroupOfThings) myGroupOfThings.Name = "myGroupOfThings" ' <xs:sequence> Dim sequence As New XmlSchemaSequence() myGroupOfThings.Particle = sequence ' <xs:element ref="thing1"/> Dim elementThing1Ref As New XmlSchemaElement() sequence.Items.Add(elementThing1Ref) elementThing1Ref.RefName = New XmlQualifiedName("thing1") ' <xs:element ref="thing2"/> Dim elementThing2Ref As New XmlSchemaElement() sequence.Items.Add(elementThing2Ref) elementThing2Ref.RefName = New XmlQualifiedName("thing2") ' <xs:element ref="thing3"/> Dim elementThing3Ref As New XmlSchemaElement() sequence.Items.Add(elementThing3Ref) elementThing3Ref.RefName = New XmlQualifiedName("thing3") ' <xs:complexType name="myComplexType"> Dim myComplexType As New XmlSchemaComplexType() schema.Items.Add(myComplexType) myComplexType.Name = "myComplexType" ' <xs:group ref="myGroupOfThings"/> Dim myGroupOfThingsRef As New XmlSchemaGroupRef() myComplexType.Particle = myGroupOfThingsRef myGroupOfThingsRef.RefName = New XmlQualifiedName("myGroupOfThings") ' <xs:attribute ref="myAttribute"/> Dim myAttributeRef As New XmlSchemaAttribute() myComplexType.Attributes.Add(myAttributeRef) myAttributeRef.RefName = New XmlQualifiedName("myAttribute") 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
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:attribute name="myAttribute" type="xs:decimal"/>
<xs:group name="myGroupOfThings">
<xs:sequence>
<xs:element ref="thing1"/>
<xs:element ref="thing2"/>
<xs:element ref="thing3"/>
</xs:sequence>
</xs:group>
<xs:complexType name="myComplexType">
<xs:group ref="myGroupOfThings"/>
<xs:attribute ref="myAttribute"/>
</xs:complexType>
</xs:schema>
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.



