Allowing null data values

If you want to allow null values in a column:

  • Attribute-based schema – allows nulls by default; the default is use="optional", so the column below is nullable.

    <xsd:attribute name="nullableColumn" type="xsd:string"/>

    You make the data for this column null by omitting any specific value for it from the XML.

  • Element-based schema – disallows nulls by default; the default is nillable="false", so you must add nillable="true".

    <xsd:element name="nullableColumn" type="xsd:string" nillable="true"/>

    You make the data for this column null by using xsi:nil="true".

    <nullableColumn xsi:nil="true"></nullableColumn>