StreamSource xmlSource = new StreamSource( file:" + new File( xmlFilename ).getAbsolutePath() );
StreamSource xslSource = new StreamSource( file:" + new File( xslFilename ).getAbsolutePath() );Writer out = new StringWriter();
StreamResult result = new StreamResult( out );TransformerFactory tFactory = TransformerFactory.newInstance();
Templates translet = tFactory.newTemplates( xslSource );
Transformer transformer = translet.newTransformer();
transformer.transform( xmlSource, result );String html = result.toString();
StreamSource xslSource = new StreamSource( file:" + new File( xslFilename ).getAbsolutePath() );Writer out = new StringWriter();
StreamResult result = new StreamResult( out );TransformerFactory tFactory = TransformerFactory.newInstance();
Templates translet = tFactory.newTemplates( xslSource );
Transformer transformer = translet.newTransformer();
transformer.transform( xmlSource, result );String html = result.toString();
你还需要Jaxp和Xerces
String html = out.toString();