Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Moxy map attribute that doesn't exist in the object model.

Hi Magnus,

Just don't set the attribute name or AttributeTransformer on the transformation mapping. You can also make use of the existing "ConstantTransformer" if the value you're marshalling is a constant.

For example:
        XMLTransformationMapping mapping = new XMLTransformationMapping();
        mapping.addFieldTransformer("env:Code/env:Value/@xml:lang", new ConstantTransformer("sv_SE"));
        desc.addMapping(mapping);

I tried this out in trunk and it marshals and unmarshals without any trouble.

-Matt

On 06/05/2010 1:33 AM, Magnus Heino wrote:
I want this:

<env:Code>
    <env:Value xml:lang="sv_SE"></env:Value>
<env:Code>

I need to be able to both marshal and unmarshal.

I have no interest in xml:lang in my objects, but I need to get it into the xml.

Right now I have this:

XMLTransformationMapping faultCodeLang = new XMLTransformationMapping();
faultCodeLang.setAttributeName("lang");
faultCodeLang.addFieldTransformer("env:Code/env:Value/@xml:lang", new DefaultLocaleTransformer());
faultCodeLang.setAttributeTransformer(new AttributeTransformerAdapter() {
    //
});
fault.addMapping(faultCodeLang);

It does work, but now I need to have a lang attribute on my object. 

Is there a better way to do this?

--

 /Magnus Heino

_______________________________________________ eclipselink-users mailing list eclipselink-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Back to the top