users@jaxb.java.net

Re: Jaxb 1.0.1 and defaults values

From: Tim Davidson <tim.davidson_at_greenhatconsulting.com>
Date: Fri, 06 Jun 2003 17:37:55 +0100

looking at your email, I have just changed <xs:element... to <xs:attribute... and it works! great!

This was what was generated:

    public java.lang.String getUserID() {
        if (_UserID == null) {
            return "fred";
        } else {
            return _UserID;
        }
    }

Thanks again.

-----Original Message-----
From: Joe Fialli [mailto:Joseph.Fialli_at_Sun.COM]
Sent: Friday, June 06, 2003 5:09 PM
To: JAXB-INTEREST_at_JAVA.SUN.COM
Subject: Re: Jaxb 1.0.1 and defaults values


Tim Davidson wrote:

>hello people,
>
> I managed to get jaxb 1.0.1 working with my schmas, but it still doesn't appear to be picking up default values from the schma. We are using the jaxb generated classes as a bean on a web site and we require defaults. Is this still a bug? or are the defaults for the generated xml only and not the class itself? can you reccommend a fix?
>
Are you inquiring what happens to a JAXB property that is related to an
XML Schema attribute with a default value?

Lets use the following explicit example that I am assuming summarizes
your situation:

XML Schema fragrment <xs:attribute name="Foo" type="xsd:string"
default="default value"/>

Java Fragrment:
XXX x = (XXX)ObjectFactory.createXXX()
x.getFoo() should return "default value" and you are seeing "" instead.

Additionally, were you looking for element defaulting as well as
attribute defaulting.

-Joe Fialli, Sun Microsystems

>
>regards
>
>
>