Package org.apache.tools.ant.taskdefs
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:
- java.lang.Cloneable,- XSLTLogger,- SelectorContainer
 
 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 SummaryNested Classes Modifier and Type Class Description static classXSLTProcess.FactoryThe factory element to configure a transformer factorystatic classXSLTProcess.OutputPropertySpecify how the result tree should be output as specified in the specification.static classXSLTProcess.ParamThe Param inner class used to store XSL parametersstatic classXSLTProcess.ParamTypeEnum for types of the parameter expression.classXSLTProcess.TraceConfigurationConfiguration for Xalan2 traces.
 - 
Field SummaryFields Modifier and Type Field Description static java.lang.StringPROCESSOR_TRAXThe default processor is trax- 
Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTaskfileset
 - 
Fields inherited from class org.apache.tools.ant.ProjectComponentdescription, location, project
 
- 
 - 
Constructor SummaryConstructors Constructor Description XSLTProcess()
 - 
Method SummaryModifier and Type Method Description voidadd(ResourceCollection rc)Adds a collection of resources to style in addition to the given file or the implicit fileset.voidadd(FileNameMapper fileNameMapper)Adds a nested filenamemapper.voidaddConfiguredStyle(Resources rc)Add a nested <style> element.voidaddConfiguredXMLCatalog(XMLCatalog xmlCatalog)Add the catalog to our internal catalogvoidaddMapper(Mapper mapper)Defines the mapper to map source to destination files.voidaddSysproperty(Environment.Variable sysp)A system property to set during transformation.voidaddSyspropertyset(PropertySet sysp)A set of system properties to set during transformation.protected voidconfigureLiaison(java.io.File stylesheet)Deprecated.since Ant 1.7protected voidconfigureLiaison(Resource stylesheet)Loads the stylesheet and set xsl:param parameters.PathcreateClasspath()Set the optional classpath to the XSL processorXSLTProcess.FactorycreateFactory()Create the factory element to configure a trax liaison.XSLTProcess.OutputPropertycreateOutputProperty()Create an instance of an output property to be configured.XSLTProcess.ParamcreateParam()Create an instance of an XSL parameter for configuration by Ant.XSLTProcess.TraceConfigurationcreateTrace()Enables Xalan2 traces and uses the given configuration.voidexecute()Executes the task.XSLTProcess.FactorygetFactory()Get the factory instance configured for this processorprotected XSLTLiaisongetLiaison()Get the Liaison implementation to use in processing.java.util.Enumeration<XSLTProcess.OutputProperty>getOutputProperties()Get an enumeration on the outputproperties.booleangetSuppressWarnings()Whether to suppress warning messages of the processor.XSLTProcess.TraceConfigurationgetTraceConfiguration()Configuration for Xalan2 traces.XMLCataloggetXMLCatalog()Get the XML catalog containing entity definitionsprotected voidhandleError(java.lang.String msg)Throws an exception with the given message if failOnError is true, otherwise logs the message using the WARN level.protected voidhandleError(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 voidhandleTransformationError(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.voidinit()Initialize internal instance of XMLCatalog.voidsetBasedir(java.io.File dir)Set the base directory; optional, default is the project's basedir.voidsetClasspath(Path classpath)Set the optional classpath to the XSL processorvoidsetClasspathRef(Reference r)Set the reference to an optional classpath to the XSL processorvoidsetDestdir(java.io.File dir)Set the destination directory into which the XSL result files should be copied to; required, unlessinandoutare specified.voidsetExtension(java.lang.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(java.lang.String fileDirParameter)Pass the directory name of the current processed file as a xsl parameter to the transformation.voidsetFileNameParameter(java.lang.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.voidsetIn(java.io.File inFile)specifies a single XML document to be styled.voidsetOut(java.io.File outFile)Specifies the output name for the styled result from theinattribute; required ifinis setvoidsetProcessor(java.lang.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.voidsetStyle(java.lang.String xslFile)Name 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 org.apache.tools.ant.taskdefs.MatchingTaskadd, 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
 - 
Methods inherited from class org.apache.tools.ant.TaskbindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 - 
Methods inherited from class org.apache.tools.ant.ProjectComponentclone, getDescription, getLocation, getProject, setDescription, setLocation
 - 
Methods inherited from class java.lang.Objectequals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.apache.tools.ant.taskdefs.XSLTLoggerlog
 
- 
 
- 
- 
- 
Field Detail- 
PROCESSOR_TRAXpublic static final java.lang.String PROCESSOR_TRAX The default processor is trax- Since:
- Ant 1.7
- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
setScanIncludedDirectoriespublic 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
 
 - 
setReloadStylesheetpublic 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- booleanvalue
- Since:
- Ant 1.5.2
 
 - 
addMapperpublic void addMapper(Mapper mapper) 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
 
 - 
addpublic 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
 
 - 
addConfiguredStylepublic void addConfiguredStyle(Resources rc) Add a nested <style> element.- Parameters:
- rc- the configured Resources object represented as <style>.
- Since:
- Ant 1.7
 
 - 
setXslResourcepublic void setXslResource(Resource xslResource) API method to set the XSL Resource.- Parameters:
- xslResource- Resource to set as the stylesheet.
- Since:
- Ant 1.7
 
 - 
addpublic 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
 
 - 
executepublic void execute() throws BuildExceptionExecutes the task.- Overrides:
- executein class- Task
- Throws:
- BuildException- if there is an execution problem.
- To do:
- validate that if either in or out is defined, then both are
 
 - 
setForcepublic void setForce(boolean force) Set whether to check dependencies, or always generate; optional, default is false.- Parameters:
- force- true if always generate.
 
 - 
setBasedirpublic void setBasedir(java.io.File dir) Set the base directory; optional, default is the project's basedir.- Parameters:
- dir- the base directory
 
 - 
setDestdirpublic void setDestdir(java.io.File dir) 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
 
 - 
setExtensionpublic void setExtension(java.lang.String name) Set the desired file extension to be used for the target; optional, default is html.- Parameters:
- name- the extension to use
 
 - 
setStylepublic 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.- Parameters:
- xslFile- the stylesheet to use
 
 - 
setClasspathpublic void setClasspath(Path classpath) Set the optional classpath to the XSL processor- Parameters:
- classpath- the classpath to use when loading the XSL processor
 
 - 
createClasspathpublic Path createClasspath() Set the optional classpath to the XSL processor- Returns:
- a path instance to be configured by the Ant core.
 
 - 
setClasspathRefpublic 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
 
 - 
setProcessorpublic void setProcessor(java.lang.String processor) Set the name of the XSL processor to use; optional, default trax.- Parameters:
- processor- the name of the XSL processor
 
 - 
setUseImplicitFilesetpublic 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
 
 - 
addConfiguredXMLCatalogpublic void addConfiguredXMLCatalog(XMLCatalog xmlCatalog) Add the catalog to our internal catalog- Parameters:
- xmlCatalog- the XMLCatalog instance to use to look up DTDs
 
 - 
setFileNameParameterpublic void setFileNameParameter(java.lang.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
 
 - 
setFileDirParameterpublic void setFileDirParameter(java.lang.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
 
 - 
setSuppressWarningspublic void setSuppressWarnings(boolean b) Whether to suppress warning messages of the processor.- Parameters:
- b- boolean
- Since:
- Ant 1.8.0
 
 - 
getSuppressWarningspublic boolean getSuppressWarnings() Whether to suppress warning messages of the processor.- Returns:
- boolean
- Since:
- Ant 1.8.0
 
 - 
setFailOnTransformationErrorpublic void setFailOnTransformationError(boolean b) Whether transformation errors should make the build fail.- Parameters:
- b- boolean
- Since:
- Ant 1.8.0
 
 - 
setFailOnErrorpublic void setFailOnError(boolean b) Whether any errors should make the build fail.- Parameters:
- b- boolean
- Since:
- Ant 1.8.0
 
 - 
setFailOnNoResourcespublic void setFailOnNoResources(boolean b) Whether the build should fail if the nested resource collection is empty.- Parameters:
- b- boolean
- Since:
- Ant 1.8.0
 
 - 
addSyspropertypublic void addSysproperty(Environment.Variable sysp) A system property to set during transformation.- Parameters:
- sysp- Environment.Variable
- Since:
- Ant 1.8.0
 
 - 
addSyspropertysetpublic void addSyspropertyset(PropertySet sysp) A set of system properties to set during transformation.- Parameters:
- sysp- PropertySet
- Since:
- Ant 1.8.0
 
 - 
createTracepublic XSLTProcess.TraceConfiguration 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
 
 - 
getTraceConfigurationpublic XSLTProcess.TraceConfiguration getTraceConfiguration() Configuration for Xalan2 traces.- Returns:
- TraceConfiguration
- Since:
- Ant 1.8.0
 
 - 
setOutpublic void setOut(java.io.File outFile) Specifies the output name for the styled result from theinattribute; required ifinis set- Parameters:
- outFile- the output File instance.
 
 - 
setInpublic void setIn(java.io.File inFile) specifies a single XML document to be styled. Should be used with theoutattribute; required ifoutis set- Parameters:
- inFile- the input file
 
 - 
getFactorypublic XSLTProcess.Factory getFactory() Get the factory instance configured for this processor- Returns:
- the factory instance in use
 
 - 
getXMLCatalogpublic XMLCatalog getXMLCatalog() Get the XML catalog containing entity definitions- Returns:
- the XML catalog for the task.
 
 - 
getOutputPropertiespublic java.util.Enumeration<XSLTProcess.OutputProperty> getOutputProperties() Get an enumeration on the outputproperties.- Returns:
- the outputproperties
 
 - 
getLiaisonprotected XSLTLiaison getLiaison() Get the Liaison implementation to use in processing.- Returns:
- an instance of the XSLTLiaison interface.
 
 - 
createParampublic XSLTProcess.Param createParam() Create an instance of an XSL parameter for configuration by Ant.- Returns:
- an instance of the Param class to be configured.
 
 - 
createOutputPropertypublic XSLTProcess.OutputProperty createOutputProperty() Create an instance of an output property to be configured.- Returns:
- the newly created output property.
- Since:
- Ant 1.5
 
 - 
initpublic void init() throws BuildExceptionInitialize internal instance of XMLCatalog. Initialize XPath for parameter evaluation.- Overrides:
- initin class- Task
- Throws:
- BuildException- on error
 
 - 
configureLiaison@Deprecated protected void configureLiaison(java.io.File stylesheet) throws BuildExceptionDeprecated.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.
 
 - 
configureLiaisonprotected 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
 
 - 
createFactorypublic 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.
 
 - 
handleErrorprotected 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.- Parameters:
- msg- String
- Since:
- Ant 1.8.0
 
 - 
handleErrorprotected 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.- Parameters:
- ex- Throwable
- Since:
- Ant 1.8.0
 
 - 
handleTransformationErrorprotected 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.- Parameters:
- ex- Exception
- Since:
- Ant 1.8.0
 
 
- 
 
-