// show how to read from a system identifier and a Reader
Source xmlSource = new StreamSource(xmlSystemId);
Source xsltSource = new StreamSource(
new StringReader(IDENTITY_XSLT));
// send the result to a file
File resultFile = File.createTempFile("Streams", ".xml");
Result result = new StreamResult(resultFile);
System.out.println("Results will go to: "
+ resultFile.getAbsolutePath());
// get the factory
TransformerFactory transFact = TransformerFactory.newInstance();
// get a transformer for this particular stylesheet
Transformer trans = transFact.newTransformer(xsltSource);
// the next line will also perform an identity copy
// Transformer trans = transFact.newTransformer();
// do the transformation
trans.transform(xmlSource, result);