Skip to main content

Derivation By Restriction - JAXBElement Types not getting generated when Global Type has nillable = true
Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
No replies
mangeshg
Offline
Joined: 2013-06-19

Hello There,
We have a situation where in we are using the Derivation by Restriction approach to design our XSD.
Following is the sample which we are having to use this XSD feature.
<---------------PARENT------------------------------->
<complexType name="Parent">
<sequence>
<element ref="NillableElement" minOccurs="0"
maxOccurs="1">
</element>
</sequence>
</complexType>
<---------------Child------------------------------->
<complexType name="Child">
<complexContent>
<restriction base="Parent">
<sequence>
<element ref="NillableElement" minOccurs="1"
maxOccurs="1">
        </element>
                       </sequence>
</restriction>
</complexContent>
</complexType>

<----------Nillable Element Definition------------------>
    <element name="NillableElement" nillable="true">
    <simpleType>
    <restriction base="string">
    <minLength value="1"></minLength>
    <maxLength value="20"></maxLength>
    </restriction>
    </simpleType>
    </element>

We are using JAXB 2.1 to generate the Java Classes using wsimport.
The generated java Class for Parent has the NillableElement as a Type of String but we expect it to be JAXBElement.

We dont want to use generateElementProperty setting at the Global or local level as prescribed in the JAXB Specification.
Is there any other way by which we can achieve it ?