users@jaxb.java.net

Re: newbe - missing defaultValue on attributes

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Tue, 16 Sep 2008 14:39:43 +0200

The annotation XmlAttribute doesn't have an element "defaultValue". Look at
the getter for the attribute, it should contain a statement like this
  if( test1 == null ){ return true; } else { return test1; }

So, why does a schema element require this extra annotation element? That's
because the schema definition of an element permits you to say <xsd:element
... nillable="true" ...>. This means that the Java null for an element has
two possible interpretations in XML: (1) the omission of the element (2)
<elem xsi:nil="true"/>.

Wolfgang

On Tue, Sep 16, 2008 at 1:57 PM, Mike Skells <mike.skells_at_validsoft.com>wrote:

> Hi, I am using 2.1.8 and I am missing default values from attributes. when
> I generate with this XSD I get public class Def { @XmlElement(defaultValue =
> "true") protected Boolean test2; @XmlAttribute protected Boolean test1; ...
> } I would expect to see @XmlAttribute(defaultValue = "true") protected
> Boolean test1; Have I missed something.
> ------------------------------
> View this message in context: newbe - missing defaultValue on attributes<http://www.nabble.com/newbe---missing-defaultValue-on-attributes-tp19510263p19510263.html>
> Sent from the java.net - jaxb users mailing list archive<http://www.nabble.com/java.net---jaxb-users-f13500.html>at Nabble.com.
>