On 18 June 2010 12:51, Leo Romanoff <romixlev_at_yahoo.com> wrote:
> Is there any way to integrate it a bit more tightly with the rest of JAXB
> parsing? I mean, can I say:
> "Do now directly return any raw DOM elements, but use first my custom
> function to pre-process it". Then I could provide a function that would
> convert an XML fragment into e.g. a Map and this map would be then stored in
> my model, instead of raw DOM elements that need post-processing.
> I guess something like this is probably possible, or?
>
Say, you have a class Cabinet, where your Map should ultimately be a field.
For unmarshalling arbitrary content, you'll need another field
Object any
as the root of your arbitrary <k>v</k> stuff. (I'm not seriously considering
of using the Object any to store the Map, too.) You can do the conversions
after the document has been unmarshalled. If you are worried about the effort
for walking the final tree, you might look into
javax.xml.bind.Unmarshaller.Listener, method afterUnmarshal, and do it in
the callback.
-W