Sunday 15 May 2011

java - How to marshal / unmarshal different xml from the same object model -



java - How to marshal / unmarshal different xml from the same object model -

i'm new jaxb , appreciate little help.

first allow me give bit of back-ground.

i have relatively simple object model, based on 2 main classes: provider , product. provider references list of product can provide, , product references list of provider can provide it. is, have circular references!

product build composite pattern, because: a) not want limited "categories", "types", ..., want create flexible product tree possible. b) want manage product , tree element (the called "categories") through same interface.

as now, same abstract product can have many different "physical implementations" (for example: auto abstract product, whereas toyota yaris physical product). therefore, separate abstract , physical implementations of products, implemented bridge pattern. abstract products producttemplate (the composite mentioned above) , physical product productimplementation.

i managed model using hibernate (and spring).

now produce xml strings allow , front end ends dialogue.

at moment, i'm doing research jaxb see if match needs:

i marshal provider, list of producttemplate i marshal producttemplate, list of provider

however, 1 aspect of need. able produce different versions of xml strings same class. example, provider object, able marshal xml containing

only basic infos (name, address, ...) extended infos (last deivered products, lastly delivered date)

the total monty, is, have him in bd.

at present, able marshal producttemplate, using jaxb anotations, beacause have anotated them xmltransient in provider class. way not enough!

i'm not asking @ point detailed instructions code. i'm asking :

can jaxb meet need ? if yes, please suggest way (i have seen post answers part of questions xsd having 2 root elements (1 @ time)), multiple xml single class thing!

it's been while since posted question, , found reply in blaise doughan's blog , moxy web site.

i don't have much time detail, trick utilize binding files. may have many binding files want related single class. need link jaxbcontext.

i did not find easy use, comes handy when marshalling classes cyclick references.

hope helps , hope i'll have time explain in more details day :)

java hibernate jaxb2

No comments:

Post a Comment