public class JDXSLTProcess
extends org.apache.tools.ant.taskdefs.MatchingTask
implements org.apache.tools.ant.taskdefs.XSLTLogger
Type | Property and Description |
---|---|
JDXSLTProcess.OutputProperty |
createOutput
Create an instance of an output property to be configured.
|
Modifier and Type | Class and Description |
---|---|
static class |
JDXSLTProcess.Factory
The factory element to configure a transformer factory
|
static class |
JDXSLTProcess.OutputProperty
Specify how the result tree should be output as specified
in the
specification.
|
static class |
JDXSLTProcess.Param
The Param inner class used to store XSL parameters
|
private class |
JDXSLTProcess.StyleMapper
Mapper implementation of the "traditional" way <xslt>
mapped filenames.
|
Modifier and Type | Field and Description |
---|---|
private java.io.File |
baseDir
where to find the source XML file, default is the project's basedir
|
private org.apache.tools.ant.types.Path |
classpath
Classpath to use when trying to load the XSL processor
|
private java.io.File |
destDir
destination directory
|
private JDXSLTProcess.Factory |
factory
factory element for TraX processors only
|
private org.apache.tools.ant.util.FileUtils |
fileUtils
Utilities used for file operations
|
private boolean |
force
force output of target files even if they already exist
|
private java.io.File |
inFile
Input XML document to be used
|
private org.apache.tools.ant.taskdefs.XSLTLiaison |
liaison
The Liason implementation to use to communicate with the XSL
processor
|
private org.apache.tools.ant.AntClassLoader |
loader
AntClassLoader for the nested <classpath> - if set.
|
private org.apache.tools.ant.types.Mapper |
mapperElement
Mapper to use when a set of files gets processed.
|
private java.io.File |
outFile
Output file
|
private java.util.Vector |
outputProperties
XSL output properties to be used
|
private java.util.Vector |
params
additional parameters to be passed to the stylesheets
|
private boolean |
performDirectoryScan
Whether to style all files in the included directories as well.
|
private java.lang.String |
processor
The name of the XSL processor to use
|
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 java.lang.String |
styleurl
Systemid of stylesheet (url).
|
private java.lang.String |
targetExtension
extension of the files produced by XSL processing
|
private static java.lang.String |
TRAX_LIAISON_CLASS
Name of the TRAX Liaison class
|
private static java.lang.String |
XALAN_LIAISON_CLASS
Name of the now-deprecated Xalan liaison class
|
private org.apache.tools.ant.types.XMLCatalog |
xmlCatalog
for resolving entities such as dtds
|
private java.lang.String |
xslFile
XSL stylesheet
|
private static java.lang.String |
XSLP_LIAISON_CLASS
Name of the now-deprecated XSLP Liaison class
|
Constructor and Description |
---|
JDXSLTProcess()
Creates a new JDXSLTProcess Task.
|
Modifier and Type | Method and Description |
---|---|
void |
addConfiguredXMLCatalog(org.apache.tools.ant.types.XMLCatalog xmlCatalog)
Add the catalog to our internal catalog
|
void |
addMapper(org.apache.tools.ant.types.Mapper mapper)
Defines the mapper to map source to destination files.
|
protected void |
configureLiaison(java.lang.Object stylesheet)
Loads the stylesheet and set xsl:param parameters.
|
org.apache.tools.ant.types.Path |
createClasspath()
Set the optional classpath to the XSL processor
|
JDXSLTProcess.Factory |
createFactory()
Create the factory element to configure a trax liaison.
|
JDXSLTProcess.OutputProperty |
createOutputProperty()
Create an instance of an output property to be configured.
|
JDXSLTProcess.Param |
createParam()
Create an instance of an XSL parameter for configuration by Ant.
|
private void |
ensureDirectoryFor(java.io.File targetFile)
Ensure the directory exists for a given file
|
void |
execute()
Executes the task.
|
JDXSLTProcess.Factory |
getFactory()
Get the factory instance configured for this processor
|
protected org.apache.tools.ant.taskdefs.XSLTLiaison |
getLiaison()
Get the Liason implementation to use in processing.
|
java.util.Enumeration |
getOutputProperties() |
org.apache.tools.ant.types.XMLCatalog |
getXMLCatalog()
Get the XML catalog containing entity definitions
|
void |
init()
Initialize internal instance of XMLCatalog
|
private java.lang.Class |
loadClass(java.lang.String classname)
Load named class either via the system classloader or a given
custom classloader.
|
private void |
process(java.io.File inFile,
java.io.File outFile,
java.lang.Object stylesheet)
Process the input file to the output file with the given stylesheet.
|
private void |
process(java.io.File baseDir,
java.lang.String xmlFile,
java.io.File destDir,
java.lang.Object stylesheet)
Processes the given input XML file and stores the result
in the given resultFile.
|
private void |
resolveProcessor(java.lang.String proc)
Load processor here instead of in setProcessor - this will be
called from within execute, so we have access to the latest
classpath.
|
void |
setBasedir(java.io.File dir)
Set the base directory;
optional, default is the project's basedir.
|
void |
setClasspath(org.apache.tools.ant.types.Path classpath)
Set the optional classpath to the XSL processor
|
void |
setClasspathRef(org.apache.tools.ant.types.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 |
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 |
setStyleurl(java.lang.String styleurl)
Set the stylesheet url.
|
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
private java.io.File destDir
private java.io.File baseDir
private java.lang.String xslFile
private java.lang.String targetExtension
private java.util.Vector params
private java.io.File inFile
private java.io.File outFile
private java.lang.String processor
private org.apache.tools.ant.types.Path classpath
private java.lang.String styleurl
private org.apache.tools.ant.taskdefs.XSLTLiaison liaison
private boolean stylesheetLoaded
private boolean force
private org.apache.tools.ant.util.FileUtils fileUtils
private java.util.Vector outputProperties
private org.apache.tools.ant.types.XMLCatalog xmlCatalog
private static final java.lang.String TRAX_LIAISON_CLASS
private static final java.lang.String XSLP_LIAISON_CLASS
private static final java.lang.String XALAN_LIAISON_CLASS
private boolean performDirectoryScan
private JDXSLTProcess.Factory factory
private boolean reuseLoadedStylesheet
private org.apache.tools.ant.AntClassLoader loader
We keep this here in order to reset the context classloader in execute. We can't use liaison.getClass().getClassLoader() since the actual liaison class may have been loaded by a loader higher up (system classloader, for example).
private org.apache.tools.ant.types.Mapper mapperElement
public JDXSLTProcess()
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.
public void addMapper(org.apache.tools.ant.types.Mapper mapper)
org.apache.tools.ant.BuildException
- if more than one mapper is definedpublic void execute() throws org.apache.tools.ant.BuildException
execute
in class org.apache.tools.ant.Task
org.apache.tools.ant.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(org.apache.tools.ant.types.Path classpath)
classpath
- the classpath to use when loading the XSL processorpublic org.apache.tools.ant.types.Path createClasspath()
public void setClasspathRef(org.apache.tools.ant.types.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 setStyleurl(java.lang.String styleurl)
public void addConfiguredXMLCatalog(org.apache.tools.ant.types.XMLCatalog xmlCatalog)
xmlCatalog
- the XMLCatalog instance to use to look up DTDsprivate void resolveProcessor(java.lang.String proc) throws java.lang.Exception
proc
- the name of the processor to load.java.lang.Exception
- if the processor cannot be loaded.private java.lang.Class loadClass(java.lang.String classname) throws java.lang.Exception
classname
- the name of the class to load.java.lang.Exception
- if the class could not be loaded.public void setOut(java.io.File outFile)
outFile
- the output File instance.public void setIn(java.io.File inFile)
inFile
- the input fileprivate void process(java.io.File baseDir, java.lang.String xmlFile, java.io.File destDir, java.lang.Object stylesheet) throws org.apache.tools.ant.BuildException
baseDir
- the base directory for resolving files.xmlFile
- the input filedestDir
- the destination directorystylesheet
- the stylesheet to use.org.apache.tools.ant.BuildException
- if the processing fails.private void process(java.io.File inFile, java.io.File outFile, java.lang.Object stylesheet) throws org.apache.tools.ant.BuildException
inFile
- the input file to process.outFile
- the destination file.stylesheet
- the stylesheet to use.org.apache.tools.ant.BuildException
- if the processing fails.private void ensureDirectoryFor(java.io.File targetFile) throws org.apache.tools.ant.BuildException
targetFile
- the file for which the directories are required.org.apache.tools.ant.BuildException
- if the directories cannot be created.public JDXSLTProcess.Factory getFactory()
public org.apache.tools.ant.types.XMLCatalog getXMLCatalog()
public java.util.Enumeration getOutputProperties()
protected org.apache.tools.ant.taskdefs.XSLTLiaison getLiaison()
public JDXSLTProcess.Param createParam()
public JDXSLTProcess.OutputProperty createOutputProperty()
public void init() throws org.apache.tools.ant.BuildException
init
in class org.apache.tools.ant.Task
org.apache.tools.ant.BuildException
protected void configureLiaison(java.lang.Object stylesheet) throws org.apache.tools.ant.BuildException
stylesheet
- the file form which to load the stylesheet.org.apache.tools.ant.BuildException
- if the stylesheet cannot be loaded.public JDXSLTProcess.Factory createFactory() throws org.apache.tools.ant.BuildException
org.apache.tools.ant.BuildException
- if the element is created more than one time.