2.3.1.1.14 <simpleType> Element Within <complexType> Elements

If the element is a <complexType> with <simpleContent> or if it is a <simpleType> element, the following mapping process MUST occur:

  • The element MUST be mapped to a DataColumn object within the DataTable object that the parent element maps to.

  • The ColumnMapping property of the DataColumn MUST be Element.

  • If the type is a <complexType> with <simpleContent>, apply the rules described in section 2.3.1.1.12.

  • If the element contains a ref attribute, the referenced type MUST be used for the remainder of the rules of this section.

  • The name of the DataColumn MUST be the name of the element. This name MUST be unique within the targetNamespace attribute that the DataColumn element is in.

  • If the type references a type from an imported element schema, the namespace property of the DataColumn MUST be the targetNamespace of this imported schema. Otherwise, the namespace of the DataTable MUST be the targetNamespace attribute from the current <schema> element.

  • The following rules that MUST be followed to determine what data type the DataColumn will map to depending on how the type and the msdata:DataType attribute are used:

    • If the msdata:DataType attribute is present, the value MUST map to a data type as specified in section 2.2.3. The msdata:DataType value will either be the namespace and the class name or a fully qualified type name as specified by [ECMA-335]. Only types that are defined in section 2.2.3 SHOULD<2> be specified in the non-fully-qualified form.

    • If the type attribute is present and the msdata:DataType attribute is present, the value of the type attribute MUST be the correct [XMLSCHEMA2] type for the value of the msdata:DataType attribute that is specified according to section 2.2.3.

    • If the type attribute is present and the msdata:DataType attribute is not present, the DataColumn data type MUST map to the data type according to section 2.2.2.

    • If the type attribute is not present, the DataColumn data type MUST map to "string".

  • The default attribute MUST not be specified if the DataColumn data type is SqlXml or any other data type that is not explicitly listed in section 2.2.3.

  • If the element has a default attribute, the DefaultValue property of the DataColumn is set to this value. The value of the default attribute MUST be serialized according to the data type-to-[XMLSCHEMA2]-type serialization rules that are described in section 2.2.3.

  • If the element has a minOccurs value of 0 and no nillable attribute is specified, the AllowDbNull property of the DataColumn MUST be mapped to true. If the minOccurs value is 1, the value of the AllowDbNull property of the DataColumn MUST be false. As specified in [XMLSCHEMA2], if minOccurs is not specified, the default value is 1, so the AllowDbNull property MUST be false.

  • If the value of the minOccurs attribute is greater than 0, the nillable attribute optionally can be specified as specified in [XMLSCHEMA2]. If the nillable attribute is specified, its value MUST be true or false, and the AllowDbNull property of the DataColumn MUST be the value of the nillable attribute. If the attribute is not specified and minOccurs is greater than 0, the nillable value MUST be false and the AllowDbNull property of the DataColumn MUST be false.

  • If the element has a minOccurs value of 0, the nillable attribute MUST be ignored.

  • If the msdata:AutoIncrement attribute is specified, the DataColumn AutoIncrement property value MUST be true or false. If the attribute is not specified, the DataColumn AutoIncrement property value MUST be false.

  • If the msdata:AutoIncrementSeed attribute is specified, the DataColumn AutoIncrementSeed property value MUST be a valid long value as specified in [XMLSCHEMA2]. If the attribute is not specified, the DataColumn AutoIncrementSeed property value MUST be zero.

  • If the msdata:AutoIncrementStep attribute is specified, the DataColumn AutoIncrementStep property value MUST be a valid long value as specified in [XMLSCHEMA2]. If the attribute is not specified, the DataColumn AutoIncrementStep property value MUST be 1.

  • If the msdata:Caption attribute is specified, the DataColumn Caption property value MUST be a valid string as specified in [XMLSCHEMA2]. If the attribute is not specified, the value MUST be the name of the DataColumn name.

  • If the msdata:Expression attribute is specified, the DataColumn Expression property value MUST be a valid string as specified in [XMLSCHEMA2]. If the attribute is not specified, the DataColumn Expression property value is an empty string.

  • If the msdata:ReadOnly attribute is specified, the DataColumn ReadOnly property value MUST be true or false. If the attribute is not specified, the DataColumn ReadOnly property value MUST be false.

  • The following attributes MUST be ignored for <simpleType> elements within <complexType> elements:

    • block

    • id

In the following schema excerpt, the following items apply:

  • "OrderID" becomes a DataColumn of the "order" DataTable.

    • Its ordinal is 0.

    • The data type of the DataColumn is "string".

    • AllowDbNull is false.

  • "OrderAmount" becomes a DataColumn of the "order" DataTable.

    • Its ordinal is 1.

    • The data type of the DataColumn is "int".

    • AllowDbNull is true.

    • The DefaultValue is set to 100.

  • "OrderDate" becomes a DataColumn of the "order" DataTable.

    • Its ordinal is 2.

    • The data type of the DataColumn is "string".

    • AllowDbNull is true.

  • "OrderItem" becomes a DataColumn of the "order" DataTable.

    • Its ordinal is 3.

    • The data type of the DataColumn is "string".

    • AllowDbNull is true. (The nillable attribute is ignored.)

  • "OrderItem2" becomes a DataColumn of the "order" DataTable.

    • Its ordinal is 4.

    • The data type of the DataColumn is "string".

    • AllowDbNull is false. (The nillable attribute is read.)

     <!-- "order" DataTable -->
             <xs:element name="order">
               <xs:complexType>
                 <xs:all>
                   <xs:element name="orderID" minOccurs="1" type="xs:string"></xs:element>
                   <xs:element name="orderAmount" minOccurs="0"  type="xs:int" default="100"></xs:element>
                   <xs:element name="orderDate" nillable="true" type="xs:string"></xs:element>
                   <xs:element name="orderItem" minOccurs="0" nillable="false" type="xs:string"></xs:element>
                   <xs:element name="orderItem2" minOccurs="1" nillable="false" type="xs:string"></xs:element>
                 </xs:all>
               </xs:complexType>
             <xs:element>