MinOccurs 0 and nillable true
In my wsdl, I have an element:
<xsd:element minOccurs="0" name="birthDate" nillable="true" type="xsd:dateTime"/> I know that nillable true allows null values ββto be used, does that mean that it can allow an empty xml tag? iee
<birthDate/> Setting nillable="true" means that the <birthDate> may look like this:
<birthDate xsi:nil="true"/> However, since you also set minOccurs="0" , you can also completely omit the <birthDate> from XML, and it will also check your XSD.
Please note that <birthDate/> or <birthDate></birthDate> not considered null according to XSD rules.
Check out this great blog for further reading.
Adding my view to the answers above. The main thing that many beginners do not know or do not take into account is the binding of the xsi variable to the namespace of the schema instances.
For example: xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" [add this as an attribute anywhere in the xml tag that opens].
The xsi attribute prefix "in this case must be associated 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 bind depends on the area for which you want xsi to be available.
- All elements attached to the ad get the same value.
- Even if you can use any name to bind pcae names, for brevity it is always recommended to use xsi for " http://www.w3.org/2001/XMLSchema-instance "
PS: I realized the importance of linking the xml namespace and attribute prefixes wherever needed, when I struggled to work, staying 3 extra hours to understand why my xml node does not receive confirmation from xsd even in the case of the nillable attribute present in the schema definition.
if MinOccurs 0 and nillable true do not allow us to set zero values, then what parameters should be set to fields as zero and optional?