Package net.sf.saxon.ant
Class AntTransform
- java.lang.Object
-
- org.apache.tools.ant.ProjectComponent
-
- org.apache.tools.ant.Task
-
- org.apache.tools.ant.taskdefs.MatchingTask
-
- net.sf.saxon.ant.AntTransform
-
- All Implemented Interfaces:
java.lang.Cloneable,org.apache.tools.ant.taskdefs.XSLTLogger,org.apache.tools.ant.types.selectors.SelectorContainer
public class AntTransform extends org.apache.tools.ant.taskdefs.MatchingTask implements org.apache.tools.ant.taskdefs.XSLTLoggerProcesses a set of XML documents via XSLT. This is useful for building views of XML based documentation. This task for running Saxon transformations within Ant is modelled on the standard Ant xslt task (org.apache.tools.ant.taskdefs.XSLTProcess), and makes heavy reuse of its code. See Apache notice above.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAntTransform.OutputPropertySpecify how the result tree should be output as specified in the Serialization specification.static classAntTransform.ParamThe Param inner class used to store XSL parameters
-
Constructor Summary
Constructors Constructor Description AntTransform()Create a new saxon-xslt Task.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidadd(org.apache.tools.ant.types.ResourceCollection rc)Adds a collection of resources to style in addition to the given file or the implicit fileset.voidadd(org.apache.tools.ant.util.FileNameMapper fileNameMapper)Adds a nested filenamemapper.voidaddConfiguredStyle(org.apache.tools.ant.types.resources.Resources rc)Add a nested <style> element.voidaddConfiguredXMLCatalog(org.apache.tools.ant.types.XMLCatalog xmlCatalog)Add the catalog to our internal catalogvoidaddMapper(org.apache.tools.ant.types.Mapper mapper)Defines the mapper to map source to destination files.protected voidconfigureLiaison(java.io.File stylesheet)Deprecated.since Ant 1.7protected voidconfigureLiaison(org.apache.tools.ant.types.Resource stylesheet)Loads the stylesheet and set xsl:param parameters.org.apache.tools.ant.types.PathcreateClasspath()Set the optional classpath to the XSL processorAntTransform.OutputPropertycreateOutputProperty()Create an instance of an output property to be configured.AntTransform.ParamcreateParam()Create an instance of an XSL parameter for configuration by Ant.voidexecute()Executes the task.ConfigurationgetConfiguration()Get the Saxon Configuration being used (useful for subclasses)java.util.EnumerationgetOutputProperties()Get an enumeration on the outputproperties.org.apache.tools.ant.types.XMLCataloggetXMLCatalog()Get the XML catalog containing entity definitionsvoidinit()Initialize internal instance of XMLCatalogvoidsetBasedir(java.io.File dir)Set the base directory; optional, default is the project's basedir.voidsetClasspath(org.apache.tools.ant.types.Path classpath)Set the optional classpath to the XSL processorvoidsetClasspathRef(org.apache.tools.ant.types.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, unless in and out are specified.voidsetDTDValidation(boolean validation)Indicate whether DTD validation is on or offvoidsetExpandDefaults(boolean expand)Set whether DTD or schema-defined element and attribute default values should be expanded Default is truevoidsetExtension(java.lang.String name)Set the desired file extension to be used for the target; optional, default is html.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.voidsetInitialMode(java.lang.String mode)Set the initial modevoidsetInitialTemplate(java.lang.String name)Set the initial templatevoidsetLineNumbering(boolean numbering)Set whether to maintain line numbers for input documentsvoidsetOut(java.io.File outFile)Specifies the output name for the styled result from the in attribute; required if in is setvoidsetRecoveryPolicy(java.lang.String policy)Set the policy for handling recoverable errorsvoidsetReloadStylesheet(boolean b)Controls whether the stylesheet is reloaded for every transform.voidsetScanIncludedDirectories(boolean b)Set whether to style all files in the included directories as well; optional, default is true.voidsetSchemaAware(boolean schemaAware)Indicate whether schema-aware processing is requiredvoidsetSchemaValidation(java.lang.String validation)Indicate whether schema validation for all input files to the transformation is strict, lax, or skipvoidsetStyle(java.lang.String xslFile)Name of the stylesheet to use - given either relative to the project's basedir or as an absolute path; required.voidsetTracing(boolean tracing)Set whether to trace stylesheet executionvoidsetUseImplicitFileset(boolean useimplicitfileset)Set whether to use the implicit fileset.voidsetXmlVersion(java.lang.String version)Set the XML version to be used for validating namesvoidsetXslResource(org.apache.tools.ant.types.Resource xslResource)API method to set the XSL Resource.-
Methods inherited from class org.apache.tools.ant.taskdefs.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, XsetItems
-
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, 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.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation
-
-
-
-
Method Detail
-
setScanIncludedDirectories
public void setScanIncludedDirectories(boolean b)
Set 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
public void addMapper(org.apache.tools.ant.types.Mapper mapper)
Defines the mapper to map source to destination files.- Parameters:
mapper- the mapper to use- Throws:
org.apache.tools.ant.BuildException- if more than one mapper is defined- Since:
- Ant 1.6.2
-
add
public void add(org.apache.tools.ant.types.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
-
addConfiguredStyle
public void addConfiguredStyle(org.apache.tools.ant.types.resources.Resources rc)
Add a nested <style> element.- Parameters:
rc- the configured Resources object represented as <style>.- Since:
- Ant 1.7
-
setXslResource
public void setXslResource(org.apache.tools.ant.types.Resource xslResource)
API method to set the XSL Resource.- Parameters:
xslResource- Resource to set as the stylesheet.- Since:
- Ant 1.7
-
add
public void add(org.apache.tools.ant.util.FileNameMapper fileNameMapper) throws org.apache.tools.ant.BuildExceptionAdds a nested filenamemapper.- Parameters:
fileNameMapper- the mapper to add- Throws:
org.apache.tools.ant.BuildException- if more than one mapper is defined- Since:
- Ant 1.7.0
-
execute
public void execute() throws org.apache.tools.ant.BuildExceptionExecutes the task.- Overrides:
executein classorg.apache.tools.ant.Task- Throws:
org.apache.tools.ant.BuildException- if there is an execution problem.
-
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
public void setBasedir(java.io.File dir)
Set the base directory; optional, default is the project's basedir.- Parameters:
dir- the base directory
-
setDestdir
public 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.- Parameters:
dir- the name of the destination directory
-
setExtension
public 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
-
setStyle
public 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
-
setClasspath
public void setClasspath(org.apache.tools.ant.types.Path classpath)
Set the optional classpath to the XSL processor- Parameters:
classpath- the classpath to use when loading the XSL processor
-
createClasspath
public org.apache.tools.ant.types.Path createClasspath()
Set the optional classpath to the XSL processor- Returns:
- a path instance to be configured by the Ant core.
-
setClasspathRef
public void setClasspathRef(org.apache.tools.ant.types.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
-
setSchemaAware
public void setSchemaAware(boolean schemaAware)
Indicate whether schema-aware processing is required- Parameters:
schemaAware- true if schema-aware processing is required
-
setSchemaValidation
public void setSchemaValidation(java.lang.String validation)
Indicate whether schema validation for all input files to the transformation is strict, lax, or skip- Parameters:
validation- "strict", "lax" or "skip"
-
setDTDValidation
public void setDTDValidation(boolean validation)
Indicate whether DTD validation is on or off- Parameters:
validation- set to true to request DTD validation of all input files to the transformation
-
setExpandDefaults
public void setExpandDefaults(boolean expand)
Set whether DTD or schema-defined element and attribute default values should be expanded Default is true- Parameters:
expand- true to expand default values, false if they are to be suppressed
-
setInitialMode
public void setInitialMode(java.lang.String mode)
Set the initial mode- Parameters:
mode- the initial mode for the transformation, in Clark notation
-
setInitialTemplate
public void setInitialTemplate(java.lang.String name)
Set the initial template- Parameters:
name- the name of the initial template for the transformation, in Clark notation
-
setRecoveryPolicy
public void setRecoveryPolicy(java.lang.String policy)
Set the policy for handling recoverable errors- Parameters:
policy- one of "silent", "recover", or "fatal". Default is "recover".
-
setTracing
public void setTracing(boolean tracing)
Set whether to trace stylesheet execution- Parameters:
tracing- true to trace execution. Default is false
-
setLineNumbering
public void setLineNumbering(boolean numbering)
Set whether to maintain line numbers for input documents- Parameters:
numbering- true to maintain line numbers. Default is false
-
setXmlVersion
public void setXmlVersion(java.lang.String version)
Set the XML version to be used for validating names- Parameters:
version- One of "1.0" or "1.1". Default is "1.0".
-
setUseImplicitFileset
public void setUseImplicitFileset(boolean useimplicitfileset)
Set 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
public void addConfiguredXMLCatalog(org.apache.tools.ant.types.XMLCatalog xmlCatalog)
Add the catalog to our internal catalog- Parameters:
xmlCatalog- the XMLCatalog instance to use to look up DTDs
-
setFileNameParameter
public 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
-
setFileDirParameter
public 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
-
setOut
public void setOut(java.io.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.
-
setIn
public void setIn(java.io.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
-
getConfiguration
public Configuration getConfiguration()
Get the Saxon Configuration being used (useful for subclasses)- Returns:
- the Saxon Configuration
-
getXMLCatalog
public org.apache.tools.ant.types.XMLCatalog getXMLCatalog()
Get the XML catalog containing entity definitions- Returns:
- the XML catalog for the task.
-
getOutputProperties
public java.util.Enumeration getOutputProperties()
Get an enumeration on the outputproperties.- Returns:
- the outputproperties
-
createParam
public AntTransform.Param createParam()
Create an instance of an XSL parameter for configuration by Ant.- Returns:
- an instance of the Param class to be configured.
-
createOutputProperty
public AntTransform.OutputProperty createOutputProperty()
Create an instance of an output property to be configured.- Returns:
- the newly created output property.
- Since:
- Ant 1.5
-
init
public void init() throws org.apache.tools.ant.BuildExceptionInitialize internal instance of XMLCatalog- Overrides:
initin classorg.apache.tools.ant.Task- Throws:
org.apache.tools.ant.BuildException- on error
-
configureLiaison
protected void configureLiaison(java.io.File stylesheet) throws org.apache.tools.ant.BuildExceptionDeprecated.since Ant 1.7Loads the stylesheet and set xsl:param parameters.- Parameters:
stylesheet- the file from which to load the stylesheet.- Throws:
org.apache.tools.ant.BuildException- if the stylesheet cannot be loaded.
-
configureLiaison
protected void configureLiaison(org.apache.tools.ant.types.Resource stylesheet) throws org.apache.tools.ant.BuildExceptionLoads the stylesheet and set xsl:param parameters.- Parameters:
stylesheet- the resource from which to load the stylesheet.- Throws:
org.apache.tools.ant.BuildException- if the stylesheet cannot be loaded.- Since:
- Ant 1.7
-
-