|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.beandoc.output.XslTransformer
public class XslTransformer
Base implementation of the Transformer
interface that uses
XSLT (via TRaX) in order to generate output files. If no XSL stylesheet
resources are specified when the object is constructed (or via setters before
being used) then default XSL stylesheets will be used that are stored in the
same package as this class.
This class is therefore quite flexible as a Transformer implementation in
allowing the user to specify different XSL stylesheets to have complete
control over how the output is generated. Subclasses are only responsible for
providing a file name for each output file that needs to be generated by the
Transformer. The only requirement for subclasses is that they provide an
output file name for each relevant input file via the abstract
getOutputForDocument(java.lang.String)
and a stylesheet URI through the
setTemplateName(java.lang.String)
method.
Field Summary | |
---|---|
protected org.springframework.beandoc.output.FilenameStrategy |
filenameStrategy
|
protected org.apache.commons.logging.Log |
logger
|
protected Map |
staticParameters
|
Constructor Summary | |
---|---|
XslTransformer()
default constructor |
|
XslTransformer(String templateName)
loads and compiles the stylesheets using specified values. |
Method Summary | |
---|---|
protected void |
doXslTransform(org.jdom.Document doc,
File outputDir)
perform the actual tree transformation to the output directory for the given Document |
protected String |
getOutputForDocument(String inputFileName)
Return the name of the output file (relative to the configured output directory) that this transformer will use to generate output to. |
protected Map |
getParameters(org.jdom.Document doc)
Subclasses may optionally generate and return a Map of stylesheet parameters that will be included in the transform. |
Map |
getStaticParameters()
|
String |
getTemplateName()
The String value representing the resource pointing to an XSL stylesheet used in generating documentation output. |
protected void |
handleTransform(org.jdom.Document[] contextDocuments,
File outputDirectory)
Creates an output file in the specified location for each supplied document re-using the same compiled stylesheet for each. |
protected void |
initTransform(org.jdom.Document[] contextDocuments,
File outputDirectory)
Perform any initialization or one-off tasks prior to the actual transformation of the context documents with the configured stylesheet. |
protected void |
postTransform()
Perform any finalization or one-off tasks after the actual transformation of the context documents with the configured stylesheet. |
void |
setFilenameStrategy(org.springframework.beandoc.output.FilenameStrategy filenameStrategy)
set the output filename strategy to use. |
void |
setLocale(Locale locale)
Override the system default locale and specify which locale output should be generated for. |
void |
setStaticParameters(Map staticParameters)
Provide a Map of XSL parameter values for this class that can be used to make up all or part of the Map of actual parameters used in the stylesheet. |
void |
setTemplateName(String templateName)
loads and compile the stylesheet used in generating document output. |
void |
transform(org.jdom.Document[] contextDocuments,
File outputDir)
Implements the Transformer API and sanity checks some
configuration aspects before beginning the transformation workflow. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final org.apache.commons.logging.Log logger
protected org.springframework.beandoc.output.FilenameStrategy filenameStrategy
protected Map staticParameters
Constructor Detail |
---|
public XslTransformer()
public XslTransformer(String templateName)
Resource
s
and can contain any value that the underlying resource loading classes
can understand. See the Spring JavaDocs for more information on resource
handling.
templateName
- the XSL resource used to generate outputMethod Detail |
---|
public final void transform(org.jdom.Document[] contextDocuments, File outputDir)
Transformer
API and sanity checks some
configuration aspects before beginning the transformation workflow. The
initTransform
method is first called, returning on any
thrown Exception. After successful initialisation and XSL processing, the
postTransform()
method is called to perform cleanup or
additional tasks.
transform
in interface Transformer
contextDocuments
- an array of JDOM Document objectsoutputDir
- the directory to place any output ininitTransform(org.jdom.Document[], java.io.File)
protected void initTransform(org.jdom.Document[] contextDocuments, File outputDirectory) throws Exception
contextDocuments
- the array of DOM trees about to be transformedoutputDirectory
- the file handle for the output directory
Exception
protected void handleTransform(org.jdom.Document[] contextDocuments, File outputDirectory)
doXslTransform
method aas a library function.
contextDocuments
- the array of DOM trees about to be transformedoutputDirectory
- the file handle for the output directoryprotected void doXslTransform(org.jdom.Document doc, File outputDir)
doc
- the document to transformoutputDir
- the file handle of the output locationprotected Map getParameters(org.jdom.Document doc)
doc
- the Document about to be transformed
protected String getOutputForDocument(String inputFileName)
inputFileName
- the original file name (not including path) of the
context file
protected void postTransform()
public String getTemplateName()
public void setTemplateName(String templateName) throws InvalidTransformerException
templateName
- a standard Spring Resource
that can
contain any value that the underlying resource loading classes can
understand. See the Spring JavaDocs for more information on resource
handling.
InvalidTransformerException
public Map getStaticParameters()
public void setStaticParameters(Map staticParameters)
staticParameters
- a Map of parameters that will probably be used as
part of a Map returned from the getParameters(Document) methodpublic void setFilenameStrategy(org.springframework.beandoc.output.FilenameStrategy filenameStrategy)
filenameStrategy
- public void setLocale(Locale locale)
locale
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |