Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
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();
        // 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.


Magnus Heino wrote:


I have this mapping:

        XMLDirectMapping interior = new XMLDirectMapping();
        interior.setField(new XMLField("gml:Surface/gml:patches/gml:PolygonPatch/gml:interior/gml:LinearRing/gml:posList/text()"));

Reading xml documents works just fine.

When I write the xml however, gml:Surface is required to have a gml:id attribute. Is there any way to control this?


/Magnus Heino

_______________________________________________ eclipselink-users mailing list eclipselink-users@xxxxxxxxxxx

Back to the top