users@jaxb.java.net

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

From: Slappy zd <slapnutcity_at_hotmail.com>
Date: Tue, 1 Jan 2013 01:41:05 +0000

If a null value is specified, how can I add an attribute with a specific value, "noValue"? It is part of the specification I must follow on which the xsd is based, so I cannot change that. Just nil="true" is not allowed (functionally speaking).

> Date: Mon, 31 Dec 2012 17:02:15 +0100
> Subject: Re: Nillable, minOccurs="0", maxOccurs="unbounded", JAXBElement necessary?
> From: wolfgang.laun_at_gmail.com
> To: users_at_jaxb.java.net
>
> 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).
> >