users@jaxb.java.net

Re: empty element

From: Robert Lowe <rmlowe_at_rmlowe.com>
Date: Mon, 19 May 2003 19:11:16 +0800

I guess it depends how the complex type is bound.

If it's bound to a content list, you'll need to clear the list, as in
xmlHeader.getMessageId().getContent().clear().

If it's bound to individual properties then you'll need to set them to null
individually:

MessageIdType messageId = xmlHeader.getMessageId();
messageId.setProperty1(null);
messageId.setProperty2(null);
messageId.setProperty3(null);

Or possibly a combination of the above...


----- Original Message -----
From: "David Massart" <david.massart_at_longboy.eun.org>
To: <JAXB-INTEREST_at_JAVA.SUN.COM>
Sent: Monday, May 19, 2003 6:57 PM
Subject: Re: empty element


> On Mon, May 19, 2003 at 06:45:12PM +0800, Robert Lowe wrote:
> > OK, how about xmlHeader.setMessageId("")?
> >
> > This might generate <messageId></mesageId> rather than <messageId/>, but
> > they are logically equivalent.
> >
>
> The problem is that the type of the empty element is not necessarily a
String.
> Actually, in my current project it can be a rather sofisticated
complexType.
>
> >
> > ----- Original Message -----
> > From: "David Massart" <david.massart_at_longboy.eun.org>
> > To: <JAXB-INTEREST_at_JAVA.SUN
>
> --
> The o .COM>
> > Sent: Monday, May 19, 2003 6:23 PM
> > Subject: Re: empty element
> >
> >
> > > Quoting Robert Lowe <rmlowe_at_rmlowe.com>:
> > >
> > > > How about xmlHeader.setMessageId(null)?
> > >
> > > In this case the element is completly absent, not empty.
> > >
> > > >