Forum Stats

  • 3,838,499 Users
  • 2,262,376 Discussions
  • 7,900,672 Comments

Discussions

JAXB clone or copy same block

Arsench
Arsench Member Posts: 3
edited Aug 1, 2015 5:32AM in Java Technology & XML

Hello all,

I need your help please. I’m generating an XML file using JAXB. The client request that I need to do is, when retrieving data (from data base) to set into JAXB objects I have to check one of the element values.

For example:

<id>123</id>
<Code>X22</Code>
<location>A1-2-3</location>
 

If the location value is as the above I have to change it to A1, A2 and A3 and set to location attribute cloning the block like example below.
First copy
<id>123</id>
<Code>X22</Code>
<location>A1</location>

Second copy
<id>123</id>
<Code>X22</Code>
<location>A2</location>

Third copy
<id>123</id>
<Code>X22</Code>
<location>A3</location>

All values stored in City object with getters and setters. The location type is String.

And set it into the same XML. My problem is that I can copy the blocks, but when I’m changing the location value it changes in all blocks, as I’m a beginner so please, help me if you can.

Many Thanks in advance.

Tagged:
This discussion has been closed.