Hello all,
I am wondering if I am missing something in my XSD. I am getting null values
out of attributes that have default values defined. I have an abstract
complex type which defines 2 optional attributes:
<xs:simpleType name="endian">
<xs:restriction base="xs:string">
<xs:enumeration value="big"/>
<xs:enumeration value="little"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="abstractTargetMachineProfile" abstract="true">
<xs:annotation>
<xs:documentation>Defines the target server machine
profile.</xs:documentation>
</xs:annotation>
<xs:attribute name="name" type="xs:string" use="optional"/>
<xs:attribute name="endian" type="cics:endian" use="optional"/>
</xs:complexType>
Then I have two types derived by restriction. This one is the problem:
<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>
When I parse XML like:
<intelMachineProfile/>
I'd like the JAXB object to give me "Intel" and "little" for the attributes,
it gives me nulls. I am stuck.
Here are some more details:
<xs:group name="targetMachineProfile">
<!-- JAXB 1.0.1 does not support substitution groups. Redo when it
does. -->
<xs:choice>
<xs:element name="targetMachineProfile"
type="cics:targetMachineProfile"/>
<xs:element name="intelTargetMachineProfile"
type="cics:intelMachineProfile"/>
</xs:choice>
</xs:group>
<xs:simpleType name="endian">
<xs:restriction base="xs:string">
<xs:enumeration value="big"/>
<xs:enumeration value="little"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="abstractTargetMachineProfile" abstract="true">
<xs:annotation>
<xs:documentation>Defines the target server machine
profile.</xs:documentation>
</xs:annotation>
<xs:attribute name="name" type="xs:string" use="optional"/>
<xs:attribute name="endian" type="cics:endian" use="optional"/>
</xs:complexType>
<xs:complexType name="targetMachineProfile">
<xs:annotation>
<xs:documentation>Defines the target server machine
profile.</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:restriction base="cics:abstractTargetMachineProfile">
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="endian" type="cics:endian"
use="required"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<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>
I've attached the relevant files.
I am building with Ant 1.5.3, Java 1.3.1_08, JAXB 1.0.1, Xalan 2.5.1.
Thanks,
Gary