Why does JAXB not create a member variable in its generated code when an XML schema base type and subtype have the same element declared in them?
- by belltower
I have a question regarding with regard to JAXB generated classes.
As you can I see, I have a complex type, DG_PaymentIdentification1, declared in my schema.
Its a restriction of PaymentIdentification1. DG_PaymentIdentification1 is also identical to
PaymentIdentification1. I also have a type called DG_CreditTransferTransactionInformation10
which has a base type of CreditTransferTransactionInformation10 and is identical to it.
I have included the relevant XML schema snippets below.
<xs:complexType name="DG_PaymentIdentification1">
<xs:complexContent>
<xs:restriction base="PaymentIdentification1">
<xs:sequence>
<xs:element name="InstrId" type="DG_Max35Text_REF" minOccurs="0"/>
<xs:element name="EndToEndId" type="DG_Max35Text_REF" id="DG-41"/>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="PaymentIdentification1">
<xs:sequence>
<xs:element name="InstrId" type="Max35Text" minOccurs="0"/>
<xs:element name="EndToEndId" type="Max35Text"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="DG_CreditTransferTransactionInformation10">
<xs:complexContent>
<xs:restriction base="CreditTransferTransactionInformation10">
<xs:sequence>
<xs:element name="PmtId" type="DG_PaymentIdentification1"/>
<xs:simpleType name="DG_Max35Text_REF">
<xs:restriction base="DG_NotEmpty35">
<xs:pattern value="[\-A-Za-z0-9\+/\?:\(\)\.,' ]*"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="Max35Text">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="35"/>
</xs:restriction>
</xs:simpleType>
JAXB generates the following java class for DG_PaymentIdentification1:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "DG_CreditTransferTransactionInformDGion10")
public class DGCreditTransferTransactionInformation10
extends CreditTransferTransactionInformation10
{
}
My question is why doesnt the DGCreditTransferTransactionInformation10 generated class have a variable
of type DG_PaymentIdentification1 in the generated code? The base class CreditTransferTransactionInformation10
does have a type PaymentIdentification1 declared in it.
Is there any way of ensuring that DGCreditTransferTransactionInformation10 will have a DG_PaymentIdentification1
in it?