users@jaxb.java.net

Re: [feature request] Using defaults from code in a XSD default.

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Fri, 27 Jun 2003 07:38:39 -0700

Even if you tell JAXB the secondary source of the default value
information, that doesn't change the contract exposed by the schema.
Or are you using your schema just to generate code?

So it seems to me that another approach is to have JAXB generate default
values as constants, and modify your application to use those constants.

Yet another approach would be to pre-process your schema with XSLT or
whatever and add default values, then run it through XJC afterward.


Gary Gregory <ggregory_at_seagullsw.com> wrote:
> Hello,
>
> Some of our code uses a third party library (Apache Jakarta Commons
> HttpClient if you must know) and we configure one of our component which
> uses it with an XML file for which we have an XSD which we generate code
> with JAXB. So far so good and we like it.
>
> Right now, the XSD must be kept in sync with various default values in the
> library. For example, the lib has a setting called "maxConnectionsPerHost"
> with a default value of 2. So, in our XSD we have:
>
> <xs:attribute name="maxConnectionsPerHost" type="cics:positiveShort"
> use="optional" default="2">
>
> and
>
> <xs:simpleType name="positiveShort">
> <xs:restriction base="xs:unsignedShort">
> <xs:minInclusive value="1"/>
> </xs:restriction>
> </xs:simpleType>
>
> It would be nice if somehow, I could tell JAXB to pick up the default value
> from "com.foo.ThatClass.THE_CONSTANT", which would minimize maintenance on
> keeping the XSD in sync with the code.
>
> Thanks,
> Gary
>


regards,
--
Kohsuke Kawaguchi                  408-276-7063 (x17063)
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com