// Use the factory to create a template containing the xsl file Templatestemplate= factory.newTemplates(newStreamSource( newFileInputStream(xslFilename)));
// Use the template to create a transformer Transformerxformer= template.newTransformer();
// Prepare the input and output files Sourcesource=newStreamSource(newFileInputStream(inFilename)); Resultresult=newStreamResult(newFileOutputStream(outFilename));
// Apply the xsl file to the source file and write the result to the // output file xformer.transform(source, result); } catch (FileNotFoundException e) ...{ // File not found } catch (TransformerConfigurationException e) ...{ // An error occurred in the XSL file } catch (TransformerException e) ...{ // An error occurred while applying the XSL file // Get location of error in input file } } }