mirror of
https://github.com/apache/ant.git
synced 2025-05-18 22:14:47 +00:00
come up with a better name). This provides a workaround for a bug in Xalan-J - the version that gets distributed with JDK 1.4.1. PR: 13859 based on a patch submitted by: Jens Elkner <elkner at linofee.org> git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273545 13f79535-47bb-0310-9956-ffa450edef68
333 lines
13 KiB
HTML
333 lines
13 KiB
HTML
<html>
|
|
|
|
<head>
|
|
<meta http-equiv="Content-Language" content="en-us">
|
|
<title>Xslt/Style Task</title>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h2><a name="style">Xslt/Style</a></h2>
|
|
<h3>Description</h3>
|
|
<p>Process a set of documents via XSLT.</p>
|
|
<p>This is useful for building views of XML based documentation,
|
|
or for generating code.</p>
|
|
<p><b>Note:</b> This task depends on external libraries not included in the Ant distribution.
|
|
See <a href="../install.html#librarydependencies">Library Dependencies</a> for more information.</p>
|
|
<p>It is possible to refine the set of files that are being processed. This can be
|
|
done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>, <i>excludesfile</i> and <i>defaultexcludes</i>
|
|
attributes. With the <i>includes</i> or <i>includesfile</i> attribute you specify the files you want to
|
|
have included by using patterns. The <i>exclude</i> or <i>excludesfile</i> attribute is used to specify
|
|
the files you want to have excluded. This is also done with patterns. And
|
|
finally with the <i>defaultexcludes</i> attribute, you can specify whether you
|
|
want to use default exclusions or not. See the section on <a
|
|
href="../dirtasks.html#directorybasedtasks">directory based tasks</a>, on how the
|
|
inclusion/exclusion of files works, and how to write patterns.</p>
|
|
<p>This task forms an implicit <a href="../CoreTypes/fileset.html">FileSet</a> and supports all
|
|
attributes of <code><fileset></code> (<code>dir</code> becomes <code>basedir</code>)
|
|
as well as the nested <code><include></code>, <code><exclude></code>
|
|
and <code><patternset></code> elements.</p>
|
|
<p>This task supports the use of a nested <param> element which is used to pass values
|
|
to an <xsl:param> declaration.</p>
|
|
<p>This task supports the use of a nested <a href="../CoreTypes/xmlcatalog.html">xmlcatalog</a>
|
|
element which is used to perform Entity and URI resolution</p>
|
|
<p><i><style> and <xslt> refer to the same Ant task and can be used interchangeably.</i></p>
|
|
<p>If you want to use Xalan-J 1 or XSL:P, you also need Ant's optional.jar</p>
|
|
<h3>Parameters</h3>
|
|
<table border="1" cellpadding="2" cellspacing="0">
|
|
<tr>
|
|
<td valign="top"><b>Attribute</b></td>
|
|
<td valign="top"><b>Description</b></td>
|
|
<td align="center" valign="top"><b>Required</b></td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">basedir</td>
|
|
<td valign="top">where to find the source XML file, default is the
|
|
project's basedir.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">destdir</td>
|
|
<td valign="top">directory in which to store the results.</td>
|
|
<td align="center" valign="top">Yes, unless in and out have been
|
|
specified.</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">extension</td>
|
|
<td valign="top">desired file extension to be used for the targets. If not
|
|
specified, the default is ".html".</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">style</td>
|
|
<td valign="top">name of the stylesheet to use - given either relative
|
|
to the project's basedir or as an absolute path
|
|
<em><strong>DEPRECATED</strong> - can be specified as a path relative
|
|
to the basedir attribute of this task as well</em>.
|
|
</td>
|
|
<td align="center" valign="top">Yes</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">classpath</td>
|
|
<td valign="top">the classpath to use when looking up the XSLT
|
|
processor.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">classpathref</td>
|
|
<td valign="top">the classpath to use, given as <a
|
|
href="../using.html#references">reference</a> to a path defined elsewhere.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">force</td>
|
|
<td valign="top">Recreate target files, even if they are newer
|
|
than their corresponding source files or the stylesheet.</td>
|
|
<td valign="top" align="center">No; default is false</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">processor</td>
|
|
|
|
<td valign="top">name of the XSLT processor to use. Permissible values are
|
|
"trax" for a TraX compliant processor (ie JAXP interface
|
|
implementation such as Xalan 2 or Saxon),
|
|
"xslp" for the XSL:P processor, "xalan" for
|
|
the Apache XML Xalan (version 1) processor the name of an
|
|
arbitrary XSLTLiaison class. Defaults to trax, followed by xalan
|
|
and then xslp (in that order). The first one found in your class
|
|
path is the one that is used.
|
|
|
|
<em><strong>DEPRECATED</strong> - XSL:P and xalan are deprecated and no
|
|
more supported.</em>.
|
|
</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">includes</td>
|
|
<td valign="top">comma- or space-separated list of patterns of files that must be included.
|
|
All files are included when omitted.</td>
|
|
<td valign="top" align="center">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">includesfile</td>
|
|
<td valign="top">the name of a file. Each line of this file is taken to be
|
|
an include pattern</td>
|
|
<td valign="top" align="center">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">excludes</td>
|
|
<td valign="top">comma- or space-separated list of patterns of files that must be excluded.
|
|
No files (except default excludes) are excluded when omitted.</td>
|
|
<td valign="top" align="center">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">excludesfile</td>
|
|
<td valign="top">the name of a file. Each line of this file is taken to be
|
|
an exclude pattern</td>
|
|
<td valign="top" align="center">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">defaultexcludes</td>
|
|
<td valign="top">indicates whether default excludes should be used or not
|
|
("yes"/"no"). Default excludes are used when omitted.</td>
|
|
<td valign="top" align="center">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">in</td>
|
|
<td valign="top">specifies a single XML document to be styled. Should be used
|
|
with the out attribute.</td>
|
|
<td valign="top" align="center">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">out</td>
|
|
<td valign="top">specifies the output name for the styled result from the
|
|
in attribute.</td>
|
|
<td valign="top" align="center">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">scanincludeddirectories</td>
|
|
<td valign="top">If any directories are matched by the
|
|
includes/excludes patterns, try to transform all files in these
|
|
directories. Default is <code>true</code></td>
|
|
<td valign="top" align="center">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">reuseloadedstylesheet</td>
|
|
<td valign="top">Reuse the same transformer when transforming
|
|
multiple files. If you set this to false, performance will
|
|
suffer, but you may work around a bug in certain Xalan-J versions.
|
|
Default is <code>true</code>. <em>Since Ant 1.6</em>.</td>
|
|
<td valign="top" align="center">No</td>
|
|
</tr>
|
|
</table>
|
|
<h3>Parameters specified as nested elements</h3>
|
|
<h4>classpath</h4>
|
|
<p>The classpath to load the processor from can be specified via a
|
|
nested <code><classpath></code>, as well - that is, a
|
|
<a href="../using.html#path">path</a>-like structure.</p>
|
|
|
|
<h4>xmlcatalog</h4>
|
|
<p>The <a href="../CoreTypes/xmlcatalog.html">xmlcatalog</a>
|
|
element is used to perform Entity and URI resolution.</p>
|
|
|
|
<h4>param</h4>
|
|
<p>Param is used to pass a parameter to the XSL stylesheet.</p>
|
|
<h4>Parameters</h4>
|
|
<table width="60%" border="1" cellpadding="2" cellspacing="0">
|
|
<tr>
|
|
<td valign="top"><b>Attribute</b></td>
|
|
<td valign="top"><b>Description</b></td>
|
|
<td align="center" valign="top"><b>Required</b></td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">name</td>
|
|
<td valign="top">Name of the XSL parameter</td>
|
|
<td align="center" valign="top">Yes</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">expression</td>
|
|
<td valign="top">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.</td>
|
|
<td align="center" valign="top">Yes</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<h4>outputproperty ('trax' processors only)</h4>
|
|
<p>Used to specify how you wish the result tree to be output
|
|
as specified in the <a href="http://www.w3.org/TR/xslt#output">
|
|
XSLT specifications</a>.
|
|
<h4>Parameters</h4>
|
|
<table width="60%" border="1" cellpadding="2" cellspacing="0">
|
|
<tr>
|
|
<td valign="top"><b>Attribute</b></td>
|
|
<td valign="top"><b>Description</b></td>
|
|
<td align="center" valign="top"><b>Required</b></td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">name</td>
|
|
<td valign="top">Name of the property</td>
|
|
<td align="center" valign="top">Yes</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">value</td>
|
|
<td valign="top">value of the property.</td>
|
|
<td align="center" valign="top">Yes</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<h4>factory ('trax' processors only)</h4>
|
|
Used to specify factory settings.
|
|
<h4>Parameters</h4>
|
|
<table width="60%" border="1" cellpadding="2" cellspacing="0">
|
|
<tr>
|
|
<td valign="top"><b>Attribute</b></td>
|
|
<td valign="top"><b>Description</b></td>
|
|
<td align="center" valign="top"><b>Required</b></td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">name</td>
|
|
<td valign="top">fully qualified classname of the
|
|
transformer factory to use. For example
|
|
<tt>org.apache.xalan.processor.TransformerFactoryImpl</tt>
|
|
or <tt>org.apache.xalan.xsltc.trax.TransformerFactoryImpl</tt>
|
|
or <tt>net.sf.saxon.TransformerFactoryImpl</tt>...
|
|
</td>
|
|
<td align="center" valign="top">No. Defaults to the JAXP lookup mechanism.</td>
|
|
</tr>
|
|
</table>
|
|
<blockquote>
|
|
<h4>attribute </h4>
|
|
<p>Used to specify settings of the processor factory.
|
|
The attribute names and values are entirely processor specific
|
|
so you must be aware of the implementation to figure them out.
|
|
Read the documentation of your processor.
|
|
For example, in Xalan 2.x:
|
|
<ul>
|
|
<li>http://xml.apache.org/xalan/features/optimize (boolean)</li>
|
|
<li>http://xml.apache.org/xalan/features/incremental (boolean)</li>
|
|
<li>...</li>
|
|
</ul>
|
|
And in Saxon 7.x:
|
|
<ul>
|
|
<li>http://saxon.sf.net/feature/allow-external-functions (boolean)</li>
|
|
<li>http://saxon.sf.net/feature/timing (boolean)</li>
|
|
<li>http://saxon.sf.net/feature/traceListener (string)</li>
|
|
<li>http://saxon.sf.net/feature/treeModel (integer)</li>
|
|
<li>http://saxon.sf.net/feature/linenumbering (integer)</li>
|
|
<li>...</li>
|
|
</ul>
|
|
<h4>Parameters</h4>
|
|
<table width="60%" border="1" cellpadding="2" cellspacing="0">
|
|
<tr>
|
|
<td valign="top"><b>Attribute</b></td>
|
|
<td valign="top"><b>Description</b></td>
|
|
<td align="center" valign="top"><b>Required</b></td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">name</td>
|
|
<td valign="top">Name of the attribute</td>
|
|
<td align="center" valign="top">Yes</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">value</td>
|
|
<td valign="top">value of the attribute.</td>
|
|
<td align="center" valign="top">Yes</td>
|
|
</tr>
|
|
</table>
|
|
</blockquote>
|
|
|
|
<h3>Examples</h3>
|
|
<blockquote>
|
|
<pre>
|
|
<style basedir="doc" destdir="build/doc"
|
|
extension=".html" style="style/apache.xsl"/></pre>
|
|
<h4>Using an xmlcatalog</h4>
|
|
<pre><xslt basedir="doc" destdir="build/doc"
|
|
extension=".html" style="style/apache.xsl">
|
|
<xmlcatalog refid="mycatalog"/>
|
|
</xslt>
|
|
|
|
<xslt basedir="doc" destdir="build/doc"
|
|
extension=".html" style="style/apache.xsl">
|
|
<xmlcatalog>
|
|
<dtd
|
|
publicId="-//ArielPartners//DTD XML Article V1.0//EN"
|
|
location="com/arielpartners/knowledgebase/dtd/article.dtd"/>
|
|
</xmlcatalog>
|
|
</xslt></pre>
|
|
<h4>Using XSL parameters</h4>
|
|
<pre><xslt basedir="doc" destdir="build/doc"
|
|
extension=".html" style="style/apache.xsl">
|
|
<param name="date" expression="07-01-2000"/>
|
|
</xslt></pre>
|
|
|
|
<p>Then if you declare a global parameter "date" with the top-level
|
|
element <xsl:param name="date"/>, the variable
|
|
<code>$date</code> will subsequently have the value 07-01-2000.
|
|
</p>
|
|
|
|
<h4>Using output properties</h4>
|
|
<pre><xslt in="doc.xml" out="build/doc/output.xml"
|
|
style="style/apache.xsl">
|
|
<outputproperty name="method" value="xml";/>
|
|
<outputproperty name="standalone" value="yes"/>
|
|
<outputproperty name="encoding" value="iso8859_1"/>
|
|
<outputproperty name="indent" value="yes"/>
|
|
</xslt></pre>
|
|
|
|
<h4>Using factory settings</h4>
|
|
<pre><xslt in="doc.xml" out="build/doc/output.xml"
|
|
style="style/apache.xsl">
|
|
<factory name="org.apache.xalan.processor.TransformerFactoryImpl">
|
|
<attribute name="http://xml.apache.org/xalan/features/optimize" value="true"/>
|
|
</factory>
|
|
</xslt></pre>
|
|
</blockquote>
|
|
<hr>
|
|
<p align="center">Copyright © 2000-2002 Apache Software Foundation. All rights
|
|
Reserved.</p>
|
|
|
|
</body>
|
|
</html>
|
|
|