users@jaxb.java.net

Re: Default attribute values on derived complex type (JAXB v.1.0. 1)

From: Gary Gregory <ggregory_at_seagullsw.com>
Date: Wed, 02 Jul 2003 10:20:14 -0400

* If your schema has different default values for attributes in
different types derived from abstractMachineProfile then obviously this does
not work.

 

Thanks as always for your prompt feedback.

 

This is exactly what I am trying to do. I need to have many derived types,
all with their own attribute redefinitions.

 

Am I (1) waiting for a bug fix? (2) Hosed, this will never be implemented or
(3) Waiting for a new release to implement substitution groups which could
let me solve the problem in a different way?

 

Thanks,

Gary

 

-----Original Message-----
From: Sekhar Vajjhala [mailto:sekhar.vajjhala_at_sun.com]
Sent: Tuesday, July 01, 2003 21:43
To: JAXB-INTEREST_at_JAVA.SUN.COM
Subject: Re: Default attribute values on derived complex type (JAXB v.1.0.1)

 

We are still in the holiday closure period, as indicated in the announcement
sent
by Ryan. However, I was just checking in..

Gary Gregory wrote:

  

> JAXB does not implement the inheritance of attributes when restricting a
type, although it should.

Does it say that in the specs? I did not find it. It sure says that
substitution groups are not supported... :-(

The spec does not say that. The spec states (in Section 5.3.2 ) that
derivation by
restriction is handled the same as derivation by extension. So the generated
content
interface IntelMachineProfile extends the content interface
AbstractTargetMachineProfile. Therefore no properties are generated for
attributes such as "name" in the IntelMachineProfile.

There is nothing in the spec that precludes the XML schema from working as
you indicated. As a workaround, you can specify the default value on the
abstractTargetMachineProfile type. If your schema has different default
values for
attributes in different types derived from abstractMachineProfile then
obviously this does not work.

Sekhar

  

> I guess for know you will have to redefine the attributes (+ default
values) on the restricted types.

I thought I did that:

    <xs:complexType name="intelMachineProfile">
        <xs:complexContent>
            <xs:restriction base="cics:abstractTargetMachineProfile">
                <xs:attribute name="name" type="xs:string" use="optional"
default="Intel"/>
                <xs:attribute name="endian" type="cics:endian"
use="optional" default="little"/>
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>

Are you saying: do not use XSD-style "inheritance", do not define the
attributes in the supertype?

Gary

-----Original Message-----
From: Thomas Plümpe [mailto:thomanski_at_gmx.de <mailto:thomanski_at_gmx.de> ]
Sent: Tuesday, July 01, 2003 01:14
To: JAXB-INTEREST_at_JAVA.SUN.COM
Subject: Re: Default attribute values on derived complex type (JAXB v.1.0.1)


Hi Gary,

> I'd like the JAXB object to give me "Intel" and "little" for the
> attributes, it gives me nulls. I am stuck.
I've had a similar problem, the reason for which was that JAXB does not
implement the inheritance of attributes when restricting a type,
although it should.

I guess for know you will have to redefine the attributes (+ default
values) on the restricted types.

Thomas