(resending after sf.net email problems) Hi Alex,
There's a trick which is not officially fully supported (mainly because of some code generation quirks in dealing with nested abstract mapping references which won't be cleaned up until the 2.0 rewrite), but which I use successfully in many situations. That's to use a pre-get method on the object corresponding to the element. The pre-get method can take the IMarshallingContext instance as a parameter, and should always be called after the start tag for the element has been opened. You can get the IXMLWriter instance from the IMarshallingContext, then call addAttribute() for each attribute you want to add to the start tag. This also works for unmarshalling, using a pre-set method. See http://jibx.sourceforge.net/tutorial/binding-extend.html#extmeths for some details of using these extension methods. That's not exactly what you asked for, but hopefully close enough to take care of your needs. - Dennis Dennis M. Sosnoski SOA and Web Services in Java Training and Consulting http://www.sosnoski.com - http://www.sosnoski.co.nz Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117 Alex Dickinson wrote: > Hello all, > > I am trying to figure out if I can have a reusable way of mapping > attributes into a Map. > > For instance, given the following class definitions: > > class Foo > { > public String fooText; > public Map attrs; > } > > class Bar > { > public String aText; > public String bText; > public Map attrs; > } > > I would like to have the following instance documents bound them: > > <foo attr1='val1' attr2='val2' attr3='val3'>foo value</foo> > > <bar attr1='val1' attr2='val2' attr3='val3'> > <a>a value</a> > <b>b value</b> > </bar> > > I know a custom marshaller/unmarshaller is in order, but is there any > way of marshalling just the attribute portion? > > Something like: > > <mapping name='foo' class='Foo'> > <some-thing-that-I-dont-know-using-attribute-to-map-marshaller> > <value style='text' field='fooText'/> > </mapping> > > > <mapping name='bar' class='Bar'> > <some-thing-that-I-dont-know-using-attribute-to-map-marshaller> > <value name='a' field='aText'/> > <value name='a' field='aText'/> > </mapping> > > > Much appreciated, > Alex > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > jibx-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/jibx-users > > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ jibx-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jibx-users
