How to Use JAXB with XSLT
Java's XSLT framework (TrAX) can use JAXB content trees as input or output of XSLT transformations. You can find the required helper classes JAXBSource and JAXBResult in the javax.xml.bind.util package.
The following example transforms a MovieLibrary document to another MovieLibrary using a XSLT file:
MovieLibrary library = ...;
JAXBContext ctx = JAXBContext.newInstance(MovieLibrary.class);
JAXBSource src = new JAXBSource(ctx, library);
JAXBResult result = new JAXBResult(ctx);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new StreamSource(new File("myTemplate.xslt")));
transformer.transform(src, result);
MovieLibrary modifiedLibrary = (MovieLibrary) result.getResult();
Using JAXBSource it is also possible to provide the stylesheet itself as JAXB content tree.

