FreemarkerXmlTask (FreeMarker 2.3.35 API)
Description: declaration: package: freemarker.ext.ant, class: FreemarkerXmlTask

Package 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

All Implemented Interfaces:
  `org.apache.tools.ant.types.selectors.SelectorContainer`

@Deprecated public class FreemarkerXmlTask extends org.apache.tools.ant.taskdefs.MatchingTask
Deprecated.
FMPP is a more complete solution.

This is an Ant task for transforming XML documents using FreeMarker templates. It uses the adapter class `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`: Deprecated! The DOM tree of the currently processed XML file wrapped with the legacy `NodeListModel`. For new projects you should use the `.node` instead, which initially contains the DOM Document wrapped with `NodeModel`.
- `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 DOM tree of the XML file specified by the `projectfile`. It will not be available if you didn't specify the `projectfile` attribute.
- further custom models can be instantiated and made available to the templates using the `models` attribute.

It supports the following attributes:

FreeMarker XML ant task 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 | name of the FreeMarker template file that will be applied by default to XML files | No
templateDir | location of the FreeMarker template(s) to be used, defaults to the project's baseDir | No
projectfile | path to the project file. The poject file must be an XML 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. Defaults to platform default encoding. | No
templateEncoding | The encoding of the template files. Defaults to platform default encoding. | No
validation | Whether to validate the XML input. Defaults to off. | No
models | A list of [name=]className pairs separated by spaces, commas, or semicolons that specifies further models that should be available to templates. If name is omitted, the unqualified class name is used as the name. Every class that is specified must implement the TemplateModel interface and have a no-args constructor. | No

It supports the following nesed elements:

FreeMarker XML ant task nested elements
Element | Description | Required
--- | --- | ---
prepareModel | This element executes Jython script before the processing of each XML files, that you can use to modify the data model. You either enter the Jython script directly nested into this element, or specify a Jython script file with the `file` attribute. The following variables are added to the Jython runtime's local namespace before the script is invoked: `model`: The data model as `java.util.HashMap`. You can read and modify the data model with this variable. `doc`: The XML document as `org.w3c.dom.Document`. `project`: The project document (if used) as `org.w3c.dom.Document`. If this element is used, Jython classes (tried with Jython 2.1) must be available. | No
prepareEnvironment | This element executes Jython script before the processing of each XML files, that you can use to modify the freemarker environment (`Environment`). The script is executed after the `prepareModel` element. The accessible Jython variables are the same as with the `prepareModel` element, except that there is no `model` variable, but there is `env` variable, which is the FreeMarker environment (`Environment`). If this element is used, Jython classes (tried with Jython 2.1) must be available. | No

- ## Field Summary

  ### Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTask

  `fileset`

  ### 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`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FreemarkerXmlTask()`
  Deprecated.
  Constructor creates the SAXBuilder.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addConfiguredJython​(JythonAntTask jythonAntTask)`
  Deprecated.
  `void`
  `addConfiguredPrepareEnvironment​(JythonAntTask prepareEnvironment)`
  Deprecated.
  `void`
  `addConfiguredPrepareModel​(JythonAntTask prepareModel)`
  Deprecated.
  `void`
  `execute()`
  Deprecated.
  `protected void`
  `insertDefaults​(Map root)`
  Deprecated.
  `void`
  `setBasedir​(File dir)`
  Deprecated.
  Set the base directory.
  `void`
  `setDestdir​(File dir)`
  Deprecated.
  Set the destination directory into which the generated files should be copied to
  `void`
  `setEncoding​(String encoding)`
  Deprecated.
  Set encoding for generated files.
  `void`
  `setExtension​(String extension)`
  Deprecated.
  Set the output file extension.
  `void`
  `setIncremental​(String incremental)`
  Deprecated.
  Turn on/off incremental processing.
  `void`
  `setModels​(String models)`
  Deprecated.
  `void`
  `setProjectfile​(String projectAttribute)`
  Deprecated.
  Set the path to the project XML file
  `void`
  `setTemplate​(String templateName)`
  Deprecated.
  `void`
  `setTemplateDir​(File templateDir)`
  Deprecated.
  `void`
  `setTemplateEncoding​(String inputEncoding)`
  Deprecated.
  `void`
  `setValidation​(boolean validation)`
  Deprecated.
  Sets whether to validate the XML input.

  ### 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

  `getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType`

  ### Methods inherited from class org.apache.tools.ant.ProjectComponent

  `getProject`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### FreemarkerXmlTask

    public FreemarkerXmlTask()
    Deprecated.
    Constructor creates the SAXBuilder.

- ## Method Details

  - ### setBasedir

    public void setBasedir​(File dir)
    Deprecated.
    Set the base directory. Defaults to `.`

  - ### setDestdir

    public void setDestdir​(File dir)
    Deprecated.
    Set the destination directory into which the generated files should be copied to
    Parameters:
      `dir` - the name of the destination directory

  - ### setExtension

    public void setExtension​(String extension)
    Deprecated.
    Set the output file extension. `.html` by default.

  - ### setTemplate

    public void setTemplate​(String templateName)
    Deprecated.

  - ### setTemplateDir

    public void setTemplateDir​(File templateDir) throws org.apache.tools.ant.BuildException
    Deprecated.
    Throws:
      `org.apache.tools.ant.BuildException`

  - ### setProjectfile

    public void setProjectfile​(String projectAttribute)
    Deprecated.
    Set the path to the project XML file

  - ### setIncremental

    public void setIncremental​(String incremental)
    Deprecated.
    Turn on/off incremental processing. On by default

  - ### setEncoding

    public void setEncoding​(String encoding)
    Deprecated.
    Set encoding for generated files. Defaults to platform default encoding.

  - ### setTemplateEncoding

    public void setTemplateEncoding​(String inputEncoding)
    Deprecated.

  - ### setValidation

    public void setValidation​(boolean validation)
    Deprecated.
    Sets whether to validate the XML input.

  - ### setModels

    public void setModels​(String models)
    Deprecated.

  - ### execute

    public void execute() throws org.apache.tools.ant.BuildException
    Deprecated.
    Overrides:
      `execute` in class `org.apache.tools.ant.Task`
    Throws:
      `org.apache.tools.ant.BuildException`

  - ### addConfiguredJython

    public void addConfiguredJython​(JythonAntTask jythonAntTask)
    Deprecated.

  - ### addConfiguredPrepareModel

    public void addConfiguredPrepareModel​(JythonAntTask prepareModel)
    Deprecated.

  - ### addConfiguredPrepareEnvironment

    public void addConfiguredPrepareEnvironment​(JythonAntTask prepareEnvironment)
    Deprecated.

  - ### insertDefaults

    protected void insertDefaults​(Map root)
    Deprecated.