users@jaxb.java.net

Re: Nillable, minOccurs="0", maxOccurs="unbounded", JAXBElement necessary?

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Mon, 31 Dec 2012 17:02:15 +0100

Since ArrayList allows null element there's no need for the more elaborate
JAXBElement. A null List element should result in a
<foo xsi:nil="true"/>

-W


On 31/12/2012, slapnutcity_at_hotmail.com <slapnutcity_at_hotmail.com> wrote:
> I've got an XSD (a part of a bigger XSD which I do not have control
> over), which is provided below.
>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> <xsd:element name="foo">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="bar" type="xsd:string"
> nillable="true" minOccurs="0" maxOccurs="unbounded"/>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
> </xsd:schema>
>
> I has an element "bar" which is of type "string", is nillable, does not
> have to occur, but it can also occur more than once. I've understood to
> make a difference between a nillable element and an element not
> provided, a JAXBElement is used.
>
> When I generate classes by using xjc, I get a class Foo with a
> List<String> bar.Isn't it supposed to be List<JAXBElement<String>> bar?
> If not, how can I make the difference between a value not provided and
> a nil value? When it is a nil value, it should be able to hold an
> attribute defining it has "noValue" (part of the specification I'm
> working with).
>