I /am/ looking for element defaulting. I guess I /could/ change my XSD to
use attributes. Can we expect element defaulting in a maintenance release?
For example, I have:
<xs:element name="keepAliveTimeMillis" type="xs:int" default="60000"
minOccurs="0">
but
ThreadPoolType type = new ObjectFactory().createThreadPool();
int x = type.getKeepAliveTimeMillis();
returns 0 and not 60000.
Gary
-----Original Message-----
From: Tim Davidson [mailto:tim.davidson_at_greenhatconsulting.com]
Sent: Friday, June 06, 2003 09:38
To: JAXB-INTEREST_at_JAVA.SUN.COM
Subject: Re: Jaxb 1.0.1 and defaults values
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
>
>
>