2.8. Nil Values

XSD lets you indicate explicitly that an element is nil (Nothing in VB) as opposed to empty (that is, no content). For example, if you were out of chocolate cake and the DessertMenu object had only two items, you'd expect Item3 to be Nothing. To express this in the schema and instance document, you perform two steps. First, modify the schema so that the item elements are nillable:

<!-- the DessertMenu --> 
<element name="DessertMenu">
  <complexType>
    <sequence>
      <element name="Item1" type="dx:Dessert" nillable="true" />
      <element name="Item2" type="dx:Dessert" nillable="true"/>
      <element name="Item3" type="dx:Dessert" nillable="true"/>
    </sequence>
  </complexType>
</element>

then modify the XML instance document by adding xsi:nil=

Get Real World XML Web Services: For VB and VB .NET Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.