users@jaxb.java.net

Re: default element value

From: Han Ming Ong <hanming_at_mac.com>
Date: Tue, 06 May 2003 10:05:59 -0700

IIRC, it actually works. Try the getUserId() API and see if it returns
"na".

If it works, I agree that the Javadoc is buggy. Log a bug.

Cheers, Han Ming

On Tuesday, May 6, 2003, at 06:18 AM, Arek Stryjski wrote:

> I have this XML schema fragment:
>
> <xsd:complexType name="AutodebugMeta">
> <xsd:sequence>
> <xsd:element name="body-type" type="BodyType" default="test" />
> <xsd:element name="dealer-id" type="xsd:string"/>
> <xsd:element name="user-id" type="xsd:string" default="na"/>
> <xsd:element name="res-id" type="xsd:string" default="na"/>
> <xsd:element name="time" type="xsd:dateTime"/>
> </xsd:sequence>
> </xsd:complexType>
>
> In genereted class I got:
>
> /**
> * Java content class for AutodebugMeta complex type.
> * <p>The following schema fragment specifies the expected content
> contained
> within this java content object.
> * <p>
> * <pre>
> * &lt;complexType name="AutodebugMeta">
> * &lt;complexContent>
> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
> * &lt;sequence>
> * &lt;element name="body-type" type="{}BodyType"/>
> * &lt;element name="dealer-id"
> type="{http://www.w3.org/2001/XMLSchema}string"/>
> * &lt;element name="user-id"
> type="{http://www.w3.org/2001/XMLSchema}string"/>
> * &lt;element name="res-id"
> type="{http://www.w3.org/2001/XMLSchema}string"/>
> * &lt;element name="time"
> type="{http://www.w3.org/2001/XMLSchema}dateTime"/>
> * &lt;/sequence>
> * &lt;/restriction>
> * &lt;/complexContent>
> * &lt;/complexType>
> * </pre>
> *
> */
>
> Well I don't agree with sentence: "The following schema fragment
> specifies
> the expected content".
>
> I don't understand why generated code does not take default values? Is
> something wrong with my schema, or JAXB does not support this. It will
> be
> very strange if this will be not supported in version 1.0 because as
> far as
> I remember it was working in JAXB-ea for DTD.
>
> Regards
> Arek