Reputation: 23
Here's the XML I'm trying to unmarshall:
<eveapi version="2" zkbapi="1">
<result>
<rowset name="events">
<row eventID="41551776" solarSystemID="30003069">
<pilot characterID="1803362092"/>
<rowset name="copilots">
<row characterID="914916227"/>
<row characterID="877714973"/>
</rowset>
<rowset name="items">
<row typeID="31055"/>
<row typeID="2048"/>
</rowset>
</row>
</rowset>
</result>
</eveapi>
I'm having issues unmarshalling the two rowset tags copilots and items (the objects are null after the unmarshall). Also, I have no control over the schema. Below is the class that represents the tag at the eveapi/result/rowset/row level. Event is instantiated by jaxb. Pilot is unmarshalled fine. But I can't get copilots and items to work, they are both null.
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "row")
public class Event {
@XmlElement(name = "pilot")
Pilot pilot;
@XmlPath("rowset[@name='copilots']")
Copilots copilots;
@XmlPath("rowset[@name='items']")
Items items;
Is what I am doing possible? Thanks!
Upvotes: 2
Views: 272
Reputation: 149047
To use the @XmlPath
annotation you need to be sure you are using EclipseLink JAXB (MOXy) as your JAXB provider. To do this you need to have EclipseLink on your classpath and a jaxb.properties
file in the same package as your domain model with the following entry:
javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory
For more information see the following posts on my blog:
Upvotes: 1