MinOccurs 0 and nillable true

SpongebobJunior picture SpongebobJunior · Apr 20, 2016 · Viewed 46.5k times · Source

In my wsdl I have an element:

<xsd:element minOccurs="0" name="birthDate" nillable="true" type="xsd:dateTime"/>

I know that the nillable true allows null values does this means that it can allow xml empty tag? i.e

<birthDate/>

Answer

Tim Biegeleisen picture Tim Biegeleisen · Apr 20, 2016

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.