MinOccurs 0 and nillable true

Setting nillable="true" means that the <birthDate> tag can appear as follows:

<birthDate xsi:nil="true"/>

However, since you also set minOccurs="0", you could also omit the <birthDate> tag completely from the XML and it would also still validate against your XSD.

Note that <birthDate/> or <birthDate></birthDate> is not considered null according to XSD rules.

Have a look at this great blog post for further reading.


Adding my view to above answers, A basic thing that many beginners don't know or take into consideration is binding the xsi variable with Schema Instance namespace.

Eg: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" [add this as a attribute anywhere in a xml opening tag].

The attribute prefix "xsi" in this case has to be bonded with the XML namespace "http://www.w3.org/2001/XMLSchema-instance". This binding can be done in any of the parent elements or in the root element itself, Where to do the binding depends on the scope for which you want the xsi to be available.

  • All the elements in nested to to declaration gets the same value
  • Even though you can use any name for binding the namespcae, for brevity its always recommended to use xsi for "http://www.w3.org/2001/XMLSchema-instance"

PS : I realized the whole importance of xml namespace bindings and prefixing attributes wherever required, when I struggled at work by staying back for 3 extra hours to understand, why my xml node is not getting validated by its xsd even in case of a nillable attribute in present in schema definition.

Tags:

Xml

Xsd

Soap

Wsdl