| Re: [eclipselink-users] Moxy mapping |
|
Hi Magnus, There are a couple of options: 1. Create an XMLDirectMapping from an attribute on your object to the XPath "gml:Surface/@gml:id" If the data corresponds to a property on your object then you can just create a mapping for it. With the XPath above it will put the attribute on the same "gml:Surface" element created by your other mapping. 2. Create an XMLTransformationMapping If the data does not exist in your object and you want to create it with code you could use a transformation mapping. XMLTransformationMapping idMapping = new XMLTransformationMapping(); idMapping.setAttributeName("someAttribute"); // AttributeTransformers are used to build to build the property value for the domain object. idMapping.setAttributeTransformer(new IdAttributeTransformer()); // FieldTransformers are used to build the XML document. idMapping.addFieldTransformer("gml:Surface/@gml:id", new IdFieldTransformer()); IdAttributeTransformer is required to implement org.eclipse.persistence.mappings.transformers.AttributeTransformer and IdFieldTransformer is required to implement org.eclipse.persistence.mappings.transformers.FieldTransformer. -Blaise Magnus Heino wrote:
|