XmlSchemaSimpleTypeUnion Class
Represents the union element for simple types from XML Schema as specified by the . A union datatype can be used to specify the content of a simpleType. The value of the simpleType element must be any one of a set of alternative datatypes specified in the union. Union types are always derived types and must comprise at least two alternative datatypes.
System.Xml.Schema.XmlSchemaObject
System.Xml.Schema.XmlSchemaAnnotated
System.Xml.Schema.XmlSchemaSimpleTypeContent
System.Xml.Schema.XmlSchemaSimpleTypeUnion
Assembly: System.Xml (in System.Xml.dll)
The XmlSchemaSimpleTypeUnion type exposes the following members.
| Name | Description | |
|---|---|---|
![]() ![]() | XmlSchemaSimpleTypeUnion | Initializes a new instance of the XmlSchemaSimpleTypeUnion class. |
| Name | Description | |
|---|---|---|
![]() ![]() | Annotation | Gets or sets the annotation property. (Inherited from XmlSchemaAnnotated.) |
![]() ![]() | BaseMemberTypes | Gets an array of XmlSchemaSimpleType objects representing the type of the simpleType element based on the BaseTypes and MemberTypes values of the simple type. |
![]() ![]() | BaseTypes | Gets the collection of base types. |
![]() ![]() | 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.) |
![]() ![]() | MemberTypes | Gets or sets the array of qualified member names of built-in data types or simpleType elements defined in this schema (or another schema indicated by the specified namespace). |
![]() ![]() | 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.) |
![]() ![]() | 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 XmlSchemaSimpleTypeUnion class.
Imports System Imports System.Xml Imports System.Xml.Schema Class XMLSchemaExamples Public Shared Sub Main() Dim schema As New XmlSchema() ' <xs:simpleType name="StringOrIntType"> Dim StringOrIntType As New XmlSchemaSimpleType() StringOrIntType.Name = "StringOrIntType" schema.Items.Add(StringOrIntType) ' <xs:union> Dim union As New XmlSchemaSimpleTypeUnion StringOrIntType.Content = union ' <xs:simpleType> Dim simpleType1 As New XmlSchemaSimpleType union.BaseTypes.Add(simpleType1) ' <xs:restriction base="xs:string"/> Dim restriction1 As New XmlSchemaSimpleTypeRestriction() restriction1.BaseTypeName = New XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema") simpleType1.Content = restriction1 ' <xs:simpleType> Dim simpleType2 As New XmlSchemaSimpleType() union.BaseTypes.Add(simpleType2) ' <xs:restriction base="xs:int"/> Dim restriction2 As New XmlSchemaSimpleTypeRestriction() restriction2.BaseTypeName = New XmlQualifiedName("int", "http://www.w3.org/2001/XMLSchema") simpleType2.Content = restriction2 ' <xs:element name="size" type="StringOrIntType"/> Dim elementSize As New XmlSchemaElement() elementSize.Name = "size" elementSize.SchemaTypeName = New XmlQualifiedName("StringOrIntType") schema.Items.Add(elementSize) 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
The following XML file is generated for this code example.
<?xml version="1.0" encoding="IBM437"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="StringOrIntType">
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:string"/>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:int"/>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:element name="size" type="StringOrIntType"/>
</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.



