[FreeMarker-user] FreeMarkerXMLTask suggestion
Generates text that depends on changing data (like dynamic HTML).
Brought to you by:
revusky
|
From: Russell S. <rus...@ho...> - 2005-12-23 15:41:40
|
You could add to the FreemarkerXmlTask, a nested class:
class Loader {
/**
* A helper method to load an xml file from insed yoru template.
* @param targetFile - the local, valid XML file you want to load up
* @return the parsed document
* @throws org.xml.sax.SAXException
* @throws java.io.IOException
*/
public org.w3c.dom.Document getLocalXMLDocument(String targetFile)
throws org.xml.sax.SAXException, java.io.IOException {
File xmlfile;
xmlfile = new File(targetFile);
org.w3c.dom.Document doc = builder.parse(xmlfile);
return doc;
}
/**
* A helper method to load an xml file at some URL from insed your
template.
* @param targetFile - the valid URL of the XML file you wish to
load
* @return
* @throws org.xml.sax.SAXException
* @throws java.io.IOException
*/
public org.w3c.dom.Document getRemoteXMLDocument(String targetFile)
throws org.xml.sax.SAXException, java.io.IOException {
java.net.URL xmlfile = new java.net.URL(targetFile);
org.w3c.dom.Document doc = builder.parse(xmlfile.openStream());
return doc;
}
}
then just add this one line to private void process(File baseDir, String
xmlFile, File destDir)......
root.put("loader", new Loader());
|