List Element Binding Support

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

The .NET Framework provides accurate bindings for XML attribute declarations with list types, but not for element declarations.


The <list> construct is used to define a simple type whose possible values are a white-space delimited series of values from another simple type. The types that serve as building blocks are called atomic types because they cannot be divided into anything meaningful. Any simple type, except for a list or union type, is atomic.

The following example shows the creation of a list type where the values can be white-space delimited decimals:

<xsd:simpleType name="numbersList">
  <xsd:list itemType="xsd:Decimal"/>

The .NET Framework provides bindings for the <list> element when it defines attribute types, but not element types.

When generating source code from an XML Schema document, if Xsd.exe encounters an element with a list type, it produces a field whose type is the .NET Framework type corresponding to the list's constituent type, which is the value of the itemTypeattribute. For string-based types, this translation is technically correct because a string of strings is still a string. For list types based on other simple types, such as the decimal-based type in the preceding example, the translation is erroneous.

If Xsd.exe encounters an attribute with a list type, it produces a field whose type is an array of the .NET Framework type corresponding to the value of the itemType attribute. The field appears with the attribute XmlAttributeAttribute. Following is an example of a generated field:

public System.Decimal[] numbers;

Likewise, when generating an XML Schema document from a set of classes, Xsd.exe looks for the following conditions in a field or property to produce a list type:

  • The field or property's type is an array of a type that can map to a simple type.

  • The field or property appears with an XmlAttribute attribute.

This combination can be expressed only as a <list> type, because an XML attribute must have a simple type and an array would otherwise be bound to a complex type (with a maxOccurs attribute set to unbounded).


Input XML Schema document:

<xsd:schema xmlns:xsd="" 
            targetNamespace="" xmlns="" elementFormDefault="qualified">
    <xsd:element name="alphabet" type="AlphabetType"/>

    <xsd:complexType name="AlphabetType">
            <xsd:element name="language" type="xsd:string"/>
            <xsd:element name="count" type="xsd:decimal"/>
        <xsd:attribute name="letters">
                <xsd:list itemType="Character"/>

    <xsd:simpleType name="Character">
        <xsd:restriction base="xsd:string">
            <xsd:length value="1"/>

C# class generated from the preceding XML Schema document:

[System.Xml.Serialization.XmlRootAttribute("alphabet", Namespace="", IsNullable=false)]
public class AlphabetType {
    public string language;
    public System.Decimal count;
    public string[] letters;

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

<xs:complexType name="AlphabetType">
    <xs:element minOccurs="0" maxOccurs="1" name="language" type="xs:string" />
    <xs:element minOccurs="1" maxOccurs="1" name="count" type="xs:decimal" />
  <xs:attribute name="letters">
      <xs:list itemType="xs:string" />
Possible Attributes Binding Support


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


When a list type is used as an XML attribute (but not as an element), the Xsd.exe tool produces a field that is an array of the .NET Framework type corresponding to the value of the itemType attribute.

Possible parent elements: <simpleType>

Possible child elements: <annotation>, <simpleType>

See Also