users@jaxb.java.net

Re: Custom mapping for Maps in JAXB

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Thu, 17 Jun 2010 22:28:43 +0200

My understanding of XML Schema is that <xs:element>s are static components
of their parent <xs:element>. This maps to Java classes, where elements are
represented as fields.

Using tags to represent what is actually data (as opposed to field selector)
would also cause problems with other XML processors such as XSLT.

Feel free to disagree ;-)
-W


On 16 June 2010 20:14, Leo Romanoff <romixlev_at_yahoo.com> wrote:
>
> Hi,
>
> Has anyone more concrete and constructive comments on this issue?
>
> Is it possible to produce custom serialization using standard JAXB tricks?
> If not, is there any way to extend JAXB by means of a custom "plugin" to
> support custom serialization and deserialization of specific parts of the
> overall object graph? For example, every map field marked by a special
> annotation could produce a top-level tag <map> and inside it for each
> key/value pair (K,V) it would produce <K>V</K> thus resulting in something
> like:
>  <map>
>     <K1>V1</K1>
>     <K2>V2</K2>
>     ...
>     <Kn>Vn</Kn>
>  </map>
>
> As custom section is clearly marked by <map> tags, it should be actually
> pretty straight forward for JAXB to detect it and to call a user-defined
> custom handler for unmarshalling the enclosed XML fragment.  Of course, it
> would only work if JAXB would support this type of custom handlers.
>
> Do you think this idea makes sense? Is it possible to implement something
> like this?
>
> Thanks,
>  Leo
> --
> View this message in context: http://old.nabble.com/Custom-mapping-for-Maps-in-JAXB-tp28779221p28905884.html
> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>