users@jaxb.java.net

Re: JAXB serialization: Option to have a reference to inner objects

From: Mirko Klemm <mirko_at_cm-klemm.de>
Date: Wed, 26 Aug 2015 12:30:51 +0200

XML preserves the ID and IDREF types for such a use case. (The reference implementation of) JAXB can make use of that.
Your options are, if you define your model in XML Schema to add an appropriate XML Schema annotation to your element or attribute declaration in the XSD, in order to convey information on about what type of object is actually referenced by an IDREF.
This might also help:

https://jaxb.java.net/tutorial/section_4_3_1-Assembling-Data-with-Links-ID-IDREF.html


If you are working with hand-written JAXB classes, use the XmlID and XmlIDREF annotations (see JAXB API documentation: https://jaxb.java.net/nonav/2.2.4/docs/api/javax/xml/bind/annotation/XmlIDREF.html).


> Am 2015-08-26 um 12:20 schrieb Anurag Sharma <anuraag.sharma001_at_gmail.com>:
>
> Hi,
>
> We are serializing a large number of objects. Some objects have attributes as list of objects.
>
> I found an option in Texo serializer where such list of objects are saved as references and a lot of space is saved rather than showing same object multiple times. eg shown below:
>
> <target:LogicalFact id="6022" version="28"
> created="2014-12-01T15:53:59.000+0000"
> logicalColumns="#/16651 #/10549 #/17142 #/16898 #/16542 #/16551 #/16832 #/16623 #/17230 #/16645 #/16393 #/16968 #/16575 #/17179 #/17195 #/16717 #/16636 #/16560 #/16410 #/16814 #/16610 #/16691 #/17173 #/16705 #/16838"/>
>
> In above example, all logical columns are references. This saves space by avoiding duplicate information. Is there any such option available with JAXB serializer.
>
> Regards
> Anurag
>