This documentation is archived and is not being maintained.

XmlSchemaComplexContent Class

Represents the complexContent element from XML Schema as specified by the World Wide Web Consortium (W3C). This class represents the complex content model for complex types. It contains extensions or restrictions on a complex type that has either only elements or mixed content.

Namespace: System.Xml.Schema
Assembly: System.Xml (in system.xml.dll)

Public Class XmlSchemaComplexContent
	Inherits XmlSchemaContentModel
Dim instance As XmlSchemaComplexContent

public class XmlSchemaComplexContent extends XmlSchemaContentModel
public class XmlSchemaComplexContent extends XmlSchemaContentModel

The following example creates a complexContent element.

Option Strict On
Option Explicit On

Imports System
Imports System.Xml
Imports System.Xml.Schema

Class XMLSchemaExamples

    Public Shared Sub Main()
        Dim schema As New XmlSchema()

        ' <xs:complexType name="address">
        Dim address As New XmlSchemaComplexType()
        address.Name = "address"

        ' <xs:sequence>
        Dim sequence As New XmlSchemaSequence()
        address.Particle = sequence

        ' <xs:element name="name"   type="xs:string"/>
        Dim elementName As New XmlSchemaElement()
        elementName.Name = "name"
        elementName.SchemaTypeName = New XmlQualifiedName("string", "")

        ' <xs:element name="street"   type="xs:string"/>
        Dim elementStreet As New XmlSchemaElement()
        elementStreet.Name = "street"
        elementStreet.SchemaTypeName = New XmlQualifiedName("string", "")

        ' <xs:element name="city"   type="xs:string"/>
        Dim elementCity As New XmlSchemaElement()
        elementCity.Name = "city"
        elementCity.SchemaTypeName = New XmlQualifiedName("string", "")

        ' <xs:complexType name="USAddress">
        Dim USAddress As New XmlSchemaComplexType()
        USAddress.Name = "USAddress"

        ' <xs:complexContent>
        Dim complexContent As New XmlSchemaComplexContent()
        USAddress.ContentModel = complexContent

        ' <xs:extension base="address">
        Dim extensionAddress As New XmlSchemaComplexContentExtension()
        complexContent.Content = extensionAddress
        extensionAddress.BaseTypeName = New XmlQualifiedName("address")

        ' <xs:sequence>
        Dim sequence2 As New XmlSchemaSequence()
        extensionAddress.Particle = sequence2

        ' <xs:element name="state" type="xs:string"/>
        Dim elementUSState As New XmlSchemaElement()
        elementUSState.Name = "state"
        elementUSState.SchemaTypeName = New XmlQualifiedName("string", "")

        ' <xs:element name="zipcode" type="xs:positiveInteger"/>
        Dim elementZipcode As New XmlSchemaElement()
        elementZipcode.Name = "zipcode"
        elementZipcode.SchemaTypeName = New XmlQualifiedName("positiveInteger", "")

        Dim schemaSet As New XmlSchemaSet()
        AddHandler schemaSet.ValidationEventHandler, AddressOf ValidationCallbackOne


        Dim compiledSchema As XmlSchema = Nothing

        For Each schema1 As XmlSchema In schemaSet.Schemas()
            compiledSchema = schema1

        Dim nsmgr As New XmlNamespaceManager(New NameTable())
        nsmgr.AddNamespace("xs", "")
        compiledSchema.Write(Console.Out, nsmgr)
    End Sub 'Main

    Public Shared Sub ValidationCallbackOne(ByVal sender As Object, ByVal args As ValidationEventArgs)

    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="">
    <xs:complexType name="address">
            <xs:element name="name"   type="xs:string"/>
            <xs:element name="street" type="xs:string"/>
            <xs:element name="city"   type="xs:string"/>

    <xs:complexType name="USAddress">
        <xs:complexContent mixed="false">
            <xs:extension base="address">
                    <xs:element name="state" type="xs:string"/>
                    <xs:element name="zipcode" type="xs:positiveInteger"/>

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

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0