public class XSLTProcess extends MatchingTask implements XSLTLogger
Modifier and Type | Class and Description |
---|---|
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
|
static class |
XSLTProcess.ParamType
Enum for types of the parameter expression.
|
class |
XSLTProcess.TraceConfiguration
Configuration for Xalan2 traces.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PROCESSOR_TRAX
The default processor is trax
|
fileset
description, location, project
Constructor and Description |
---|
XSLTProcess()
Creates a new XSLTProcess Task.
|
Modifier and Type | Method and Description |
---|---|
void |
add(FileNameMapper fileNameMapper)
Adds a nested filenamemapper.
|
void |
add(ResourceCollection rc)
Adds a collection of resources to style in addition to the
given file or the implicit fileset.
|
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.
|
void |
addSysproperty(Environment.Variable sysp)
A system property to set during transformation.
|
void |
addSyspropertyset(PropertySet sysp)
A set of system properties to set during transformation.
|
protected void |
configureLiaison(java.io.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.
|
XSLTProcess.TraceConfiguration |
createTrace()
Enables Xalan2 traces and uses the given configuration.
|
void |
execute()
Executes the task.
|
XSLTProcess.Factory |
getFactory()
Get the factory instance configured for this processor
|
protected XSLTLiaison |
getLiaison()
Get the Liaison implementation to use in processing.
|
java.util.Enumeration<XSLTProcess.OutputProperty> |
getOutputProperties()
Get an enumeration on the outputproperties.
|
boolean |
getSuppressWarnings()
Whether to suppress warning messages of the processor.
|
XSLTProcess.TraceConfiguration |
getTraceConfiguration()
Configuration for Xalan2 traces.
|
XMLCatalog |
getXMLCatalog()
Get the XML catalog containing entity definitions
|
protected void |
handleError(java.lang.String msg)
Throws an exception with the given message if failOnError is
true, otherwise logs the message using the WARN level.
|
protected void |
handleError(java.lang.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(java.lang.Exception ex)
Throws an exception with the given nested exception if
failOnError and failOnTransformationError are true, otherwise
logs the message using the WARN level.
|
void |
init()
Initialize internal instance of XMLCatalog.
|
void |
setBasedir(java.io.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(java.io.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(java.lang.String name)
Set the desired file extension to be used for the target;
optional, default is html.
|
void |
setFailOnError(boolean b)
Whether any errors should make the build fail.
|
void |
setFailOnNoResources(boolean b)
Whether the build should fail if the nested resource collection is empty.
|
void |
setFailOnTransformationError(boolean b)
Whether transformation errors should make the build fail.
|
void |
setFileDirParameter(java.lang.String fileDirParameter)
Pass the directory name of the current processed file as a xsl parameter
to the transformation.
|
void |
setFileNameParameter(java.lang.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(java.io.File inFile)
specifies a single XML document to be styled.
|
void |
setOut(java.io.File outFile)
Specifies the output name for the styled result from the
in attribute; required if in is set
|
void |
setProcessor(java.lang.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(java.lang.String xslFile)
Name of the stylesheet to use - given either relative
to the project's basedir or as an absolute path; required.
|
void |
setSuppressWarnings(boolean b)
Whether to suppress warning messages of the processor.
|
void |
setUseImplicitFileset(boolean useimplicitfileset)
Whether to use the implicit fileset.
|
void |
setXslResource(Resource xslResource)
API method to set the XSL Resource.
|
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
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
clone, getDescription, getLocation, getProject, setDescription, setLocation
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
log
public static final java.lang.String PROCESSOR_TRAX
public void setScanIncludedDirectories(boolean b)
b
- true if files in included directories are processed.public void setReloadStylesheet(boolean b)
Setting this to true may get around a bug in certain Xalan-J versions, default is false.
b
- a boolean
valuepublic void addMapper(Mapper mapper)
mapper
- the mapper to useBuildException
- if more than one mapper is definedpublic void add(ResourceCollection rc)
rc
- the collection of resources to stylepublic void addConfiguredStyle(Resources rc)
rc
- the configured Resources object represented as <style>.public void setXslResource(Resource xslResource)
xslResource
- Resource to set as the stylesheet.public void add(FileNameMapper fileNameMapper) throws BuildException
fileNameMapper
- the mapper to addBuildException
- if more than one mapper is definedpublic void execute() throws BuildException
execute
in class Task
BuildException
- if there is an execution problem.public void setForce(boolean force)
force
- true if always generate.public void setBasedir(java.io.File dir)
dir
- the base directorypublic void setDestdir(java.io.File dir)
dir
- the name of the destination directorypublic void setExtension(java.lang.String name)
name
- the extension to usepublic void setStyle(java.lang.String xslFile)
xslFile
- the stylesheet to usepublic void setClasspath(Path classpath)
classpath
- the classpath to use when loading the XSL processorpublic Path createClasspath()
public void setClasspathRef(Reference r)
r
- the id of the Ant path instance to act as the classpath
for loading the XSL processorpublic void setProcessor(java.lang.String processor)
processor
- the name of the XSL processorpublic void setUseImplicitFileset(boolean useimplicitfileset)
Set this to false if you want explicit control with nested resource collections.
useimplicitfileset
- set to true if you want to use implicit filesetpublic void addConfiguredXMLCatalog(XMLCatalog xmlCatalog)
xmlCatalog
- the XMLCatalog instance to use to look up DTDspublic void setFileNameParameter(java.lang.String fileNameParameter)
fileNameParameter
- name of the xsl parameter retrieving the
current file namepublic void setFileDirParameter(java.lang.String fileDirParameter)
fileDirParameter
- name of the xsl parameter retrieving the
current file directorypublic void setSuppressWarnings(boolean b)
b
- booleanpublic boolean getSuppressWarnings()
public void setFailOnTransformationError(boolean b)
b
- booleanpublic void setFailOnError(boolean b)
b
- booleanpublic void setFailOnNoResources(boolean b)
b
- booleanpublic void addSysproperty(Environment.Variable sysp)
sysp
- Environment.Variablepublic void addSyspropertyset(PropertySet sysp)
sysp
- PropertySetpublic XSLTProcess.TraceConfiguration createTrace()
Note that this element doesn't have any effect with a processor other than trax or if the Transformer is not Xalan2's transformer implementation.
public XSLTProcess.TraceConfiguration getTraceConfiguration()
public void setOut(java.io.File outFile)
outFile
- the output File instance.public void setIn(java.io.File inFile)
inFile
- the input filepublic XSLTProcess.Factory getFactory()
public XMLCatalog getXMLCatalog()
public java.util.Enumeration<XSLTProcess.OutputProperty> getOutputProperties()
protected XSLTLiaison getLiaison()
public XSLTProcess.Param createParam()
public XSLTProcess.OutputProperty createOutputProperty()
public void init() throws BuildException
init
in class Task
BuildException
- on error@Deprecated protected void configureLiaison(java.io.File stylesheet) throws BuildException
stylesheet
- the file from which to load the stylesheet.BuildException
- if the stylesheet cannot be loaded.protected void configureLiaison(Resource stylesheet) throws BuildException
stylesheet
- the resource from which to load the stylesheet.BuildException
- if the stylesheet cannot be loaded.public XSLTProcess.Factory createFactory() throws BuildException
BuildException
- if the element is created more than one time.protected void handleError(java.lang.String msg)
msg
- Stringprotected void handleError(java.lang.Throwable ex)
ex
- Throwableprotected void handleTransformationError(java.lang.Exception ex)
ex
- Exception