Class XSLTProcess
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.apache.tools.ant.taskdefs.MatchingTask
org.apache.tools.ant.taskdefs.XSLTProcess
- All Implemented Interfaces:
Cloneable, XSLTLogger, SelectorContainer
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
Nested ClassesModifier and TypeClassDescriptionstatic classThe factory element to configure a transformer factorystatic classSpecify how the result tree should be output as specified in the specification.static classThe Param inner class used to store XSL parametersstatic enumEnum for types of the parameter expression.final classConfiguration for Xalan2 traces. -
Field Summary
FieldsFields inherited from class MatchingTask
filesetFields inherited from class ProjectComponent
description, location, project -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a collection of resources to style in addition to the given file or the implicit fileset.voidadd(FileNameMapper fileNameMapper) Adds a nested filenamemapper.voidAdd a nested <style> element.voidaddConfiguredXMLCatalog(XMLCatalog xmlCatalog) Add the catalog to our internal catalogvoidDefines the mapper to map source to destination files.voidA system property to set during transformation.voidaddSyspropertyset(PropertySet sysp) A set of system properties to set during transformation.protected voidconfigureLiaison(File stylesheet) Deprecated.since Ant 1.7protected voidconfigureLiaison(Resource stylesheet) Loads the stylesheet and set xsl:param parameters.Set the optional classpath to the XSL processorCreate the factory element to configure a trax liaison.Create an instance of an output property to be configured.Create an instance of an XSL parameter for configuration by Ant.Enables Xalan2 traces and uses the given configuration.voidexecute()Executes the task.Get the factory instance configured for this processorprotected XSLTLiaisonGet the Liaison implementation to use in processing.Get an enumeration on the outputproperties.booleanWhether to suppress warning messages of the processor.Configuration for Xalan2 traces.Get the XML catalog containing entity definitionsprotected voidhandleError(String msg) Throws an exception with the given message if failOnError is true, otherwise logs the message using the WARN level.protected voidhandleError(Throwable ex) Throws an exception with the given nested exception if failOnError is true, otherwise logs the message using the WARN level.protected voidThrows an exception with the given nested exception if failOnError and failOnTransformationError are true, otherwise logs the message using the WARN level.voidinit()Initialize internal instance of XMLCatalog.voidsetBasedir(File dir) Set the base directory; optional, default is the project's basedir.voidsetClasspath(Path classpath) Set the optional classpath to the XSL processorvoidSet the reference to an optional classpath to the XSL processorvoidsetDestdir(File dir) Set the destination directory into which the XSL result files should be copied to; required, unlessinandoutare specified.voidsetExtension(String name) Set the desired file extension to be used for the target; optional, default is html.voidsetFailOnError(boolean b) Whether any errors should make the build fail.voidsetFailOnNoResources(boolean b) Whether the build should fail if the nested resource collection is empty.voidsetFailOnTransformationError(boolean b) Whether transformation errors should make the build fail.voidsetFileDirParameter(String fileDirParameter) Pass the directory name of the current processed file as a xsl parameter to the transformation.voidsetFileNameParameter(String fileNameParameter) Pass the filename of the current processed file as a xsl parameter to the transformation.voidsetForce(boolean force) Set whether to check dependencies, or always generate; optional, default is false.voidsetGranularity(long granularity) Set the number of milliseconds leeway to give before deciding a target is out of date.voidspecifies a single XML document to be styled.voidSpecifies the output name for the styled result from theinattribute; required ifinis setvoidsetProcessor(String processor) Set the name of the XSL processor to use; optional, default trax.voidsetReloadStylesheet(boolean b) Controls whether the stylesheet is reloaded for every transform.voidsetScanIncludedDirectories(boolean b) Whether to style all files in the included directories as well; optional, default is true.voidName of the stylesheet to use - given either relative to the project's basedir or as an absolute path; required.voidsetSuppressWarnings(boolean b) Whether to suppress warning messages of the processor.voidsetUseImplicitFileset(boolean useimplicitfileset) Whether to use the implicit fileset.voidsetXslResource(Resource xslResource) API method to set the XSL Resource.Methods inherited from class 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, XsetItemsModifier and TypeMethodDescriptionvoidadd(FileSelector selector) add an arbitrary selectorvoidaddAnd(AndSelector selector) add an "And" selector entry on the selector listvoidaddContains(ContainsSelector selector) add a contains selector entry on the selector listvoidaddContainsRegexp(ContainsRegexpSelector selector) add a regular expression selector entry on the selector listvoidaddCustom(ExtendSelector selector) add an extended selector entry on the selector listvoidaddDate(DateSelector selector) add a selector date entry on the selector listvoidaddDepend(DependSelector selector) add a depends selector entry on the selector listvoidaddDepth(DepthSelector selector) add a depth selector entry on the selector listvoidaddDifferent(DifferentSelector selector) add a type selector entry on the type listvoidaddFilename(FilenameSelector selector) add a selector filename entry on the selector listvoidaddMajority(MajoritySelector selector) add a majority selector entry on the selector listvoidaddModified(ModifiedSelector selector) add the modified selectorvoidaddNone(NoneSelector selector) add a "None" selector entry on the selector listvoidaddNot(NotSelector selector) add a "Not" selector entry on the selector listvoidaddOr(OrSelector selector) add an "Or" selector entry on the selector listvoidaddPresent(PresentSelector selector) add a present selector entry on the selector listvoidaddSelector(SelectSelector selector) add a "Select" selector entry on the selector listvoidaddSize(SizeSelector selector) add a selector size entry on the selector listvoidaddType(TypeSelector selector) add a type selector entry on the type listvoidappendSelector(FileSelector selector) Add a new selector into this container.add a name entry on the exclude listadd a name entry on the include files listadd a name entry on the include listadd a name entry on the include files listadd a set of patternsprotected DirectoryScannergetDirectoryScanner(File baseDir) Returns the directory scanner needed to access the files to process.protected final FileSetAccessor for the implicit fileset.Returns the set of selectors as an array.booleanIndicates whether there are any selectors here.intGives the count of the number of selectors in this containerReturns an enumerator for accessing the set of selectors.voidsetCaseSensitive(boolean isCaseSensitive) Sets case sensitivity of the file systemvoidsetDefaultexcludes(boolean useDefaultExcludes) Sets whether default exclusions should be used or not.voidsetExcludes(String excludes) Sets the set of exclude patterns.voidsetExcludesfile(File excludesfile) Sets the name of the file containing the includes patterns.voidsetFollowSymlinks(boolean followSymlinks) Sets whether or not symbolic links or Windows junctions should be followed.voidsetIncludes(String includes) Sets the set of include patterns.voidsetIncludesfile(File includesfile) Sets the name of the file containing the includes patterns.voidsetProject(Project project) Sets the project object of this component.voidXsetIgnore(String ignoreString) List of filenames and directory names to not include.voidSet this to be the items in the base directory that you want to be included.Methods inherited from class Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskTypeModifier and TypeMethodDescriptionfinal voidbindToOwner(Task owner) Bind a task to another; use this when configuring a newly created task to do work on behalf of another.Returns the container target of this task.Returns the wrapper used for runtime configuration.Returns the name to use in logging messages.Return the type of task.protected RuntimeConfigurableReturn the runtime configurable structure for this task.protected voidhandleErrorFlush(String output) Handles an error line by logging it with the WARN priority.protected voidhandleErrorOutput(String output) Handles an error output by logging it with the WARN priority.protected voidhandleFlush(String output) Handles output by logging it with the INFO priority.protected inthandleInput(byte[] buffer, int offset, int length) Handle an input request by this task.protected voidhandleOutput(String output) Handles output by logging it with the INFO priority.protected final booleanHas this task been marked invalid?voidLogs a message with the default (INFO) priority.voidLogs a message with the given priority.voidLogs a message with the given priority.voidLogs a message with the given priority.voidConfigures this task - if it hasn't been done already.final voidperform()Performs this task if it's still valid, or gets a replacement version and performs that otherwise.voidForce the task to be reconfigured from its RuntimeConfigurable.voidsetOwningTarget(Target target) Sets the target container of this task.voidSets the wrapper to be used for runtime configuration.voidsetTaskName(String name) Sets the name to use in logging messages.voidsetTaskType(String type) Sets the name with which the task has been invoked.Methods inherited from class ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocationModifier and TypeMethodDescriptionclone()Returns the description of the current action.Returns the file/location where this task was defined.Returns the project to which this component belongs.voidsetDescription(String desc) Sets a description of the current action.voidsetLocation(Location location) Sets the file/location where this task was defined.Methods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface XSLTLogger
log
-
Field Details
-
PROCESSOR_TRAX
-
-
Constructor Details
-
XSLTProcess
public XSLTProcess()
-
-
Method Details
-
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
-
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- abooleanvalue- Since:
- Ant 1.5.2
-
addMapper
Defines the mapper to map source to destination files.- Parameters:
mapper- the mapper to use- Throws:
BuildException- if more than one mapper is defined- Since:
- Ant 1.6.2
-
add
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
-
addConfiguredStyle
Add a nested <style> element.- Parameters:
rc- the configured Resources object represented as <style>.- Since:
- Ant 1.7
-
setXslResource
API method to set the XSL Resource.- Parameters:
xslResource- Resource to set as the stylesheet.- Since:
- Ant 1.7
-
add
Adds a nested filenamemapper.- Parameters:
fileNameMapper- the mapper to add- Throws:
BuildException- if more than one mapper is defined- Since:
- Ant 1.7.0
-
execute
Executes the task.- Overrides:
executein classTask- Throws:
BuildException- if there is an execution problem.- To do:
- validate that if either in or out is defined, then both are
-
setForce
public void setForce(boolean force) Set whether to check dependencies, or always generate; optional, default is false.- Parameters:
force- true if always generate.
-
setBasedir
Set the base directory; optional, default is the project's basedir.- Parameters:
dir- the base directory
-
setDestdir
Set the destination directory into which the XSL result files should be copied to; required, unlessinandoutare specified.- Parameters:
dir- the name of the destination directory
-
setExtension
Set the desired file extension to be used for the target; optional, default is html.- Parameters:
name- the extension to use
-
setStyle
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
-
setClasspath
Set the optional classpath to the XSL processor- Parameters:
classpath- the classpath to use when loading the XSL processor
-
createClasspath
Set the optional classpath to the XSL processor- Returns:
- a path instance to be configured by the Ant core.
-
setClasspathRef
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
-
setProcessor
Set the name of the XSL processor to use; optional, default trax.- Parameters:
processor- the name of the XSL processor
-
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
-
addConfiguredXMLCatalog
Add the catalog to our internal catalog- Parameters:
xmlCatalog- the XMLCatalog instance to use to look up DTDs
-
setFileNameParameter
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
-
setFileDirParameter
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
-
setSuppressWarnings
public void setSuppressWarnings(boolean b) Whether to suppress warning messages of the processor.- Parameters:
b- boolean- Since:
- Ant 1.8.0
-
getSuppressWarnings
public boolean getSuppressWarnings()Whether to suppress warning messages of the processor.- Returns:
- boolean
- Since:
- Ant 1.8.0
-
setFailOnTransformationError
public void setFailOnTransformationError(boolean b) Whether transformation errors should make the build fail.- Parameters:
b- boolean- Since:
- Ant 1.8.0
-
setFailOnError
public void setFailOnError(boolean b) Whether any errors should make the build fail.- Parameters:
b- boolean- Since:
- Ant 1.8.0
-
setFailOnNoResources
public void setFailOnNoResources(boolean b) Whether the build should fail if the nested resource collection is empty.- Parameters:
b- boolean- Since:
- Ant 1.8.0
-
addSysproperty
A system property to set during transformation.- Parameters:
sysp- Environment.Variable- Since:
- Ant 1.8.0
-
addSyspropertyset
A set of system properties to set during transformation.- Parameters:
sysp- PropertySet- Since:
- Ant 1.8.0
-
createTrace
Enables Xalan2 traces and uses the given configuration.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.
- Returns:
- TraceConfiguration
- Since:
- Ant 1.8.0
-
getTraceConfiguration
Configuration for Xalan2 traces.- Returns:
- TraceConfiguration
- Since:
- Ant 1.8.0
-
setGranularity
public void setGranularity(long granularity) Set the number of milliseconds leeway to give before deciding a target is out of date.Default is 1 second, or 2 seconds on DOS systems.
- Parameters:
granularity- the granularity used to decide if a target is out of date.- Since:
- Ant 1.10.16
-
setOut
Specifies the output name for the styled result from theinattribute; required ifinis set- Parameters:
outFile- the output File instance.
-
setIn
specifies a single XML document to be styled. Should be used with theoutattribute; required ifoutis set- Parameters:
inFile- the input file
-
getFactory
Get the factory instance configured for this processor- Returns:
- the factory instance in use
-
getXMLCatalog
Get the XML catalog containing entity definitions- Returns:
- the XML catalog for the task.
-
getOutputProperties
Get an enumeration on the outputproperties.- Returns:
- the outputproperties
-
getLiaison
Get the Liaison implementation to use in processing.- Returns:
- an instance of the XSLTLiaison interface.
-
createParam
Create an instance of an XSL parameter for configuration by Ant.- Returns:
- an instance of the Param class to be configured.
-
createOutputProperty
Create an instance of an output property to be configured.- Returns:
- the newly created output property.
- Since:
- Ant 1.5
-
init
Initialize internal instance of XMLCatalog. Initialize XPath for parameter evaluation.- Overrides:
initin classTask- Throws:
BuildException- on error
-
configureLiaison
Deprecated.since Ant 1.7Loads 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
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
-
createFactory
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.
-
handleError
Throws an exception with the given message if failOnError is true, otherwise logs the message using the WARN level.- Parameters:
msg- String- Since:
- Ant 1.8.0
-
handleError
Throws an exception with the given nested exception if failOnError is true, otherwise logs the message using the WARN level.- Parameters:
ex- Throwable- Since:
- Ant 1.8.0
-
handleTransformationError
Throws an exception with the given nested exception if failOnError and failOnTransformationError are true, otherwise logs the message using the WARN level.- Parameters:
ex- Exception- Since:
- Ant 1.8.0
-