MOXy - How to map multiple nodes with the same path? [message #487853] |
Thu, 24 September 2009 11:08  |
Eclipse User |
|
|
|
Hi!
I have a value which I map to two fields:
MyClass { <MyXML>
value; <--> <valuePartA>ABC</valuePartA>
} <valuePartB>123</valuePartB>
</MyXML>
Using a transformation mapping, this is no problem. The trouble comes from the fact that the node <valuePartB> may appear many times in <MyXML>, and I need all "B-values" to create the value in MyClass.
Is this at all possible? Maybe by having an intermediary class with a "valueA" and a list of "valueB"s, but how would the transformer get hold of the intermediary instance?
Thanks!
[Updated on: Thu, 24 September 2009 11:21] by Moderator
|
|
|
|
Re: MOXy - How to map multiple nodes with the same path? [message #488938 is a reply to message #488885] |
Wed, 30 September 2009 14:56   |
Eclipse User |
|
|
|
Thank you so much for your help, Blaise!
And to repay you: a bug report
My case got a little more complicated, so I decided to use an XMLChoiceObjectMapping for the value instead. Going from XML to Java proved to be a cinch but when going the other way the converter never ran.
I did some debugging, and it seems like the mapping is looking for which XMLField is associated with the object, but it doesn't take into account that the object might have to be converted back first, so no XMLField is found and nothing is written.
I understand the object may be converted to any class, so it's impossible to tell which converter to use until it's been converted. Because of this catch 22 the behaviour might not be a bug, in which case I apologize.
I managed to solve my problem with an XMLAnyObjectMapping, so it doesn't bother me.
Anyway, thanks again!
/Matti
|
|
|
|
Powered by
FUDForum. Page generated in 0.11861 seconds