TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(
new StreamSource( this.getClass().getResourceAsStream( STYLESHEET_NAME ) ) );
// apply the conversion stylesheet to the incoming process definition
DocumentSource source = new DocumentSource( document );
DocumentResult result = new DocumentResult();
transformer.transform( source, result );
// return the transformed document