tags:

views:

200

answers:

1

I'm trying to figure out what bits I need to plug together to marshal a JAXB POJO to a XOM document, and vice versa.

The JAXB Marshaller interface's marshal methods take various targets, such as Result, but none of them have a XOM adapter. Irritatingly, the XOM API does have a XOMResult implementation, but it's package protected, and only used internally.

Is there some other way I can marshal to/from XOM without resorting to String or byte buffers?

A: 

I'm not sure if you are adverse to using DOM to accomplish this, as you're probably using XOM to avoid DOM! Anyway, using a JAXB Binder as described here along with XOM's DOMConverter, you can go from JAXB to DOM to XOM without using a String or a byte buffer.

It is too bad that XOM doesn't have a utility to create a XOM Document from a SAX ContentHandler, since JAXB also supports marshalling to an instance of that object. XOM has a SAXConverter that can create a ContentHandler from a Document, but not the other way around.

Here's a thread that relates to this on the XOM-interest mailing list.

laz
Yeah, going from JAXB->DOM->XOM is what I'm currently stuck with, but it leaves a bad taste in my mouth.
skaffman
I understand completely. Perhaps this is an opportunity to create a contribution to XOM by creating the missing converter? ;)
laz