Skip to content

Instantly share code, notes, and snippets.

@theresajayne
Created July 7, 2011 11:40
Show Gist options
  • Save theresajayne/1069338 to your computer and use it in GitHub Desktop.
Save theresajayne/1069338 to your computer and use it in GitHub Desktop.
public File generateFOFromXml(File xslFile,File xmlFile){
File tempout = null;
try {
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new StreamSource(xslFile));
tempout = File.createTempFile("tmp", ".fo");
transformer.transform(new StreamSource(xmlFile), new StreamResult(new FileOutputStream(tempout)));
} catch (TransformerConfigurationException tce) {
LOGGER.error("Transformer Configuration Error",tce);
} catch (IOException ioe) {
LOGGER.error(ioe);
} catch (TransformerException te) {
LOGGER.error(te);
}
return tempout;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment