tags:

views:

124

answers:

1

Is anyone aware of implementations of the standard javax.xml.transform.Source and javax.xml.transform.Result which operate on underlying POJOs?

In other words, I want to use XSLT to transform one java object graph into another.

I am currently using xstream to render the POJOs to a W3C DOM, and then using DomSource and DomResult to pass to a javax.xml.transform.Transformer, but I'd like to skip that step and operate directly on POJOs, using the same XSLT and Transformer/Source/Result interfaces.

I'm already aware of Apache JXPath, which provides an XPath implementation which operates on POJOs, which is sort of halfway there, but not quite far enough.

Also, JAXB provides javax.xml.bind.util.JAXBSource and JAXBResult, but these only work on objects which are instances of JAXB-annotated classes.

+1  A: 

Have you tried looking at smooks? It is able to mix XSLT and POJO transformations under one configuation file.

Superfilin
Nice link, thanks, I'll check it out.
skaffman
I just write a test case which uses a smooks `JavaSource` and `JavaResult` and passing them to a Transformer, but the `Transformer` rejects the `JavaResult` because it's not a `DomResult`, a `StreamResult` or a `SAXResult` (which the Transformer API requires). It seems tantalisingly close, but I don't want to use the Smooks infrastructure, just its API.
skaffman
But which Transformar API implementation are you using? I guess it is really dependent on the implementation which types of sources/results are supported. I guess you can make a wrapper around the library you are using and make it use JavaSource/JavaResult through smooks. But I'm only guessing here. Never done it myself :).
Superfilin