• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Jaxb marshalling exception

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic