...">

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/> 
+13
soap wsdl xml xsd
source share
3 answers

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.

+16
source share

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.

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.

0
source share

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?

0
source share

All Articles