users@jaxb.java.net

JAXBElement wrapper of combined minOccurs ="0" and nillable="true"

From: landcast <landcast_at_163.com>
Date: Wed, 13 Dec 2006 11:10:30 +0800 (CST)

Hi all,

When I use jaxb to generate java type with xml schema, I found if the element in a sequence of complex type has both minOccurs="0" and nillable="true", it will generate the field, getter and setter with JAXBElement<String> instead of String, <B>is it correct</B>?

Thanks a lot.

<B>Schema part</B>:

    <xs:element name="EchoStringAsBinary">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="s" minOccurs="0" nillable="true" type="xs:string" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="EchoStringAsBinaryResponse">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="EchoStringAsBinaryResult" minOccurs="0" nillable="true"
                    type="xs:base64Binary" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>


<B>Java type generated</B>:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "s"
})
@XmlRootElement(name = "EchoStringAsBinary")
public class EchoStringAsBinary {

    @XmlElementRef(name = "s", namespace = "http://xmlsoap.org/Ping", type = JAXBElement.class)
    protected JAXBElement<String> s;

    /**
     * Gets the value of the s property.
     *
     * @return
     * possible object is
     * {_at_link JAXBElement }{_at_code <}{_at_link String }{_at_code >}
     *
     */
    public JAXBElement<String> getS() {
        return s;
    }

    /**
     * Sets the value of the s property.
     *
     * @param value
     * allowed object is
     * {_at_link JAXBElement }{_at_code <}{_at_link String }{_at_code >}
     *
     */
    public void setS(JAXBElement<String> value) {
        this.s = ((JAXBElement<String> ) value);
    }

}