JAXB serialization: Option to have a reference to inner objects

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

JAXB serialization: Option to have a reference to inner objects

Anurag Sharma
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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Dmitry-77
You can use the List<> with @XmlAttribute (the value of list must be XML simple).

Cheers,

D.

On 8/26/2015 12:20 PM, Anurag Sharma wrote:
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


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Mirko Klemm
In reply to this post by Anurag Sharma
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 <[hidden email]>:
>
> 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
>


smime.p7s (5K) Download Attachment
Loading...