nil
為一布林值,表示項目是否應包含內容。
<xsi:nil="boolean">
值
true
項目必須是空的,而結構描述中的項目宣告必須具有註釋,其中 nillable 屬性是設為 true。false
項目不能是空的。 此為預設值。
範例
此範例使用 XML 結構描述 (person.xsd) 及執行個體文件 (person.xml)。 結構描述包含型別 Person,且該型別具有 name 和 height 兩個元素的元素宣告。 height 項目宣告包含了值為 true 的 nillable 屬性。 它還包含 person 項目所對應的項目宣告,其中具有對應至 com:People 命名空間的 name 和 height 兩個項目子系。 height 項目包含了值為 true 的 xsi:nil 屬性,表示該項目不應包含內容。
<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>
<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>