users@jaxb.java.net

RE: optional attributes

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

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