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

public class FreeMarkerXmlTask
extends org.apache.tools.ant.taskdefs.MatchingTask

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:

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:
$Id: FreeMarkerXmlTask.java,v 1.8 2003/11/26 05:53:48 run2000 Exp $
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
 
Constructor Summary
FreeMarkerXmlTask()
          Constructor creates the SAXBuilder.
 
Method Summary
 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
addAnd, addContains, addCustom, addDate, addDepend, addDepth, addFilename, addMajority, addNone, addNot, addOr, addPresent, addSelector, addSize, 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, handleErrorFlush, handleErrorOutput, handleFlush, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName
 
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 Detail

FreeMarkerXmlTask

public FreeMarkerXmlTask()
Constructor creates the SAXBuilder.
Method Detail

setBasedir

public void setBasedir(java.io.File dir)
Set the base directory. Defaults to .
Parameters:
dir - the name of the base input directory

setDestdir

public void setDestdir(java.io.File dir)
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(java.lang.String extension)
Set the output file extension. .html by default.
Parameters:
extension - the file extension for the output files

setTemplate

public void setTemplate(java.lang.String template)
Set the path to the template file
Parameters:
template - the template to be used when transforming the XML

setProjectfile

public void setProjectfile(java.lang.String projectAttribute)
Set the path to the project XML file
Parameters:
projectAttribute - the project attribute from the Ant task

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.
Parameters:
encoding - the encoding to be used

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Execute this task as an Ant task.
Overrides:
execute in class org.apache.tools.ant.Task