Re: [Simple-support] Availabily of object inlining
Brought to you by:
niallg
|
From: Maxim S. <sol...@gm...> - 2012-07-30 18:21:01
|
Hello Niall
sorry for double post
I was able to parse "inline" object by using following "ugly" code:
InputNode root = NodeBuilder.read(new FileInputStream(xml));
InputNode root1 = NodeBuilder.read(new FileInputStream(xml)); //HACK to
handle Adresses inside user
InputNode listNode = root.getNext();
InputNode listNode1 = root1.getNext(); //HACK to handle inline object
A a = serializer.read(A.class, listNode , false);
B b = serializer.read(B.class, listNode1 , false);
can you advise how can I handle duplicated element in source XML (one
element was printed twice by mistake)
Thanks in advance
On Tue, Jul 31, 2012 at 12:15 AM, Maxim Solodovnik <sol...@gm...>wrote:
> Hello Niall,
>
> Thanks for the quick reply.
>
> Here is the full story:
> Our application performs backup of the DB into XML files.
> I try to update this system to use Simple XML framework.
>
> The new version should work with old backup files :(
> So I need possibility to import old XML files.
>
> currently I have 2 problems:
> 1) contents of B is inside A
> 2) A contains 1 node 2 times
>
> I tried to parse object in "semi-automatic" mode by trying to process
> InputNode twice:
> first time for object A and second time for object B
>
> But this seems to be impossible since InputNode is iterable only once :(((
>
> can you suggest any clue for this?
>
> I personally think of XSLT transform of the document prior to import (but
> it not seems to be very good solution)
>
> Thanks in advance for your answers
>
> BTW I'm currently using 2.6.6 version
>
>
> On Mon, Jul 30, 2012 at 4:48 PM, Niall Gallagher <
> gal...@ya...> wrote:
>
>> You could use a Converter, or you could just serialize one object i.e
>> drop B.
>>
>> --- On *Fri, 27/7/12, Maxim Solodovnik <sol...@gm...>* wrote:
>>
>>
>> From: Maxim Solodovnik <sol...@gm...>
>> Subject: [Simple-support] Availabily of object inlining
>> To: sim...@li...
>> Received: Friday, 27 July, 2012, 2:04 AM
>>
>>
>> Hello,
>>
>> I have very specific question regarding object serialization:
>> Our current code uses "hand writed" serialization/deserialization to/from
>> XML.
>> I would like to port it to use "Simple framework".
>>
>> 2 features I was unable to find in documentation/examples
>> 1) serializing of List<MyObject> (can be workarounded by creating
>> additional class holding list as the only parameter)
>> 2) inlining of property object:
>> imaging we have
>> @Root
>> class A {
>> @Element
>> String prop;
>> @Element
>> B b;
>> }
>>
>> @Root
>> class B {
>> @Element
>> String propB1;
>> @Element
>> String propB2;
>> }
>>
>> Serializing of A will produce:
>> <a>
>> <prop></prop>
>> <b>
>> <propB1></propB1>
>> <propB2></propB2>
>> </b>
>> </a>
>>
>> what I need is to get (to be compatible with previous versions)
>> <a>
>> <prop></prop>
>> <propB1></propB1>
>> <propB2></propB2>
>> </a>
>>
>> Is this possible somehow?
>>
>> Maybe 1) above can be implemented without creating additional class?
>>
>> Sorry for the long post
>> Thanks in advance
>>
>> --
>> WBR
>> Maxim aka solomax
>>
>> -----Inline Attachment Follows-----
>>
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>>
>> -----Inline Attachment Follows-----
>>
>> _______________________________________________
>> Simple-support mailing list
>> Sim...@li...<http://mc/compose?to=...@li...>
>> https://lists.sourceforge.net/lists/listinfo/simple-support
>>
>>
>
>
> --
> WBR
> Maxim aka solomax
>
--
WBR
Maxim aka solomax
|