org.apache.tools.ant.taskdefs

Class XSLTProcess

Implemented Interfaces:
Cloneable, SelectorContainer, XSLTLogger

public class XSLTProcess
extends MatchingTask
implements XSLTLogger

Processes a set of XML documents via XSLT. This is useful for building views of XML based documentation.
Since:
Ant 1.1

Nested Class Summary

static class
XSLTProcess.Factory
The factory element to configure a transformer factory
static class
XSLTProcess.OutputProperty
Specify how the result tree should be output as specified in the specification.
static class
XSLTProcess.Param
The Param inner class used to store XSL parameters

Field Summary

static String
PROCESSOR_TRAX
The default processor is trax

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

XSLTProcess()
Creates a new XSLTProcess Task.

Method Summary

void
add(ResourceCollection rc)
Adds a collection of resources to style in addition to the given file or the implicit fileset.
void
add(FileNameMapper fileNameMapper)
Adds a nested filenamemapper.
void
addConfiguredStyle(Resources rc)
Add a nested <style> element.
void
addConfiguredXMLCatalog(XMLCatalog xmlCatalog)
Add the catalog to our internal catalog
void
addMapper(Mapper mapper)
Defines the mapper to map source to destination files.
protected void
configureLiaison(File stylesheet)
Deprecated. since Ant 1.7
protected void
configureLiaison(Resource stylesheet)
Loads the stylesheet and set xsl:param parameters.
Path
createClasspath()
Set the optional classpath to the XSL processor
XSLTProcess.Factory
createFactory()
Create the factory element to configure a trax liaison.
XSLTProcess.OutputProperty
createOutputProperty()
Create an instance of an output property to be configured.
XSLTProcess.Param
createParam()
Create an instance of an XSL parameter for configuration by Ant.
void
execute()
Executes the task.
XSLTProcess.Factory
getFactory()
Get the factory instance configured for this processor
protected XSLTLiaison
getLiaison()
Get the Liason implementation to use in processing.
Enumeration
getOutputProperties()
Get an enumeration on the outputproperties.
XMLCatalog
getXMLCatalog()
Get the XML catalog containing entity definitions
void
init()
Initialize internal instance of XMLCatalog
void
setBasedir(File dir)
Set the base directory; optional, default is the project's basedir.
void
setClasspath(Path classpath)
Set the optional classpath to the XSL processor
void
setClasspathRef(Reference r)
Set the reference to an optional classpath to the XSL processor
void
setDestdir(File dir)
Set the destination directory into which the XSL result files should be copied to; required, unless in and out are specified.
void
setExtension(String name)
Set the desired file extension to be used for the target; optional, default is html.
void
setFileDirParameter(String fileDirParameter)
Pass the directory name of the current processed file as a xsl parameter to the transformation.
void
setFileNameParameter(String fileNameParameter)
Pass the filename of the current processed file as a xsl parameter to the transformation.
void
setForce(boolean force)
Set whether to check dependencies, or always generate; optional, default is false.
void
setIn(File inFile)
specifies a single XML document to be styled.
void
setOut(File outFile)
Specifies the output name for the styled result from the in attribute; required if in is set
void
setProcessor(String processor)
Set the name of the XSL processor to use; optional, default trax.
void
setReloadStylesheet(boolean b)
Controls whether the stylesheet is reloaded for every transform.
void
setScanIncludedDirectories(boolean b)
Whether to style all files in the included directories as well; optional, default is true.
void
setStyle(String xslFile)
Name of the stylesheet to use - given either relative to the project's basedir or as an absolute path; required.
void
setUseImplicitFileset(boolean useimplicitfileset)
Whether to use the implicit fileset.
void
setXslResource(Resource xslResource)
API method to set the XSL Resource.

Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTask

XsetIgnore, XsetItems, 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

Methods inherited from class org.apache.tools.ant.Task

bindToOwner, execute, 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, log, log, setDescription, setLocation, setProject

Field Details

PROCESSOR_TRAX

public static final String PROCESSOR_TRAX
The default processor is trax
Since:
Ant 1.7

Constructor Details

XSLTProcess

public XSLTProcess()
Creates a new XSLTProcess Task.

Method Details

add

public void add(ResourceCollection rc)
Adds a collection of resources to style in addition to the given file or the implicit fileset.
Parameters:
rc - the collection of resources to style
Since:
Ant 1.7

add

public void add(FileNameMapper fileNameMapper)
            throws BuildException
Adds a nested filenamemapper.
Parameters:
fileNameMapper - the mapper to add
Throws:
BuildException - if more than one mapper is defined
Since:
Ant 1.7.0

addConfiguredStyle

public void addConfiguredStyle(Resources rc)
Add a nested <style> element.
Parameters:
rc - the configured Resources object represented as <style>.
Since:
Ant 1.7

addConfiguredXMLCatalog

public void addConfiguredXMLCatalog(XMLCatalog xmlCatalog)
Add the catalog to our internal catalog
Parameters:
xmlCatalog - the XMLCatalog instance to use to look up DTDs

addMapper

public void addMapper(Mapper mapper)
Defines the mapper to map source to destination files.
Parameters:
mapper - the mapper to use
Since:
Ant 1.6.2

configureLiaison

protected void configureLiaison(File stylesheet)
            throws BuildException

Deprecated. since Ant 1.7

Loads the stylesheet and set xsl:param parameters.
Parameters:
stylesheet - the file from which to load the stylesheet.
Throws:
BuildException - if the stylesheet cannot be loaded.

configureLiaison

protected void configureLiaison(Resource stylesheet)
            throws BuildException
Loads the stylesheet and set xsl:param parameters.
Parameters:
stylesheet - the resource from which to load the stylesheet.
Throws:
BuildException - if the stylesheet cannot be loaded.
Since:
Ant 1.7

createClasspath

public Path createClasspath()
Set the optional classpath to the XSL processor
Returns:
a path instance to be configured by the Ant core.

createFactory

public XSLTProcess.Factory createFactory()
            throws BuildException
Create the factory element to configure a trax liaison.
Returns:
the newly created factory element.
Throws:
BuildException - if the element is created more than one time.

createOutputProperty

public XSLTProcess.OutputProperty createOutputProperty()
Create an instance of an output property to be configured.
Returns:
the newly created output property.
Since:
Ant 1.5

createParam

public XSLTProcess.Param createParam()
Create an instance of an XSL parameter for configuration by Ant.
Returns:
an instance of the Param class to be configured.

execute

public void execute()
            throws BuildException
Executes the task.
Overrides:
execute in interface Task
Throws:
BuildException - if there is an execution problem.
To do:
validate that if either in or our is defined, then both are

getFactory

public XSLTProcess.Factory getFactory()
Get the factory instance configured for this processor
Returns:
the factory instance in use

getLiaison

protected XSLTLiaison getLiaison()
Get the Liason implementation to use in processing.
Returns:
an instance of the XSLTLiason interface.

getOutputProperties

public Enumeration getOutputProperties()
Get an enumeration on the outputproperties.
Returns:
the outputproperties

getXMLCatalog

public XMLCatalog getXMLCatalog()
Get the XML catalog containing entity definitions
Returns:
the XML catalog for the task.

init

public void init()
            throws BuildException
Initialize internal instance of XMLCatalog
Overrides:
init in interface Task
Throws:
BuildException - on error

setBasedir

public void setBasedir(File dir)
Set the base directory; optional, default is the project's basedir.
Parameters:
dir - the base directory

setClasspath

public void setClasspath(Path classpath)
Set the optional classpath to the XSL processor
Parameters:
classpath - the classpath to use when loading the XSL processor

setClasspathRef

public void setClasspathRef(Reference r)
Set the reference to an optional classpath to the XSL processor
Parameters:
r - the id of the Ant path instance to act as the classpath for loading the XSL processor

setDestdir

public void setDestdir(File dir)
Set the destination directory into which the XSL result files should be copied to; required, unless in and out are specified.
Parameters:
dir - the name of the destination directory

setExtension

public void setExtension(String name)
Set the desired file extension to be used for the target; optional, default is html.
Parameters:
name - the extension to use

setFileDirParameter

public void setFileDirParameter(String fileDirParameter)
Pass the directory name of the current processed file as a xsl parameter to the transformation. This value sets the name of that xsl parameter.
Parameters:
fileDirParameter - name of the xsl parameter retrieving the current file directory

setFileNameParameter

public void setFileNameParameter(String fileNameParameter)
Pass the filename of the current processed file as a xsl parameter to the transformation. This value sets the name of that xsl parameter.
Parameters:
fileNameParameter - name of the xsl parameter retrieving the current file name

setForce

public void setForce(boolean force)
Set whether to check dependencies, or always generate; optional, default is false.
Parameters:
force - true if always generate.

setIn

public void setIn(File inFile)
specifies a single XML document to be styled. Should be used with the out attribute; ; required if out is set
Parameters:
inFile - the input file

setOut

public void setOut(File outFile)
Specifies the output name for the styled result from the in attribute; required if in is set
Parameters:
outFile - the output File instance.

setProcessor

public void setProcessor(String processor)
Set the name of the XSL processor to use; optional, default trax. Other values are "xalan" for Xalan1
Parameters:
processor - the name of the XSL processor

setReloadStylesheet

public void setReloadStylesheet(boolean b)
Controls whether the stylesheet is reloaded for every transform.

Setting this to true may get around a bug in certain Xalan-J versions, default is false.

Parameters:
b - a boolean value
Since:
Ant 1.5.2

setScanIncludedDirectories

public void setScanIncludedDirectories(boolean b)
Whether to style all files in the included directories as well; optional, default is true.
Parameters:
b - true if files in included directories are processed.
Since:
Ant 1.5

setStyle

public void setStyle(String xslFile)
Name of the stylesheet to use - given either relative to the project's basedir or as an absolute path; required.
Parameters:
xslFile - the stylesheet to use

setUseImplicitFileset

public void setUseImplicitFileset(boolean useimplicitfileset)
Whether to use the implicit fileset.

Set this to false if you want explicit control with nested resource collections.

Parameters:
useimplicitfileset - set to true if you want to use implicit fileset
Since:
Ant 1.7

setXslResource

public void setXslResource(Resource xslResource)
API method to set the XSL Resource.
Parameters:
xslResource - Resource to set as the stylesheet.
Since:
Ant 1.7