Process a set of documents via XSLT.
This is useful for building views of XML based documentation, or for generating code.
Note: This task depends on external libraries not included in the Ant distribution. See Library Dependencies for more information.
It is possible to refine the set of files that are being processed. This can be done with the includes, includesfile, excludes, excludesfile and defaultexcludes attributes. With the includes or includesfile attribute you specify the files you want to have included by using patterns. The exclude or excludesfile attribute is used to specify the files you want to have excluded. This is also done with patterns. And finally with the defaultexcludes attribute, you can specify whether you want to use default exclusions or not. See the section on directory based tasks, on how the inclusion/exclusion of files works, and how to write patterns.
This task forms an implicit FileSet and supports all
attributes of <fileset>
(dir
becomes basedir
)
as well as the nested <include>
, <exclude>
and <patternset>
elements.
Style supports the use of a <param> element which is used to pass values to an <xsl:param> declaration.
If you want to use Xalan-J 1 or XSL:P, you also need Ant's optional.jar
Attribute | Description | Required |
basedir | where to find the source XML file, default is the project's basedir. | No |
destdir | directory in which to store the results. | Yes, unless in and out have been specified. |
extension | desired file extension to be used for the targets. If not specified, the default is ".html". | No |
style | name of the stylesheet to use - given either relative to the project's basedir or as an absolute path DEPRECATED - can be specified as a path relative to the basedir attribute of this task as well. | Yes |
classpath | the classpath to use when looking up the XSLT processor. | No |
classpathref | the classpath to use, given as reference to a path defined elsewhere. | No |
force | Recreate target files, even if they are newer than their corresponding source files or the stylesheet. | No |
processor | name of the XSLT processor to use. Permissible values are "trax" for a TraX compliant processor, "xslp" for the XSL:P processor, "xalan" for the Apache XML Xalan (version 1) processor, "adaptx" for the Exolab Adaptx processor or the name of an arbitrary XSLTLiaison class. Defaults to trax, followed by xalan, then adaptx and then xslp (in that order). The first one found in your class path is the one that is used. DEPRECATED - XSL:P and Adaptx are deprecated and will be removed in the next version. Use trax or xalan instead.. | No |
includes | comma separated list of patterns of files that must be included. All files are included when omitted. | No |
includesfile | the name of a file. Each line of this file is taken to be an include pattern | No |
excludes | comma separated list of patterns of files that must be excluded. No files (except default excludes) are excluded when omitted. | No |
excludesfile | the name of a file. Each line of this file is taken to be an exclude pattern | No |
defaultexcludes | indicates whether default excludes should be used or not ("yes"/"no"). Default excludes are used when omitted. | No |
in | specifies a single XML document to be styled. Should be used with the out attribute. | No |
out | specifies the output name for the styled result from the in attribute. | No |
outputtype | specifies the output method to be used. Only "xml" is guaranteed to be supported by all translators. Xalan2 supports "xml", "html", and "text" | No |
The classpath to load the processor from can be specified via a
nested <classpath>
, as well - that is, a
path-like structure.
Param is used to pass a parameter to the XSL stylesheet.
Attribute | Description | Required |
name | Name of the XSL parameter | Yes |
expression | XSL expression to be placed into the param. To pass a text value into the style sheet it needs to be escaped using single quotes. | Yes |
<style basedir="doc" destdir="build/doc" extension=".html" style="style/apache.xsl"/>Using XSL parameters
<style basedir="doc" destdir="build/doc" extension=".html" style="style/apache.xsl"> <param name="date" expression="07-01-2000"/> </style>Then if you declare a global parameter "date" with the top-level element <xsl:param name="date"/>, the variable
$date
will subsequently have the value 07-01-2000.
Copyright © 2000,2001 Apache Software Foundation. All rights Reserved.