Hi,
I am working with 2 schemas and the structure follows like this.
doument.xsd <?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="document" type ="documentType"/>
<xs:complexType name="documentType">
<xs:sequence>
<xs:element name="instance" type="xs:string"/>
<xs:element name="event" type="rmb:EventType"/>
<xs:element name="version" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="EventType" abstract="true">
<xs:sequence>
<xs:element name="eventType" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
transferEvent.xsd <?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:complexType name="transferEventType">
<xs:complexContent>
<xs:extension base="rmb:EventType">
<xs:sequence>
<xs:element name="productType" type="xs:string"/>
<xs:element name="currency" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
<xs:complexType>
<xs:element name="transferEvent" type="transferEventType"/>
</xs:schema>
I am using jaxb 1.0.4 for marshalling the sample code snippet looks like this.
TrasferEvent transferEvent = objectFactory.createTransferEvent();
//set produtType etc on transferEvent
Document document = objectFactory.createDocument();
document.setInstance("Test");
document.setVersion("1.0");
document.setEvent(transferEvent);
//Validate and Marshal document
Here when I do marshalling it throws exception -
com.sun.xml.bind.serializer.AbortSerializationException: tag name "TransferEvent" is not allowed. Possible tag names are: <EventType>
Any idea if I can use
java 'is a' relation with schema objects...
Thanks.