freemarker.ext.ant
Class FreemarkerXmlTask
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
- extends org.apache.tools.ant.taskdefs.MatchingTask
This is an Ant task for transforming
XML documents using Freemarker templates. It uses the Expose-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 file
- properties: a
SimpleHash
containing
properties of the project that executes the task
- userProperties: a
SimpleHash
containing
user properties of the project that executes the task
- project: 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).
It 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 |
- Version:
- 1.0
- Author:
- Attila Szegedi, szegedia@freemail.hu, Jonathan Revusky, jon@revusky.com
Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTask |
fileset, useDefaultExcludes |
Fields inherited from class org.apache.tools.ant.Task |
description, location, target, taskName, taskType, wrapper |
Fields inherited from class org.apache.tools.ant.ProjectComponent |
project |
Method Summary |
void |
execute()
|
protected void |
insertDefaults(TemplateModelRoot root)
|
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 |
createExclude, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDirectoryScanner, setDefaultexcludes, setExcludes, setExcludesfile, setIncludes, setIncludesfile, XsetIgnore, XsetItems |
Methods inherited from class org.apache.tools.ant.Task |
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, handleErrorOutput, handleOutput, init, log, log, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName |
Methods inherited from class org.apache.tools.ant.ProjectComponent |
getProject, setProject |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FreemarkerXmlTask
public FreemarkerXmlTask()
- Constructor creates the SAXBuilder.
setBasedir
public void setBasedir(java.io.File dir)
- Set the base directory. Defaults to .
setDestdir
public void setDestdir(java.io.File dir)
- Set the destination directory into which the generated
files should be copied to
- Parameters:
dirName
- the name of the destination directory
setExtension
public void setExtension(java.lang.String extension)
- Set the output file extension. .html by default.
setTemplate
public void setTemplate(java.lang.String template)
- Set the path to the template file
setProjectfile
public void setProjectfile(java.lang.String projectAttribute)
- Set the path to the project XML file
setIncremental
public void setIncremental(java.lang.String incremental)
- Turn on/off incremental processing. On by default
setEncoding
public void setEncoding(java.lang.String encoding)
- Set encoding for generated files. Defaults to platform default encoding.
execute
public void execute()
throws org.apache.tools.ant.BuildException
- Overrides:
execute
in class org.apache.tools.ant.Task
insertDefaults
protected void insertDefaults(TemplateModelRoot root)