nil

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - XML Schemas

nil

A Boolean value that indicates if an element should contain content.

<xsi:nil="boolean">

Values

true
The element must be empty and the element declaration in the schema must have an annotation where the nillable attribute is set to true.
false
The element cannot be empty. This is the default value.

Example

This example uses an XML Schema, person.xsd, and an instance document, person.xml. The schema contains a type Person that has element declarations for name and height elements. The height element declaration includes a nillable attribute with a value of true. It also contains an element declaration that maps the person element, with its name and height child elements that map to the com:People namespace. The height element includes an xsi:nil attribute with its value set to true to indicate that the element should not contain content.

<!-- person.xsd -->
<xs:schema xmlns:xs= "http://www.w3.org/2001/XMLSchema"
   targetNamespace="urn:contoso-com:People"
   xmlns:ns="urn:contoso-com:People">

   <xs:complexType name="Person">
      <xs:sequence>
         <xs:element name= "name" type="xs:string"/>
         <xs:element name= "height" type="xs:double" nillable="true" />
      </xs:sequence>
   </xs:complexType>

   <xs:element name="Person" type="ns:Person" />
</xs:schema>

<!—person.xml -->
<p:person xmlns:p="urn:contoso-com:People">
   <name>John</name>
   <height xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
      xsi:nil="true" />
</p:person>

See Also

XML Schema Reference | XML Schema Elements | XML Schema Instance Attributes