Here you can find the source of xmlToXhtml(T catalog, StreamSource xslt, StreamResult result)
public static <T> void xmlToXhtml(T catalog, StreamSource xslt, StreamResult result)
//package com.java2s; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.util.JAXBSource; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; public class Main { public static <T> void xmlToXhtml(T catalog, StreamSource xslt, StreamResult result) { try {// w w w . j a v a 2s.c o m TransformerFactory.newInstance().newTransformer(xslt) .transform(new JAXBSource(JAXBContext.newInstance(catalog.getClass()), catalog), result); } catch (JAXBException | TransformerException e) { throw new IllegalStateException(e); } } }