Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] XML attributes on the fly? How?

Hi John,

What kind of object model are you trying to map this to?

You may be able to leverage the XmlAnyAttribute annotation to handle this case. XmlAnyAttribute is for handling attributes which aren't otherwise mapped to static fields/properties on the class. The values are stored in a Map keyed on the QName of the attribute.

Depending on your object model this may work for you. For example:

@XmlRootElement(name="Region")
public class Region

    @XmlAttribute
    public String id;

    @XmlAttribute
    public String name;

    @XmlAnyAttribute
    public Map<QName, String> source;

    @XmlAttribute
    public Integer channels;

    ...
}

Using this class, all of the different source attributes (source-0, source-1 etc) would be captured in the source map, keyed on name on the unmarshal.

Hope that's helpful.

-Matt
On 2013-04-23 10:21 AM, jdiligence wrote:
I need to map an arbitrary number of attributes (based on another attribute)
which have the following form but not sure how to do this with eclipselink.
So far only mapped attributes who's name doesn't change dynamically.

source-n where n is the channel number

<Region id="590" name="r4-1" source-0="586" source-1="588" channels="2"
master-source-0="586" master-source-1="588">

Thanks
John






--
View this message in context: http://eclipse.1072660.n5.nabble.com/XML-attributes-on-the-fly-How-tp159345.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users





Back to the top