This is not a final limitation. You can change xsd to
<xsd:element name="myValue" type="xsd:float" minOccurs="0" default="0" />
And then you can provide an empty element for your float without causing rejection of your xml.
The above example means that if an element is empty, then its value is 0. Beware, the default attribute does not apply to missing elements: missing elements are simply absent, whether they have a default declared or not. http://www.w3.org/TR/xmlschema-0/#OccurrenceConstraints
if an element appears without any content, the schema processor provides the element with a value equal to the default attribute value. However, if the item does not appear in the instance document, the schema processor does not provide the item at all.
I have not used this yet, but to protect against personally reading the w3c specifications, I checked with the online validator that an xml was accepted with the empty xs: float element having a default value (at least this online validator: http: //www.freeformatter.com/xml-validator-xsd.html ).
Frédéric
source share