2018-12-21 11:20:43 +01:00
|
|
|
<!DOCTYPE html>
|
2006-09-11 04:19:00 +00:00
|
|
|
<!--
|
|
|
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
contributor license agreements. See the NOTICE file distributed with
|
|
|
|
this work for additional information regarding copyright ownership.
|
|
|
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
(the "License"); you may not use this file except in compliance with
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
2019-05-25 13:41:47 +02:00
|
|
|
https://www.apache.org/licenses/LICENSE-2.0
|
2006-09-11 04:19:00 +00:00
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
-->
|
2018-12-21 11:20:43 +01:00
|
|
|
<html lang="en">
|
2001-02-13 12:32:01 +00:00
|
|
|
|
|
|
|
<head>
|
2005-04-29 18:58:16 +00:00
|
|
|
<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
|
2005-03-28 23:22:12 +00:00
|
|
|
<title>XSLT Task</title>
|
2001-02-13 12:32:01 +00:00
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
2018-01-22 23:52:21 +01:00
|
|
|
<h2 id="style">XSLT</h2>
|
2018-02-28 07:58:59 +01:00
|
|
|
<p><em>The name <code>style</code> is a <u>deprecated</u> name for the same task.</em></p>
|
2001-02-13 12:32:01 +00:00
|
|
|
<h3>Description</h3>
|
|
|
|
<p>Process a set of documents via XSLT.</p>
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>This is useful for building views of XML based documentation, or for generating code.</p>
|
|
|
|
<p>It is possible to refine the set of files that are being processed. This can be done with
|
|
|
|
the <var>includes</var>, <var>includesfile</var>, <var>excludes</var>, <var>excludesfile</var>
|
|
|
|
and <var>defaultexcludes</var> attributes. With the <var>includes</var> or <var>includesfile</var>
|
|
|
|
attribute you specify the files you want to have included by using patterns. The <var>exclude</var>
|
|
|
|
or <var>excludesfile</var> attribute is used to specify the files you want to have excluded. This is
|
|
|
|
also done with patterns. And finally with the <var>defaultexcludes</var> 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
|
2001-02-13 12:32:01 +00:00
|
|
|
inclusion/exclusion of files works, and how to write patterns.</p>
|
2010-05-26 20:33:51 +00:00
|
|
|
<p>This task forms an implicit <a href="../Types/fileset.html">FileSet</a> and supports all
|
2018-03-10 20:17:33 +01:00
|
|
|
attributes of <code><fileset></code> (<var>dir</var> becomes <var>basedir</var>) as well
|
2018-02-28 07:58:59 +01:00
|
|
|
as the nested <code><include></code>, <code><exclude></code>
|
|
|
|
and <code><patternset></code> elements.</p>
|
|
|
|
|
|
|
|
<p><strong>Note</strong>: Unlike other similar tasks, this task treats directories that have been
|
|
|
|
matched by the include/exclude patterns of the implicit fileset in a special way. It will apply the
|
|
|
|
stylesheets to all files contain in them as well. Since the default <var>includes</var> pattern
|
|
|
|
is <code>**</code> this means it will apply the stylesheet to all files. If you specify
|
|
|
|
an <var>excludes</var> pattern, it may still work on the files matched by those patterns because the
|
|
|
|
parent directory has been matched. If this behavior is not what you want, set
|
2018-03-10 20:17:33 +01:00
|
|
|
the <var>scanincludedirectories</var> attribute to <q>false</q>.</p>
|
2018-02-28 07:58:59 +01:00
|
|
|
|
|
|
|
<p><em>Since Ant 1.7</em>, this task supports
|
2018-03-05 17:35:30 +01:00
|
|
|
nested <a href="../Types/resources.html#collection">resource collections</a> in addition to (or
|
2018-02-28 07:58:59 +01:00
|
|
|
instead of, depending on the <var>useImplicitFileset</var> attribute) the implicit fileset formed by
|
|
|
|
this task.</p>
|
|
|
|
|
|
|
|
<p>This task supports the use of a nested <code><param></code> element which is used to pass
|
|
|
|
values to an <code><xsl:param></code> declaration.</p>
|
|
|
|
<p>This task supports the use of a nested <a href="../Types/xmlcatalog.html">xmlcatalog</a> element
|
|
|
|
which is used to perform Entity and URI resolution.</p>
|
|
|
|
|
|
|
|
<p><strong>Note on XSLT extension functions</strong>: when using the default TrAX implementation of
|
|
|
|
the Java class library and a <code>SecurityManager</code> is active—e.g. when running from
|
|
|
|
within an IDE—XSLT extension functions cannot be used as "secure processing" is active in Java
|
|
|
|
7 and above. Ant contains a special "hack" that allows XSLT extensions to be used in Java 7 and 8,
|
|
|
|
but this hack fails for Java 9. If you want to use extensions like the redirect extension that are
|
|
|
|
provided by the Java class library itself, you can allow them by enabling the
|
|
|
|
feature <var>http://www.oracle.com/xml/jaxp/properties/enableExtensionFunctions</var> in Java 9 and
|
|
|
|
above. If you need to use an extension function not provided by Java itself you can set the
|
|
|
|
attribute <var>jdk.xml.transform.extensionClassLoader</var> to a classloader (reference to an Ant
|
|
|
|
path-like structure).</p>
|
2016-09-21 19:13:57 +02:00
|
|
|
|
2001-02-13 12:32:01 +00:00
|
|
|
<h3>Parameters</h3>
|
2018-02-28 07:58:59 +01:00
|
|
|
<table class="attr">
|
2001-02-13 12:32:01 +00:00
|
|
|
<tr>
|
2018-05-15 10:29:27 +02:00
|
|
|
<th scope="col">Attribute</th>
|
|
|
|
<th scope="col">Description</th>
|
|
|
|
<th scope="col">Required</th>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>basedir</td>
|
|
|
|
<td>where to find the source XML file.</td>
|
|
|
|
<td>No; defaults to the project's <var>basedir</var></td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>destdir</td>
|
|
|
|
<td>directory in which to store the results.</td>
|
|
|
|
<td>Yes, unless <var>in</var> and <var>out</var> have been specified.</td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>extension</td>
|
|
|
|
<td>desired file extension to be used for the targets.</td>
|
|
|
|
<td>No; default is <q>.html</q>, ignored if a nested <code><mapper></code> or
|
|
|
|
both <var>in</var> and <var>out</var> have been specified</td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>style</td>
|
|
|
|
<td>name of the stylesheet to use—given either relative to the
|
|
|
|
project's <var>basedir</var> or as an absolute path.<br/> Alternatively, a nested element
|
|
|
|
which Ant can interpret as a resource can be used to indicate where to find the
|
|
|
|
stylesheet.<br/><em><u>Deprecated</u> variation</em>:<br/> If the stylesheet cannot be found,
|
|
|
|
and if you have specified the attribute <var>basedir</var> for the task, Ant will assume that
|
|
|
|
the <var>style</var> attribute is relative to the <var>basedir</var> of the task.</td>
|
|
|
|
<td>No, if the location of the stylesheet is specified using a nested <code><style></code>
|
|
|
|
element</td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
2001-06-22 07:45:16 +00:00
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>classpath</td>
|
|
|
|
<td>the classpath to use when looking up the XSLT processor.</td>
|
|
|
|
<td>No</td>
|
2001-06-22 07:45:16 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>classpathref</td>
|
|
|
|
<td>the classpath to use, given as <a href="../using.html#references">reference</a> to a path
|
|
|
|
defined elsewhere.</td>
|
|
|
|
<td>No</td>
|
2001-06-22 07:45:16 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>force</td>
|
|
|
|
<td>Recreate target files, even if they are newer than their corresponding source files or the
|
|
|
|
stylesheet.</td>
|
|
|
|
<td>No; default is <q>false</q></td>
|
2001-06-22 07:45:16 +00:00
|
|
|
</tr>
|
2001-02-13 12:32:01 +00:00
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>processor</td>
|
|
|
|
<td>name of the XSLT processor to use. Permissible value is:
|
|
|
|
<ul>
|
|
|
|
<li><q>trax</q> for a TraX compliant processor (ie JAXP interface implementation such as
|
2018-03-01 06:44:53 +01:00
|
|
|
Xalan 2 or Saxon)</li>
|
2018-02-28 07:58:59 +01:00
|
|
|
</ul>
|
|
|
|
Support for Xalan 1 has been removed <em>since Ant 1.7</em>.
|
|
|
|
</td>
|
|
|
|
<td>No; defaults to <q>trax</q></td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>includes</td>
|
|
|
|
<td>comma- or space-separated list of patterns of files that must be included.</td>
|
|
|
|
<td>No; defaults to all (<q>**</q>)</td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>includesfile</td>
|
|
|
|
<td>name of a file. Each line of this file is taken to be an include pattern</td>
|
|
|
|
<td>No</td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>excludes</td>
|
|
|
|
<td>comma- or space-separated list of patterns of files that must be excluded.</td>
|
|
|
|
<td>No; defaults to default excludes or none if <var>defaultexcludes</var> is <q>no</q></td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>excludesfile</td>
|
|
|
|
<td>name of a file. Each line of this file is taken to be an exclude pattern</td>
|
|
|
|
<td>No</td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>defaultexcludes</td>
|
|
|
|
<td>indicates whether default excludes should be used or not (<q>yes|no</q>).</td>
|
|
|
|
<td>No; defaults to <q>yes</q></td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>in</td>
|
|
|
|
<td>specifies a single XML document to be styled. Should be used
|
|
|
|
with the <var>out</var> attribute.</td>
|
|
|
|
<td>No</td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>out</td>
|
|
|
|
<td>specifies the output name for the styled result from the <var>in</var> attribute.</td>
|
|
|
|
<td>No</td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
2002-02-26 16:39:37 +00:00
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>scanincludeddirectories</td>
|
|
|
|
<td>If any directories are matched by the <var>includes</var>/<var>excludes</var> patterns, try
|
|
|
|
to transform all files in these directories.
|
|
|
|
<td>No; default is <q>true</q></td>
|
2002-02-26 16:39:37 +00:00
|
|
|
</tr>
|
2002-11-15 11:59:31 +00:00
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>reloadstylesheet</td>
|
|
|
|
<td>Control whether the stylesheet transformer is created anew for every transform operation. If
|
|
|
|
you set this to <q>true</q>, performance may suffer, but you may work around a bug in certain
|
|
|
|
Xalan versions. <em>Since Ant 1.5.2</em>.</td>
|
|
|
|
<td>No; default is <q>false</q></td>
|
2002-11-15 11:59:31 +00:00
|
|
|
</tr>
|
2005-09-28 18:46:40 +00:00
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>useImplicitFileset</td>
|
|
|
|
<td>Whether the implicit fileset formed by this task shall be used. If you set this
|
|
|
|
to <q>false</q> you must use nested resource collections—or the <var>in</var> attribute,
|
|
|
|
in which case this attribute has no impact anyway. <em>Since Ant 1.7</em>.</td>
|
|
|
|
<td>No; default is <q>true</q></td>
|
2005-09-28 18:46:40 +00:00
|
|
|
</tr>
|
2006-07-17 12:03:07 +00:00
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>filenameparameter</td>
|
|
|
|
<td>Specifies an XSL parameter for accessing the name of the current processed file. If not set,
|
|
|
|
the file name is not passed to the transformation. <em>Since Ant 1.7</em>.</td>
|
|
|
|
<td>No</td>
|
2006-07-17 12:03:07 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>filedirparameter</td>
|
|
|
|
<td>Specifies a XSL parameter for accessing the directory of the current processed file. For
|
|
|
|
files in the current directory, a value of <q>.</q> will be passed to the transformation. If
|
|
|
|
not set, the directory is not passed to the transformation. <em>Since Ant 1.7</em>.</td>
|
|
|
|
<td>No</td>
|
2006-07-17 12:03:07 +00:00
|
|
|
</tr>
|
2008-11-26 09:34:16 +00:00
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>suppressWarnings</td>
|
|
|
|
<td>Whether processor warnings shall be suppressed. This option requires support by the
|
|
|
|
processor, it is supported by the TrAX processor bundled with Ant. <em>Since Ant
|
|
|
|
1.8.0</em>.</td>
|
|
|
|
<td>No; default is <q>false</q></td>
|
2008-11-26 09:34:16 +00:00
|
|
|
</tr>
|
2008-11-26 14:08:20 +00:00
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>failOnError</td>
|
|
|
|
<td>Whether the build should fail if any error occurs. Note that transformation errors can
|
2018-03-02 08:23:45 +01:00
|
|
|
still be suppressed by setting <var>failOnTransformationError</var> to <q>false</q> even if
|
|
|
|
this attribute is <q>true</q>. <em>Since Ant 1.8.0</em>.</td>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>No; default is <q>true</q></td>
|
2008-11-26 14:08:20 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>failOnTransformationError</td>
|
|
|
|
<td>Whether the build should fail if an error occurs while transforming the document. Note that
|
|
|
|
this attribute has no effect if <var>failOnError</var> is <q>false</q>. <em>Since Ant
|
|
|
|
1.8.0</em>.</td>
|
|
|
|
<td>No; default is <q>true</q></td>
|
2008-11-26 14:08:20 +00:00
|
|
|
</tr>
|
2008-11-26 14:24:01 +00:00
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>failOnNoResources</td>
|
|
|
|
<td>Whether the build should fail if the nested resource collection is empty. Note that this
|
|
|
|
attribute has no effect of <var>failOnError</var> is <q>false</q>. <em>Since Ant
|
|
|
|
1.8.0</em>.</td>
|
|
|
|
<td>No; default is <q>true</q></td>
|
2008-11-26 14:24:01 +00:00
|
|
|
</tr>
|
2001-02-13 12:32:01 +00:00
|
|
|
</table>
|
|
|
|
<h3>Parameters specified as nested elements</h3>
|
2005-09-28 18:46:40 +00:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<h4>any <a href="../Types/resources.html#collection">resource collection</a></h4>
|
2005-09-28 18:46:40 +00:00
|
|
|
|
2018-03-04 15:17:41 +01:00
|
|
|
<p><em>Since Ant 1.7</em></p>
|
2005-09-28 18:46:40 +00:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>Use resource collections to specify resources that the stylesheet should be applied to. Use a
|
|
|
|
nested mapper and the task's <q>destdir</q> attribute to specify the output files.</p>
|
2005-09-28 18:46:40 +00:00
|
|
|
|
2018-01-22 23:52:21 +01:00
|
|
|
<h4 id="classpath">classpath</h4>
|
2001-06-22 07:45:16 +00:00
|
|
|
<p>The classpath to load the processor from can be specified via a
|
2018-02-28 07:58:59 +01:00
|
|
|
nested <code><classpath></code>, as well—that is,
|
|
|
|
a <a href="../using.html#path">path-like structure</a>.</p>
|
2002-07-09 21:06:15 +00:00
|
|
|
|
2002-06-01 12:26:43 +00:00
|
|
|
<h4>xmlcatalog</h4>
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>The <a href="../Types/xmlcatalog.html">xmlcatalog</a> element is used to perform Entity and URI
|
|
|
|
resolution.</p>
|
2002-07-09 21:06:15 +00:00
|
|
|
|
2001-02-13 12:32:01 +00:00
|
|
|
<h4>param</h4>
|
2018-02-28 07:58:59 +01:00
|
|
|
<p><code>Param</code> is used to pass a parameter to the XSL stylesheet.</p>
|
2018-01-24 21:40:28 +01:00
|
|
|
|
|
|
|
<h5>Parameters</h5>
|
2018-02-28 07:58:59 +01:00
|
|
|
<table class="attr">
|
|
|
|
<tr>
|
2018-05-15 10:29:27 +02:00
|
|
|
<th scope="col">Attribute</th>
|
|
|
|
<th scope="col">Description</th>
|
|
|
|
<th scope="col">Required</th>
|
2018-02-28 07:58:59 +01:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>name</td>
|
|
|
|
<td>Name of the XSL parameter</td>
|
|
|
|
<td>Yes</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>expression</td>
|
|
|
|
<td>The value to be placed into the param or an XPath expression (depending
|
|
|
|
on <var>type</var>).</td>
|
|
|
|
<td>Yes</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>type</td>
|
|
|
|
<td>Data type of the parameter. Possible values are:
|
|
|
|
<ul>
|
|
|
|
<li><q>STRING</q></li>
|
|
|
|
<li><q>BOOLEAN</q></li>
|
|
|
|
<li><q>INT</q></li>
|
|
|
|
<li><q>LONG</q></li>
|
|
|
|
<li><q>DOUBLE</q></li>
|
|
|
|
<li><q>XPATH_STRING</q></li>
|
|
|
|
<li><q>XPATH_BOOLEAN</q></li>
|
|
|
|
<li><q>XPATH_NUMBER</q></li>
|
|
|
|
<li><q>XPATH_NODE</q></li>
|
|
|
|
<li><q>XPATH_NODESET</q></li>
|
|
|
|
</ul><em>since Ant 1.9.3</em>
|
2013-12-05 18:49:03 +00:00
|
|
|
</td>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>No; default is <q>STRING</q></td>
|
2013-12-05 18:49:03 +00:00
|
|
|
</tr>
|
2003-08-05 16:01:10 +00:00
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>if</td>
|
|
|
|
<td>The param will only be passed <a href="../properties.html#if+unless">if this property is
|
2018-03-01 06:44:53 +01:00
|
|
|
set</a>.</td>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>No</td>
|
2003-08-05 16:01:10 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>unless</td>
|
|
|
|
<td>The param will not be passed <a href="../properties.html#if+unless">if this property is
|
2018-03-01 06:44:53 +01:00
|
|
|
set</a>.</td>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>No</td>
|
2003-08-05 16:01:10 +00:00
|
|
|
</tr>
|
2001-02-13 12:32:01 +00:00
|
|
|
</table>
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>The <q>XPATH_*</q> types says that the <var>expression</var> is not just a primitive-type value
|
|
|
|
but an XPath expression. This expression will be evaluated on an empty XML document and the result
|
|
|
|
will be passed to the XSLT transformer as a parameter of given type. In these expressions the
|
|
|
|
declared Ant properties can be used as XPath variables e.g. <code>$someProperty</code>. So you can
|
|
|
|
compute something using standard XPath functions and operators.</p>
|
|
|
|
<p>If you write <code>${someProperty}</code> instead of <code>$someProperty</code>, the value will
|
|
|
|
be simply substituted by Ant before evaluating the XPath expression (this substitution works also
|
|
|
|
for primitive types).</p>
|
|
|
|
|
|
|
|
<h4>outputproperty (<var>trax</var> processors only)</h4>
|
|
|
|
<p>Used to specify how you wish the result tree to be output as specified in
|
2018-03-08 07:43:53 +01:00
|
|
|
the <a href="https://www.w3.org/TR/xslt#output" target="_top">XSLT specifications</a>.
|
2018-01-24 21:40:28 +01:00
|
|
|
|
|
|
|
<h5>Parameters</h5>
|
2018-02-28 07:58:59 +01:00
|
|
|
<table class="attr">
|
2002-07-09 21:06:15 +00:00
|
|
|
<tr>
|
2018-05-15 10:29:27 +02:00
|
|
|
<th scope="col">Attribute</th>
|
|
|
|
<th scope="col">Description</th>
|
|
|
|
<th scope="col">Required</th>
|
2002-07-09 21:06:15 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>name</td>
|
|
|
|
<td>Name of the property</td>
|
|
|
|
<td>Yes</td>
|
2002-07-09 21:06:15 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>value</td>
|
|
|
|
<td>Value of the property</td>
|
|
|
|
<td>Yes</td>
|
2002-07-09 21:06:15 +00:00
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<h4 id="factory">factory (<var>trax</var> processors only)</h4>
|
2018-03-04 15:17:41 +01:00
|
|
|
<p><em>Since Ant 1.9.8</em></p>
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>Used to specify factory settings.</p>
|
2018-01-24 21:40:28 +01:00
|
|
|
|
|
|
|
<h5>Parameters</h5>
|
2018-02-28 07:58:59 +01:00
|
|
|
<table class="attr">
|
2002-07-12 21:25:29 +00:00
|
|
|
<tr>
|
2018-05-15 10:29:27 +02:00
|
|
|
<th scope="col">Attribute</th>
|
|
|
|
<th scope="col">Description</th>
|
|
|
|
<th scope="col">Required</th>
|
2002-07-12 21:25:29 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>name</td>
|
|
|
|
<td>fully qualified classname of the transformer factory to use. For
|
|
|
|
example <code>org.apache.xalan.processor.TransformerFactoryImpl</code>
|
|
|
|
or <code>org.apache.xalan.xsltc.trax.TransformerFactoryImpl</code>
|
|
|
|
or <code>net.sf.saxon.TransformerFactoryImpl</code>...</td>
|
|
|
|
<td>No; defaults to the JAXP lookup mechanism</td>
|
2002-07-12 21:25:29 +00:00
|
|
|
</tr>
|
|
|
|
</table>
|
2018-01-24 21:40:28 +01:00
|
|
|
<h5>Parameters specified as nested elements</h5>
|
|
|
|
<h6>attribute</h6>
|
2018-02-28 07:58:59 +01:00
|
|
|
<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:</p>
|
2002-07-11 22:52:55 +00:00
|
|
|
<ul>
|
2018-02-28 07:58:59 +01:00
|
|
|
<li><var>http://xml.apache.org/xalan/features/optimize</var> (boolean)</li>
|
|
|
|
<li><var>http://xml.apache.org/xalan/features/incremental</var> (boolean)</li>
|
|
|
|
<li>...</li>
|
2002-07-11 22:52:55 +00:00
|
|
|
</ul>
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>And in Saxon 7.x:</p>
|
2002-07-11 22:52:55 +00:00
|
|
|
<ul>
|
2018-02-28 07:58:59 +01:00
|
|
|
<li><var>http://saxon.sf.net/feature/allow-external-functions</var> (boolean)</li>
|
|
|
|
<li><var>http://saxon.sf.net/feature/timing</var> (boolean)</li>
|
|
|
|
<li><var>http://saxon.sf.net/feature/traceListener</var> (string)</li>
|
|
|
|
<li><var>http://saxon.sf.net/feature/treeModel</var> (integer)</li>
|
|
|
|
<li><var>http://saxon.sf.net/feature/linenumbering</var> (integer)</li>
|
|
|
|
<li>...</li>
|
2002-07-11 22:52:55 +00:00
|
|
|
</ul>
|
2006-07-17 12:03:07 +00:00
|
|
|
<blockquote>
|
2018-01-24 21:40:28 +01:00
|
|
|
<h6>Parameters</h6>
|
2018-02-28 07:58:59 +01:00
|
|
|
<table class="attr">
|
2002-07-11 22:52:55 +00:00
|
|
|
<tr>
|
2018-05-15 10:29:27 +02:00
|
|
|
<th scope="col">Attribute</th>
|
|
|
|
<th scope="col">Description</th>
|
|
|
|
<th scope="col">Required</th>
|
2002-07-11 22:52:55 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>name</td>
|
|
|
|
<td>Name of the attribute</td>
|
|
|
|
<td>Yes</td>
|
2002-07-11 22:52:55 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>value</td>
|
|
|
|
<td>Value of the attribute.</td>
|
|
|
|
<td rowspan="3">Exactly one of these</td>
|
2016-09-04 16:24:18 +02:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>valueref</td>
|
|
|
|
<td class="left">Value of the attribute is the value of the project reference with the given
|
|
|
|
id. <em>since Ant 1.9.8</em></td>
|
2016-09-04 16:24:18 +02:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>classloaderforpath</td>
|
|
|
|
<td class="left">Value of the attribute is a classloader that uses the classpath specified by a
|
2018-03-10 20:17:33 +01:00
|
|
|
path that is the project reference with the given <var>id</var>. <em>since Ant 1.9.8</em></td>
|
2002-07-11 22:52:55 +00:00
|
|
|
</tr>
|
|
|
|
</table>
|
2018-01-24 21:40:28 +01:00
|
|
|
</blockquote>
|
2016-09-04 16:24:18 +02:00
|
|
|
|
2018-01-24 21:40:28 +01:00
|
|
|
<h5>Examples</h5>
|
2016-09-04 16:24:18 +02:00
|
|
|
|
|
|
|
<pre>
|
2018-02-28 07:58:59 +01:00
|
|
|
<path id="extension-path">
|
|
|
|
...
|
|
|
|
</path>
|
2016-09-04 16:24:18 +02:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<xslt ...>
|
|
|
|
<factory>
|
|
|
|
<attribute name="jdk.xml.transform.extensionClassLoader"
|
|
|
|
classloaderforpath="extension-path"/>
|
|
|
|
</factory>
|
|
|
|
</xslt ...></pre>
|
2016-09-04 16:24:18 +02:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>Sets the classloader to use when loading extension functions to a classloader using
|
|
|
|
the <code>path</code> with the id <code>extension-path</code>.</p>
|
2018-01-24 21:40:28 +01:00
|
|
|
|
|
|
|
<h6>feature</h6>
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>Used to specify settings of the processor factory. The feature names are mostly processor
|
|
|
|
specific so you must be aware of the implementation to figure them out. Read the documentation of
|
|
|
|
your processor. The only feature all implementations are required to support
|
|
|
|
is <var>http://javax.xml.XMLConstants/feature/secure-processing</var>.
|
2016-09-04 13:32:01 +02:00
|
|
|
<blockquote>
|
2018-01-24 21:40:28 +01:00
|
|
|
<h6>Parameters</h6>
|
2018-02-28 07:58:59 +01:00
|
|
|
<table class="attr">
|
2016-09-04 13:32:01 +02:00
|
|
|
<tr>
|
2018-05-15 10:29:27 +02:00
|
|
|
<th scope="col">Attribute</th>
|
|
|
|
<th scope="col">Description</th>
|
|
|
|
<th scope="col">Required</th>
|
2016-09-04 13:32:01 +02:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>name</td>
|
|
|
|
<td>Name of the feature</td>
|
|
|
|
<td>Yes</td>
|
2016-09-04 13:32:01 +02:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>value</td>
|
|
|
|
<td>Value of the feature. A boolean value (i.e. permitted values
|
|
|
|
are <q>true</q>, <q>false</q>, <q>yes</q>, <q>no</q>, <q>on</q>, <q>off</q>).</td>
|
|
|
|
<td>No; defaults to <q>false</q></td>
|
2016-09-04 13:32:01 +02:00
|
|
|
</tr>
|
|
|
|
</table>
|
2002-07-12 21:25:29 +00:00
|
|
|
</blockquote>
|
2018-01-24 21:40:28 +01:00
|
|
|
|
2004-04-16 08:36:01 +00:00
|
|
|
<h4>mapper</h4>
|
|
|
|
|
2018-03-04 15:17:41 +01:00
|
|
|
<p><em>Since Ant 1.6.2</em></p>
|
2004-04-16 08:36:01 +00:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>You can define filename transformations by using a
|
|
|
|
nested <a href="../Types/mapper.html">mapper</a> element. The default mapper used
|
|
|
|
by <code><xslt></code> removes the file extension from the source file and adds the extension
|
|
|
|
specified via the extension attribute.</p>
|
2004-04-16 08:36:01 +00:00
|
|
|
|
2006-09-19 22:22:17 +00:00
|
|
|
<h4>style</h4>
|
2006-05-25 12:39:19 +00:00
|
|
|
|
|
|
|
<p><em>Since Ant 1.7</em></p>
|
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>The nested <code>style</code> element can be used to specify your stylesheet in terms of
|
|
|
|
Ant's <a href="../Types/resources.html">resource</a> types. With this element, the stylesheet
|
|
|
|
should be specified as a nested resource or single-element collection. Alternatively, use
|
|
|
|
the <var>refid</var> to specify the resource or collection as a reference.</p>
|
2006-05-25 12:39:19 +00:00
|
|
|
|
2008-11-26 14:45:10 +00:00
|
|
|
<h4>sysproperty</h4>
|
2018-03-04 15:17:41 +01:00
|
|
|
|
|
|
|
<p><em>Since Ant 1.8.0</em>.</p>
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>Use nested <code><sysproperty></code> elements to specify system properties required by the
|
|
|
|
factory or transformation. These properties will be made available to JVM during the execution of
|
|
|
|
the class. The attributes for this element are the same as for <a href="exec.html#env">environment
|
|
|
|
variables</a>.</p>
|
2008-11-26 14:45:10 +00:00
|
|
|
|
|
|
|
<h4>syspropertyset</h4>
|
|
|
|
|
2018-03-04 15:17:41 +01:00
|
|
|
<p><em>Since Ant 1.8.0</em>.</p>
|
|
|
|
|
2008-11-26 14:45:10 +00:00
|
|
|
<p>You can specify a set of properties to be used as system properties
|
2010-05-26 20:33:51 +00:00
|
|
|
with <a href="../Types/propertyset.html">syspropertyset</a>s.</p>
|
2008-11-26 14:45:10 +00:00
|
|
|
|
2001-02-13 12:32:01 +00:00
|
|
|
<h3>Examples</h3>
|
2018-02-28 07:58:59 +01:00
|
|
|
<pre>
|
2008-02-11 15:08:49 +00:00
|
|
|
<xslt basedir="doc" destdir="build/doc"
|
2001-11-25 16:32:51 +00:00
|
|
|
extension=".html" style="style/apache.xsl"/></pre>
|
2018-02-28 07:58:59 +01:00
|
|
|
<h4>Using an xmlcatalog</h4>
|
|
|
|
<pre>
|
2005-03-10 13:01:55 +00:00
|
|
|
<xslt basedir="doc" destdir="build/doc"
|
2002-04-13 11:18:28 +00:00
|
|
|
extension=".html" style="style/apache.xsl">
|
2002-06-01 12:26:43 +00:00
|
|
|
<xmlcatalog refid="mycatalog"/>
|
|
|
|
</xslt>
|
|
|
|
|
|
|
|
<xslt basedir="doc" destdir="build/doc"
|
2018-02-28 07:58:59 +01:00
|
|
|
extension=".html" style="style/apache.xsl">
|
2002-06-01 12:26:43 +00:00
|
|
|
<xmlcatalog>
|
2002-07-09 21:06:15 +00:00
|
|
|
<dtd
|
2002-06-01 12:26:43 +00:00
|
|
|
publicId="-//ArielPartners//DTD XML Article V1.0//EN"
|
|
|
|
location="com/arielpartners/knowledgebase/dtd/article.dtd"/>
|
|
|
|
</xmlcatalog>
|
2018-02-28 07:58:59 +01:00
|
|
|
</xslt></pre>
|
|
|
|
<h4>Using XSL parameters</h4>
|
|
|
|
<p>Simple String parameter:</p>
|
2005-03-10 13:01:55 +00:00
|
|
|
<pre>
|
|
|
|
<xslt basedir="doc" destdir="build/doc"
|
2002-06-01 12:26:43 +00:00
|
|
|
extension=".html" style="style/apache.xsl">
|
2002-04-13 11:18:28 +00:00
|
|
|
<param name="date" expression="07-01-2000"/>
|
|
|
|
</xslt></pre>
|
2001-11-25 16:32:51 +00:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>Then if you declare a global parameter <q>date</q> with the top-level element <code><xsl:param
|
|
|
|
name="date"/></code>, the variable <code>$date</code> will subsequently have the value
|
|
|
|
07-01-2000.</p>
|
2018-01-22 23:52:21 +01:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>Various data types and XPath expressions:</p>
|
2018-01-22 23:52:21 +01:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<pre>
|
|
|
|
<property name="antProperty1" value="ANT_PROPERTY_1"/>
|
2013-12-05 18:49:03 +00:00
|
|
|
<property name="antProperty2" value="ANT_PROPERTY_2"/>
|
|
|
|
<property name="antProperty3" value="3"/>
|
|
|
|
<property name="antProperty4" value="substring-before"/>
|
|
|
|
|
|
|
|
<!--
|
|
|
|
${this} is substituted by Ant itself
|
|
|
|
and $this is evaluated by XPath as a variable
|
|
|
|
-->
|
|
|
|
|
|
|
|
<xslt in="in.xml" out="out.xml" style="template.xsl">
|
2018-01-22 23:52:21 +01:00
|
|
|
|
2013-12-05 18:49:03 +00:00
|
|
|
<!-- Simple String parameter: -->
|
|
|
|
<param name="p0" expression="some nice string" type="STRING"/>
|
2018-01-22 23:52:21 +01:00
|
|
|
|
2013-12-05 18:49:03 +00:00
|
|
|
<!-- A value substituted by Ant -->
|
|
|
|
<param name="p1" expression="some string with ${antProperty1} constructed by Ant" type="STRING"/>
|
2018-01-22 23:52:21 +01:00
|
|
|
|
2013-12-05 18:49:03 +00:00
|
|
|
<!-- XPath resulting in: and this is done in XPath: ANT_PROPERTY_2 -->
|
|
|
|
<param name="p2" expression="concat('and this is done in XPath: ', $antProperty2)" type="XPATH_STRING"/>
|
2018-01-22 23:52:21 +01:00
|
|
|
|
2013-12-05 18:49:03 +00:00
|
|
|
<!-- Some XPath math, result: 42 -->
|
|
|
|
<param name="p3" expression="64 * 64 div 128 + 10" type="XPATH_NUMBER"/>
|
2018-01-22 23:52:21 +01:00
|
|
|
|
2013-12-05 18:49:03 +00:00
|
|
|
<!-- Some numeric parameter: -->
|
|
|
|
<param name="p4" expression="123.45" type="DOUBLE"/>
|
2018-01-22 23:52:21 +01:00
|
|
|
|
2013-12-05 18:49:03 +00:00
|
|
|
<!-- XPath expression, result: true boolean -->
|
|
|
|
<param name="p5" expression="$antProperty1 = 'ANT_PROPERTY_1'" type="XPATH_BOOLEAN"/>
|
2018-01-22 23:52:21 +01:00
|
|
|
|
2013-12-05 18:49:03 +00:00
|
|
|
<!-- First one is an XPath variable, second one is a text substituted by Ant, result: true boolean -->
|
|
|
|
<param name="p6" expression="$antProperty2 = '${antProperty2}'" type="XPATH_BOOLEAN"/>
|
2018-01-22 23:52:21 +01:00
|
|
|
|
2013-12-05 18:49:03 +00:00
|
|
|
<!-- Some XPath math with a variable, result: 64 -->
|
|
|
|
<param name="p7" expression="$antProperty3 * 4 * 5 + 4" type="XPATH_NUMBER"/>
|
2018-01-22 23:52:21 +01:00
|
|
|
|
|
|
|
<!--
|
2013-12-05 18:49:03 +00:00
|
|
|
XPath expression with substituted function name and a variable:
|
|
|
|
substring-before($antProperty2, '_')
|
|
|
|
result: ANT
|
|
|
|
-->
|
|
|
|
<param name="p8" expression="${antProperty4}($antProperty2, '_')" type="XPATH_STRING"/>
|
2018-01-22 23:52:21 +01:00
|
|
|
|
2013-12-05 18:49:03 +00:00
|
|
|
<!-- Without type attribute: -->
|
|
|
|
<param name="p9" expression="default type is String"/>
|
|
|
|
</xslt></pre>
|
2002-07-09 21:06:15 +00:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<h4>Using output properties</h4>
|
2005-03-10 13:01:55 +00:00
|
|
|
<pre>
|
|
|
|
<xslt in="doc.xml" out="build/doc/output.xml"
|
2002-07-09 21:06:15 +00:00
|
|
|
style="style/apache.xsl">
|
2005-04-07 19:40:17 +00:00
|
|
|
<outputproperty name="method" value="xml"/>
|
2002-07-09 21:06:15 +00:00
|
|
|
<outputproperty name="standalone" value="yes"/>
|
|
|
|
<outputproperty name="encoding" value="iso8859_1"/>
|
|
|
|
<outputproperty name="indent" value="yes"/>
|
2018-02-28 07:58:59 +01:00
|
|
|
</xslt></pre>
|
2002-07-09 21:06:15 +00:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<h4>Using factory settings</h4>
|
2005-03-10 13:01:55 +00:00
|
|
|
<pre>
|
|
|
|
<xslt in="doc.xml" out="build/doc/output.xml"
|
2002-07-12 21:25:29 +00:00
|
|
|
style="style/apache.xsl">
|
2003-08-05 16:01:10 +00:00
|
|
|
<factory name="org.apache.xalan.processor.TransformerFactoryImpl">
|
2002-07-12 21:25:29 +00:00
|
|
|
<attribute name="http://xml.apache.org/xalan/features/optimize" value="true"/>
|
|
|
|
</factory>
|
|
|
|
</xslt></pre>
|
2004-04-16 08:36:01 +00:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<h4>Using a mapper</h4>
|
2005-03-10 13:01:55 +00:00
|
|
|
<pre>
|
|
|
|
<xslt basedir="in" destdir="out"
|
2004-04-16 08:36:01 +00:00
|
|
|
style="style/apache.xsl">
|
|
|
|
<mapper type="glob" from="*.xml.en" to="*.html.en"/>
|
|
|
|
</xslt></pre>
|
2006-05-25 12:39:19 +00:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<h4>Using a nested resource to define the stylesheet</h4>
|
|
|
|
<pre>
|
2006-05-25 12:39:19 +00:00
|
|
|
<xslt in="data.xml" out="${out.dir}/out.xml">
|
2006-09-19 22:22:17 +00:00
|
|
|
<style>
|
|
|
|
<url url="${printParams.xsl.url}"/>
|
|
|
|
</style>
|
2006-05-25 12:39:19 +00:00
|
|
|
<param name="set" expression="value"/>
|
|
|
|
</xslt></pre>
|
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<h4>Print the current processed file name</h4>
|
2006-07-17 12:03:07 +00:00
|
|
|
<pre>
|
|
|
|
<project>
|
|
|
|
<xslt style="printFilename.xsl" destdir="out" basedir="in" extension=".txt"
|
|
|
|
filenameparameter="filename"
|
2018-01-24 21:40:28 +01:00
|
|
|
filedirparameter="filedir"/>
|
2006-07-17 12:03:07 +00:00
|
|
|
</project>
|
|
|
|
|
|
|
|
<xsl:stylesheet
|
2018-02-28 07:58:59 +01:00
|
|
|
version="1.0"
|
|
|
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
2006-07-17 12:03:07 +00:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<xsl:param name="filename"></xsl:param>
|
|
|
|
<xsl:param name="filedir">.</xsl:param>
|
2006-07-17 12:03:07 +00:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<xsl:template match="/">
|
|
|
|
Current file is <xsl:value-of select="$filename"/> in directory <xsl:value-of select="$filedir"/>.
|
|
|
|
</xsl:template>
|
2006-07-17 12:03:07 +00:00
|
|
|
|
|
|
|
</xsl:stylesheet>
|
2006-07-18 08:28:25 +00:00
|
|
|
</pre>
|
2006-07-17 12:03:07 +00:00
|
|
|
|
2008-11-26 14:45:10 +00:00
|
|
|
<h4>Use an XInclude-aware version of Xerces while transforming</h4>
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
<xslt ...>
|
|
|
|
<sysproperty key="org.apache.xerces.xni.parser.XMLParserConfiguration"
|
2018-01-24 21:40:28 +01:00
|
|
|
value="org.apache.xerces.parsers.XIncludeParserConfiguration"/>
|
2008-11-26 14:45:10 +00:00
|
|
|
<xslt>
|
|
|
|
</pre>
|
2006-09-11 04:33:25 +00:00
|
|
|
|
2001-02-13 12:32:01 +00:00
|
|
|
</body>
|
2006-08-25 03:46:29 +00:00
|
|
|
</html>
|