[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[eclipselink-users] XML Composite Object Mapping Problem
|
Hi,
I'm new to Eclipselink and I'm having trouble getting an XML mapping
working.
I have the following Java classes:
public class Response {
List<ResourceStatus> rs;
List<ResourceLocation> rl;
...
}
public class ResourceStatus {
private String id;
private String status;
...
}
public class ResourceLocation {
private String id;
private Point posn;
...
}
My XML doc is:
<remc:Response>
<remc:ResourceStatusLocations>
<remc:ID>AAA</remc:ID>
<remc:Status>0</remc:Status>
<remc:Location>
<common:Coordinate>
<common:X>5.0</common:X>
<common:y>5.0</common:y>
</common:Coordinate>
</remc:Location>
</remc:ResourceStatusLocations>
<remc:ResourceStatusLocations>
<remc:ID>BBB</remc:ID>
<remc:Status>2</remc:Status>
<remc:Location>
<common:Coordinate>
<common:X>7.0</common:X>
<common:y>7.0</common:y>
</remc:Coordinate>
</remc:Location>
</remc:ResourceStatusLocations>
</remc:Response>
and the equivalent objects should be
Response
rl ["AAA", (5.0, 5.0)], ["BBB", (7.0, 7.0)]
rs ["AAA", "0"], ["BBB", "2"]
In workbench (EclipseLink Workbench v2.0.2), I have:
Descriptor Response --> context =
schema::nnn//element::remc:Response
- Attribute ResourceLocation mapped as a composite collection:
- xpath = remc:ResourceStatusLocation
- Reference descriptor = ResourceLocation
Desciptor ResourceLocation --> context =
schema::nnn//complexType:remc:ResourceStatusLocation
- Attribute coordinate mapped as composite object using
customiser code
final XMLCompositeObjectMapping mapping = new
XMLCompositeObjectMapping();
mapping.setAttributeName("coordinate");
mapping.setXPath("remc:Location/common:Coordinate");
mapping.setReferenceClass(Point.class);
descriptor.addMapping(mapping);
However, when marshalling the object to XML, I've got the id and statuses
mapped ok but the locations are missing:.
<remc:Response>
<remc:ResourceStatusLocations>
<remc:Status>0</remc:Status>
<remc:ID>AAA</remc:ID>
</remc:ResourceStatusLocations>
<remc:ResourceStatusLocations>
<remc:Status>2</remc:Status>
<remc:ID>BBB</remc:ID>
</remc:ResourceStatusLocations>
</remc:Response>
I have verified that the customiser code is being called and that the
Point.class matches the Coordinate element.
Is this the right approach to take or am I missing something obvious here?
Thanks
Den
--
View this message in context: http://old.nabble.com/XML-Composite-Object-Mapping-Problem-tp28759777p28759777.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.