XML : XSD complexType sequence needs to allow empty string

This is a JAXB / XSD related problem. A complexType is defined as

  <xsd:complexType name="IndustryDateTimeType">    <xsd:sequence>      <xsd:element name="Date" type="xsd:date"></xsd:element>      <xsd:element minOccurs="0" name="Time" type="xsd:time"></xsd:element>    </xsd:sequence>  </xsd:complexType>    

The new requirement is that the date that is passed in XML could be an empty string, say,

  <startdate></startdate>     

where startdate is of type IndustryDateTimeType.

I figure I cannot have a union of a complexType and String - a simple type (allowing empty string). xsd:choice does not seem to be a good solution in this case. I have tried various combinations, but they are not working.

Also I cannot ask user to write an XML element like this

  <startdate xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>    

No comments:

Post a Comment