Does it mean the XML element is mandatory ? Or the XML element must have some non-null value ? I am really confused by the javadoc explanation.
@XMLElement(required=true)
generates something like this in the XML schema:
<xs:element name="city" type="xs:string" minOccurs="1"/>
which means the element and a value are mandatory. The default is false.
This:
@XMLELement(nillable=true)
generates something like this in the XML schema:
<xs:element name="city" type="xs:string" nillable="true"/>
which means you can pass in a nil value in your XML like this:
<city xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
Combining the two like this:
@XMLELement(nillable=true, required=true)
gives an XML schema definition similar to this:
<xs:element name="city" type="xs:string" nillable="true"/>
which means the element is mandatory but you can pass in a nil value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With