How to handle xsi:nil="true" together with a required attribute
Please consider the following snippet of a xsd that I have to deal with:
<element name="VALUE" nillable="true">
<attribute name="UOM" type="string" use="required" />
As you can see, the VALUE element is nillabel and the UOM attribute is required.
How should I use JAXB generated classes to marshall them to the following valid XML:
<VALUE UOM="cm" xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
The problem is that in order to get xsi:nil=true I have to set "VALUE" to NULL.
This marshalls to the invalid XML (required UOM attribute is not there):
<VALUE xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
But how can I set the required UOM attribute "cm" if it is earlier set to NULL?
Is there a workaround?