|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tools.ant.ProjectComponent org.apache.tools.ant.Task org.apache.tools.ant.taskdefs.MatchingTask freemarker.ext.ant.FreeMarkerXmlTask
public class FreeMarkerXmlTask
This is an Ant
task for transforming XML documents using FM-Classic templates. It uses the
JDOM adapter class, the
NodeListModel
. It will read a set of XML
documents, and pass them to the template for processing, building the
corresponding output files in the destination directory.
It makes the following variables available to the template in the data model:
document
—the JDOM tree of the currently processed XML fileproperties
—a FastHash
containing properties of the project that executes the taskuserProperties
—a FastHash
containing user properties of the project that executes the taskproject
—the JDOM tree of the XML file specified by the
projectfile
. It will not be available if you didn't specify the
projectfile
attribute. Note that this can be any XML file, not
necessarily the XML file of the currently executing project (altough you
would normally use that).methods
—a Methods
object
containing methods from the freemarker.ext.misc
packagetransforms
—a Transforms
object containing transforms from the freemarker.ext.misc
packageIt supports the following attributes:
Attribute | Description | Required |
---|---|---|
basedir | location of the XML files. Defaults to the project's basedir. | No |
destdir | location to store the generated files. | Yes |
includes | comma-separated list of patterns of files that must be included; all files are included when omitted. | No |
includesfile | the name of a file that contains include patterns. | No |
excludes | comma-separated list of patterns of files that must be excluded; no files (except default excludes) are excluded when omitted. | No |
excludesfile | the name of a file that contains exclude patterns. | No |
defaultexcludes | indicates whether default excludes should be used
(yes | no ); default excludes are used when omitted. |
No |
extension | extension of generated files. Defaults to .html. | No |
template | location of the FreeMarker template file that will be applied to XML files | Yes |
projectfile | path to the project file. If omitted, it will not be available to templates | No |
incremental | indicates whether all files should be regenerated (no), or only those that are older than the XML file, the template file, or the project file (yes). Defaults to yes. | No |
encoding | The encoding of the output files. Default to platform default encoding. | No |
Field Summary |
---|
Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTask |
---|
fileset |
Fields inherited from class org.apache.tools.ant.Task |
---|
target, taskName, taskType, wrapper |
Fields inherited from class org.apache.tools.ant.ProjectComponent |
---|
description, location, project |
Constructor Summary | |
---|---|
FreeMarkerXmlTask()
Constructor creates the SAXBuilder. |
Method Summary | |
---|---|
void |
exceptionThrown(TemplateExceptionEvent e)
This method is called whenever a TemplateExceptionEvent
is generated by a FM-Classic template. |
void |
execute()
Execute this task as an Ant task. |
void |
setBasedir(java.io.File dir)
Set the base directory. |
void |
setDestdir(java.io.File dir)
Set the destination directory into which the generated files should be copied to |
void |
setEncoding(java.lang.String encoding)
Set encoding for generated files. |
void |
setExtension(java.lang.String extension)
Set the output file extension. |
void |
setIncremental(java.lang.String incremental)
Turn on/off incremental processing. |
void |
setProjectfile(java.lang.String projectAttribute)
Set the path to the project XML file |
void |
setTemplate(java.lang.String template)
Set the path to the template file |
Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTask |
---|
add, addAnd, addContains, addContainsRegexp, addCustom, addDate, addDepend, addDepth, addDifferent, addFilename, addMajority, addModified, addNone, addNot, addOr, addPresent, addSelector, addSize, addType, appendSelector, createExclude, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDirectoryScanner, getImplicitFileSet, getSelectors, hasSelectors, selectorCount, selectorElements, setCaseSensitive, setDefaultexcludes, setExcludes, setExcludesfile, setFollowSymlinks, setIncludes, setIncludesfile, setProject, XsetIgnore, XsetItems |
Methods inherited from class org.apache.tools.ant.Task |
---|
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType |
Methods inherited from class org.apache.tools.ant.ProjectComponent |
---|
clone, getDescription, getLocation, getProject, setDescription, setLocation |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FreeMarkerXmlTask()
Method Detail |
---|
public void setBasedir(java.io.File dir)
.
dir
- the name of the base input directorypublic void setDestdir(java.io.File dir)
dir
- the name of the destination directorypublic void setExtension(java.lang.String extension)
.html
by default.
extension
- the file extension for the output filespublic void setTemplate(java.lang.String template)
template
- the template to be used when transforming the XMLpublic void setProjectfile(java.lang.String projectAttribute)
projectAttribute
- the project attribute from the Ant taskpublic void setIncremental(java.lang.String incremental)
public void setEncoding(java.lang.String encoding)
encoding
- the encoding to be usedpublic void execute() throws org.apache.tools.ant.BuildException
execute
in class org.apache.tools.ant.Task
org.apache.tools.ant.BuildException
public void exceptionThrown(TemplateExceptionEvent e) throws TemplateException
TemplateExceptionEvent
is generated by a FM-Classic template. Implement this method to
decide how to respond to such events.
exceptionThrown
in interface TemplateExceptionListener
TemplateException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |