*/
public static void transform(File srcFile, File destFile, File stylesheetFile, String outputFormat) throws IOException, FOPException {
StreamSource src = new StreamSource(srcFile);
StreamSource stylesheet = stylesheetFile == null ? null : new StreamSource(stylesheetFile);
BufferedOutputStream dest = new BufferedOutputStream(new FileOutputStream(destFile));
Fop fop = createFopInstance(dest, outputFormat);
if (fop.getUserAgent().getBaseURL() == null) {
String baseURL = null;
try {
File parentFile = new File(srcFile.getAbsolutePath()).getParentFile();
baseURL = parentFile.toURI().toURL().toExternalForm();
} catch (Exception e) {
baseURL = "";
}
fop.getUserAgent().setBaseURL(baseURL);
}
transform(src, stylesheet, fop);
dest.close();
}