This documentation is archived and is not being maintained.

SimpleContent Element Binding Support 

The .NET Framework provides partial binding support for the <simpleContent> element.

Simple content extension is always fully expressed through class definitions in the .NET Framework. Simple content restriction is not recognized.

The XML Schema definition language uses the <simpleContent> element to define a complex type that does not contain child elements. A complex type containing simple content (either attributes or body text, or both) is derived from a base type through either extension or restriction, using either an <extension> or <restriction> element under the <simpleContent> element.

Xsd.exe does not recognize simple content restriction. Simple content extension is always fully expressed through class definitions in the .NET Framework. When generating source code from an XML Schema document, Xsd.exe produces a public field of a type corresponding to the base type, specified by the base attribute of the <extension> element. For the bindings between built-in simple types in the XML Schema and .NET Framework types, see Data Type Support between XML Schema (XSD) Types and .NET Framework Types.

Simple content extension and restriction are represented in the Schema Object Model through the classes XmlSchemaSimpleContentExtension and XmlSchemaSimpleContentRestriction, respectively, as well as through the XmlSchemaSimpleContent class.

Objects of these classes can be used to programmatically create a schema object model, corresponding to an XSD document, that defines complex types containing simple content.


Input XML Schema document:

<xsd:schema xmlns:xsd="" 
            targetNamespace="" xmlns="" elementFormDefault="qualified">
<xsd:element name="Distance">
    <xsd:extension base="xsd:float">
     <xsd:attribute name="units" type="xsd:string"/>

C# class generated from the preceding XML Schema document:

[System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]
public class Distance {
    public string units;
    public System.Single Value;

XML Schema element and complex type generated from an assembly compiled from the preceding C# source:

<xs:element name="Distance" type="tns:Distance" />
<xs:complexType name="Distance">
    <xs:extension base="xs:float">
      <xs:attribute name="units" type="xs:string" />
Possible Attributes Binding Support


The Xsd.exe utility ignores the id attribute, which is intended to provide a unique identifier.

Possible parent elements: <complexType>

Possible child elements: <annotation>, <extension>, <restriction>