One thing to add: so, Woodstox:

https://github.com/FasterXML/woodstox

has some unit tests that may be useful in showing usage; especially:

src/test/java/stax2/dom/TestDomCompat.java  (reading)
src/test/java/stax2/dom/TestDomWrite.java (writing)

which test functionality wrt DOMSource / DOMResult.

I hope this helps,

-+ Tatu +-


On Sat, May 9, 2020 at 11:49 AM Tatu Saloranta <[email protected]> wrote:
>
> On Fri, May 8, 2020 at 8:10 AM 'Thomas Vogler' via jackson-user
> <[email protected]> wrote:
> >
> > Hi all,
> >
> > I have to (de-)serialize a complex POJO (in-)to a DOM tree.
> >
> > Persisting this DOM tree is not my business and i cannot control it.
> >
> > The structure of the generated DOM tree is my (Jackson's) decision, I get 
> > an Element and have to get/put my stuff from there
> > .
> > I found a way to serialize my POJO by implementing the required methods in 
> > a XMLStreamWriter2 and using this in an ToXmlGenerator.
> >
> > What I don't know is how to deserialize an Element to my POJO.
> >
> > All help welcome...
>
> Jackson-dataformat-xml uses Stax API for input/output, and does not
> have similar input/output integration with DOM.
> However, there are probably Stax-based tools for making
> XMLStreamReader read from DOM Document or Element, and XMLStreamWriter
> "write" a DOM document. In fact I think Woodstox might have something
> like that; and perhaps StaxMate.
>
> Alternative simple brute force solution is to write DOM as
> byte[]/String, then feed that to Jackson via readValue().
> Similarly for Jackson writing XML, parse that as DOM document.
>
> On first approach... I think `javax.xml.transform.dom.DOMSource`
> (https://docs.oracle.com/javase/8/docs/api/javax/xml/transform/dom/DOMSource.html)
> can be given to `XMLInputFactory` as `StaxSource`, and this is how you
> can do cleanly. Woodstox does support it.
> There is similar `DOMResult` which may work as well.
>
> -+ Tatu +-

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jackson-user/CAL4a10izS_x9CtT1MvKNHvhFwtkAWts%3DEiuzZqEd%2BtgNj4ovHg%40mail.gmail.com.

Reply via email to