users@jaxb.java.net

Re: default values

From: Sekhar Vajjhala <sekhar.vajjhala_at_sun.com>
Date: Mon, 03 Mar 2003 22:22:50 -0500

mike gabelmann wrote:

> I have created a schema for JAXB that defines elements with default values.
> When I compile this schema and try to use it the default values are not
> used, or if they are used the wrong ones are.
>
> <xsd:element name="thumb_width" type="xsd:int" default="100"/>
> <xsd:element name="thumb_required" type="xsd:boolean" default="true"/>
>
> I get back something like:
> <thumb_width>0</thumb_width>
> <thumb_required>false</thumb_required>
>
> instead of:
> <thumb_width>100</thumb_width>
> <thumb_required>true</thumb_required>
>
> Do I need to do something specific to set default properties?

To add to Kohsuke's email reply.

JAXB specification itself requires element defaulting to be supported,
even though JAXB RI currently does not do so at the present time.
Support for element defaulting will be added to JAXB RI in a future release.

Sekhar