Top Description Inners Fields Constructors Methods
org.apache.tools.ant.taskdefs

public Class XSLTProcess

extends MatchingTask
implements XSLTLogger
Class Inheritance
All Implemented Interfaces
org.apache.tools.ant.taskdefs.XSLTLogger
Imports
java.io.File, .OutputStream, java.util.ArrayList, .Collections, .EnumMap, .Enumeration, .List, .Map, .Vector, javax.xml.namespace.QName, javax.xml.xpath.XPath, .XPathConstants, .XPathExpression, .XPathExpressionException, .XPathFactory, org.apache.tools.ant.AntClassLoader, .BuildException, .DirectoryScanner, .DynamicConfigurator, .Project, .ProjectComponent, .PropertyHelper, org.apache.tools.ant.taskdefs.optional.TraXLiaison, org.apache.tools.ant.types.CommandlineJava, .Environment, .Mapper, .Path, .PropertySet, .Reference, .Resource, .ResourceCollection, .XMLCatalog, org.apache.tools.ant.types.resources.FileProvider, .FileResource, .Resources, .Union, org.apache.tools.ant.util.ClasspathUtils, .FileNameMapper, .FileUtils, .ResourceUtils, .StringUtils

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

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
XSLTProcess.Factory

The factory element to configure a transformer factory

public static class
XSLTProcess.OutputProperty

Specify how the result tree should be output as specified in the specification.

public static class
XSLTProcess.Param

The Param inner class used to store XSL parameters

public static enum
XSLTProcess.ParamType

Enum for types of the parameter expression.

private class
XSLTProcess.StyleMapper

Mapper implementation of the "traditional" way <xslt> mapped filenames.

public class
XSLTProcess.TraceConfiguration

Configuration for Xalan2 traces.

Field Summary

Modifier and TypeField and Description
private File
baseDir

where to find the source XML file, default is the project's basedir

private Path
classpath

Classpath to use when trying to load the XSL processor

private File
destDir

destination directory

private XSLTProcess.Factory
factory

factory element for TraX processors only

private boolean
failOnError

whether to fail the build if an error occurs.

private boolean
failOnNoResources

Whether the build should fail if the nested resource collection is empty.

private boolean
failOnTransformationError

whether to fail the build if an error occurs during transformation.

private static final FileUtils
FILE_UTILS

Utilities used for file operations

private String
fileDirParameter

name for XSL parameter containing the file directory

private String
fileNameParameter

name for XSL parameter containing the filename

private boolean
force

force output of target files even if they already exist

private File
inFile

Input XML document to be used

private XSLTLiaison
liaison

The Liaison implementation to use to communicate with the XSL processor

private AntClassLoader
loader

AntClassLoader for the nested <classpath> - if set.

private Mapper
mapperElement

Mapper to use when a set of files gets processed.

private File
outFile

Output file

private final List<XSLTProcess.OutputProperty>
outputProperties

XSL output properties to be used

private final List<XSLTProcess.Param>
params

additional parameters to be passed to the stylesheets

private boolean
performDirectoryScan

Whether to style all files in the included directories as well.

private String
processor

The name of the XSL processor to use

public static final String
PROCESSOR_TRAX

The default processor is trax

private final Union
resources

Additional resource collections to process.

private boolean
reuseLoadedStylesheet

whether to reuse Transformer if transforming multiple files.

private boolean
stylesheetLoaded

Flag which indicates if the stylesheet has been loaded into the processor

private boolean
suppressWarnings

whether to suppress warnings.

private final CommandlineJava.SysProperties
sysProperties

System properties to set during transformation.

private String
targetExtension

extension of the files produced by XSL processing

private XSLTProcess.TraceConfiguration
traceConfiguration

Trace configuration for Xalan2.

private boolean
useImplicitFileset

Whether to use the implicit fileset.

private final XMLCatalog
xmlCatalog

for resolving entities such as dtds

private XPath
xpath

For evaluating template params

private XPathFactory
xpathFactory

For evaluating template params

private String
xslFile

XSL stylesheet as a filename

private Resource
Inherited from org.apache.tools.ant.taskdefs.MatchingTask:
fileset

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
add(final ResourceCollection
the collection of resources to style
rc
)

Adds a collection of resources to style in addition to the given file or the implicit fileset.

public void
add(final FileNameMapper
the mapper to add
fileNameMapper
)

Adds a nested filenamemapper.

public void
addConfiguredStyle(final Resources
the configured Resources object represented as <style>.
rc
)

Add a nested <style> element.

public void
addConfiguredXMLCatalog(final XMLCatalog
the XMLCatalog instance to use to look up DTDs
xmlCatalog
)

Add the catalog to our internal catalog

public void
addMapper(final Mapper
the mapper to use
mapper
)

Defines the mapper to map source to destination files.

public void
addSysproperty(final Environment.Variable
Environment.Variable
sysp
)

A system property to set during transformation.

public void
addSyspropertyset(final PropertySet
PropertySet
sysp
)

A set of system properties to set during transformation.

private void
checkDest()

Throws a BuildException if the destination directory hasn't been specified.

protected void
configureLiaison(final File
the file from which to load the stylesheet.
stylesheet
)

Deprecated since Ant 1.7
Loads the stylesheet and set xsl:param parameters.
protected void
configureLiaison(final Resource
the resource from which to load the stylesheet.
stylesheet
)

Loads the stylesheet and set xsl:param parameters.

public Path

Returns:

a path instance to be configured by the Ant core.
createClasspath
()

Set the optional classpath to the XSL processor

public XSLTProcess.Factory

Returns:

the newly created factory element.
createFactory
()

Create the factory element to configure a trax liaison.

public XSLTProcess.OutputProperty

Returns:

the newly created output property.
createOutputProperty
()

Create an instance of an output property to be configured.

public XSLTProcess.Param

Returns:

an instance of the Param class to be configured.
createParam
()

Create an instance of an XSL parameter for configuration by Ant.

public XSLTProcess.TraceConfiguration

Returns:

TraceConfiguration
createTrace
()

Enables Xalan2 traces and uses the given configuration.

private void
ensureDirectoryFor(final File
the file for which the directories are required.
targetFile
)

Ensure the directory exists for a given file

private Object

Returns:

value to be passed to XSLT as parameter
evaluateParam
(final XSLTProcess.Param
parameter from Ant build file
param
)

Evaluates parameter expression according to its type.

public void
execute()

Overrides org.apache.tools.ant.Task.execute.

Executes the task.
public XSLTProcess.Factory

Returns:

the factory instance in use
getFactory
()

Get the factory instance configured for this processor

protected XSLTLiaison

Returns:

an instance of the XSLTLiaison interface.
getLiaison
()

Get the Liaison implementation to use in processing.

public Enumeration<XSLTProcess.OutputProperty>

Returns:

the outputproperties
getOutputProperties
()

Get an enumeration on the outputproperties.

public boolean

Returns:

boolean
getSuppressWarnings
()

Whether to suppress warning messages of the processor.

public XSLTProcess.TraceConfiguration

Returns:

TraceConfiguration
getTraceConfiguration
()

Configuration for Xalan2 traces.

public XMLCatalog

Returns:

the XML catalog for the task.
getXMLCatalog
()

Get the XML catalog containing entity definitions

protected void
handleError(final String
String
msg
)

Throws an exception with the given message if failOnError is true, otherwise logs the message using the WARN level.

protected void
handleError(final Throwable
Throwable
ex
)

Throws an exception with the given nested exception if failOnError is true, otherwise logs the message using the WARN level.

protected void
handleTransformationError(final Exception
Exception
ex
)

Throws an exception with the given nested exception if failOnError and failOnTransformationError are true, otherwise logs the message using the WARN level.

public void
init()

Overrides org.apache.tools.ant.Task.init.

Initialize internal instance of XMLCatalog.
private Class<?>

Returns:

the requested class.
loadClass
(final String
the name of the class to load.
classname
)

Load named class either via the system classloader or a given custom classloader.

private void
process(final File
the base directory for resolving files.
baseDir
,
final String
the input file
xmlFile
,
final File
the destination directory
destDir
,
final Resource
the stylesheet to use.
stylesheet
)

Processes the given input XML file and stores the result in the given resultFile.

private void
process(final File
the input file to process.
inFile
,
final File
the destination file.
outFile
,
final Resource
the stylesheet to use.
stylesheet
)

Process the input file to the output file with the given stylesheet.

private void
processResources(final Resource
style sheet to use
stylesheet
)

Styles all existing resources.

private void
resolveProcessor(final String
the name of the processor to load.
proc
)

Load processor here instead of in setProcessor - this will be called from within execute, so we have access to the latest classpath.

public void
setBasedir(final File
the base directory
dir
)

Set the base directory; optional, default is the project's basedir.

public void
setClasspath(final Path
the classpath to use when loading the XSL processor
classpath
)

Set the optional classpath to the XSL processor

public void
setClasspathRef(final Reference
the id of the Ant path instance to act as the classpath for loading the XSL processor
r
)

Set the reference to an optional classpath to the XSL processor

public void
setDestdir(final File
the name of the destination directory
dir
)

Set the destination directory into which the XSL result files should be copied to; required, unless in and out are specified.

public void
setExtension(final String
the extension to use
name
)

Set the desired file extension to be used for the target; optional, default is html.

public void
setFailOnError(final boolean
boolean
b
)

Whether any errors should make the build fail.

public void
setFailOnNoResources(final boolean
boolean
b
)

Whether the build should fail if the nested resource collection is empty.

public void
setFailOnTransformationError(final boolean
boolean
b
)

Whether transformation errors should make the build fail.

public void
setFileDirParameter(final String
name of the xsl parameter retrieving the current file directory
fileDirParameter
)

Pass the directory name of the current processed file as a xsl parameter to the transformation.

public void
setFileNameParameter(final String
name of the xsl parameter retrieving the current file name
fileNameParameter
)

Pass the filename of the current processed file as a xsl parameter to the transformation.

public void
setForce(final boolean
true if always generate.
force
)

Set whether to check dependencies, or always generate; optional, default is false.

public void
setIn(final File
the input file
inFile
)

specifies a single XML document to be styled.

private void
setLiaisonDynamicFileParameters(final XSLTLiaison
to change parameters for
liaison
,
final File
to get the additional file information from
inFile
)

Sets file parameter(s) for directory and filename if the attribute 'filenameparameter' or 'filedirparameter' are set in the task.

public void
setOut(final File
the output File instance.
outFile
)

Specifies the output name for the styled result from the in attribute; required if in is set

public void
setProcessor(final String
the name of the XSL processor
processor
)

Set the name of the XSL processor to use; optional, default trax.

public void
setReloadStylesheet(final boolean
a boolean value
b
)

Controls whether the stylesheet is reloaded for every transform.

public void
setScanIncludedDirectories(final boolean
true if files in included directories are processed.
b
)

Whether to style all files in the included directories as well; optional, default is true.

public void
setStyle(final String
the stylesheet to use
xslFile
)

Name of the stylesheet to use - given either relative to the project's basedir or as an absolute path; required.

public void
setSuppressWarnings(final boolean
boolean
b
)

Whether to suppress warning messages of the processor.

private void
setupLoader()

If a custom classpath has been defined but no loader created yet, create the classloader and set it as the context classloader.

public void
setUseImplicitFileset(final boolean
set to true if you want to use implicit fileset
useimplicitfileset
)

Whether to use the implicit fileset.

public void
setXslResource(final Resource
Resource to set as the stylesheet.
xslResource
)

API method to set the XSL Resource.

Inherited from org.apache.tools.ant.taskdefs.MatchingTask:
addaddAndaddContainsaddContainsRegexpaddCustomaddDateaddDependaddDepthaddDifferentaddFilenameaddMajorityaddModifiedaddNoneaddNotaddOraddPresentaddSelectoraddSizeaddTypeappendSelectorcreateExcludecreateExcludesFilecreateIncludecreateIncludesFilecreatePatternSetgetDirectoryScannergetImplicitFileSetgetSelectorshasSelectorsselectorCountselectorElementssetCaseSensitivesetDefaultexcludessetExcludessetExcludesfilesetFollowSymlinkssetIncludessetIncludesfilesetProjectXsetIgnoreXsetItems