users@jaxb.java.net

RE: optional attributes

From: Lagomasino, Adolfo (Adolfo) <"Lagomasino,>
Date: Thu, 20 May 2004 15:13:06 -0400

That's the same version I am using; and I am using that binding option. I don't know if any earlier version supported it.
Adolfo

-----Original Message-----
From: Jorge Medina [mailto:Jorge_Medina_Ang_Collan_at_symantec.com]
Sent: Thursday, May 20, 2004 3:09 PM
To: users_at_jaxb.dev.java.net
Subject: RE: optional attributes



Thanks. One more question: What version of JAXB supports such global binding option ?
I currently have JWSDP v1.2 that comes with JAXB 1.0.1





if (getYYY != null) {
  // the attribute was present in the original document
  setYYY(null); // this will "clear" the attribute
}
  
A more elegant approach would be to add the isSet and unset methods via the global binding
    <jxb:globalBindings generateIsSetMethod="true"/>
This will add the isSetYYY() and unsetYYY() methods so you could then do
  
if (isSetYYY()) {
  unsetYYY();
}
  
Adolfo
-----Original Message-----
From: Jorge Medina [mailto:Jorge_Medina_Ang_Collan_at_symantec.com]
Sent: Thursday, May 20, 2004 12:52 PM
To: users_at_jaxb.dev.java.net
Subject: optional attributes


I have defined some entities with optional attributes with no default value.

Lets assume the attribute is called YYY

I get the setYYY/getYYY methods on the generated interfaces.

a) Is there any way I could know if the attribute was in fact present in the original document ?

b) Is there any way to "clear" the attribute so that it is not generated to the xml document ?

Thanks.

-Jorge