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.


Thanks, works just fine here too now :)

/Magnus

On Thu, May 6, 2010 at 2:51 PM, Matt MacIvor <matt.macivor@xxxxxxxxxx> wrote:
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

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




--

 /Magnus Heino

Back to the top