source: release-kits/lirk3/bin/ant-installer/web/manual1.6.2/manual/CoreTasks/style.html@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 14.0 KB
Line 
1<html>
2
3<head>
4<meta http-equiv="Content-Language" content="en-us">
5<title>Xslt/Style Task</title>
6<link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
7</head>
8
9<body>
10
11<h2><a name="style">Xslt/Style</a></h2>
12<h3>Description</h3>
13<p>Process a set of documents via XSLT.</p>
14<p>This is useful for building views of XML based documentation,
15or for generating code.</p>
16<p><b>Note:</b> If you are using JDK 1.4 or higher, this task does not require external libraries
17not supplied in the Ant distribution. Otherwise,
18see <a href="../install.html#librarydependencies">Library Dependencies</a> for more information.</p>
19<p>It is possible to refine the set of files that are being processed. This can be
20done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>, <i>excludesfile</i> and <i>defaultexcludes</i>
21attributes. With the <i>includes</i> or <i>includesfile</i> attribute you specify the files you want to
22have included by using patterns. The <i>exclude</i> or <i>excludesfile</i> attribute is used to specify
23the files you want to have excluded. This is also done with patterns. And
24finally with the <i>defaultexcludes</i> attribute, you can specify whether you
25want to use default exclusions or not. See the section on <a
26href="../dirtasks.html#directorybasedtasks">directory based tasks</a>, on how the
27inclusion/exclusion of files works, and how to write patterns.</p>
28<p>This task forms an implicit <a href="../CoreTypes/fileset.html">FileSet</a> and supports all
29 attributes of <code>&lt;fileset&gt;</code> (<code>dir</code> becomes <code>basedir</code>)
30 as well as the nested <code>&lt;include&gt;</code>, <code>&lt;exclude&gt;</code>
31 and <code>&lt;patternset&gt;</code> elements.</p>
32<p>This task supports the use of a nested &lt;param&gt; element which is used to pass values
33 to an &lt;xsl:param&gt; declaration.</p>
34<p>This task supports the use of a nested <a href="../CoreTypes/xmlcatalog.html">xmlcatalog</a>
35element which is used to perform Entity and URI resolution</p>
36<p><i>&lt;style&gt; and &lt;xslt&gt; refer to the same Ant task and can be used interchangeably.</i></p>
37<p>If you want to use Xalan-J 1 or XSL:P, you also need Ant's optional.jar</p>
38<h3>Parameters</h3>
39<table border="1" cellpadding="2" cellspacing="0">
40 <tr>
41 <td valign="top"><b>Attribute</b></td>
42 <td valign="top"><b>Description</b></td>
43 <td align="center" valign="top"><b>Required</b></td>
44 </tr>
45 <tr>
46 <td valign="top">basedir</td>
47 <td valign="top">where to find the source XML file, default is the
48 project's basedir.</td>
49 <td align="center" valign="top">No</td>
50 </tr>
51 <tr>
52 <td valign="top">destdir</td>
53 <td valign="top">directory in which to store the results.</td>
54 <td align="center" valign="top">Yes, unless in and out have been
55 specified.</td>
56 </tr>
57 <tr>
58 <td valign="top">extension</td>
59 <td valign="top">desired file extension to be used for the targets. If not
60 specified, the default is &quot;.html&quot;. Will be ignored if
61 a nested &lt;mapper&gt; has been specified.</td>
62 <td align="center" valign="top">No</td>
63 </tr>
64 <tr>
65 <td valign="top">style</td>
66 <td valign="top">name of the stylesheet to use - given either relative
67 to the project's basedir or as an absolute path
68 <em><strong>DEPRECATED</strong> - can be specified as a path relative
69 to the basedir attribute of this task as well</em>.
70 </td>
71 <td align="center" valign="top">Yes</td>
72 </tr>
73 <tr>
74 <td valign="top">classpath</td>
75 <td valign="top">the classpath to use when looking up the XSLT
76 processor.</td>
77 <td align="center" valign="top">No</td>
78 </tr>
79 <tr>
80 <td valign="top">classpathref</td>
81 <td valign="top">the classpath to use, given as <a
82 href="../using.html#references">reference</a> to a path defined elsewhere.</td>
83 <td align="center" valign="top">No</td>
84 </tr>
85 <tr>
86 <td valign="top">force</td>
87 <td valign="top">Recreate target files, even if they are newer
88 than their corresponding source files or the stylesheet.</td>
89 <td valign="top" align="center">No; default is false</td>
90 </tr>
91 <tr>
92 <td valign="top">processor</td>
93
94 <td valign="top">name of the XSLT processor to use. Permissible values are
95 &quot;trax&quot; for a TraX compliant processor (ie JAXP interface
96 implementation such as Xalan 2 or Saxon),
97 &quot;xslp&quot; for the XSL:P processor, &quot;xalan&quot; for
98 the Apache XML Xalan (version 1) processor the name of an
99 arbitrary XSLTLiaison class. Defaults to trax, followed by xalan
100 and then xslp (in that order). The first one found in your class
101 path is the one that is used.
102
103 <em><strong>DEPRECATED</strong> - XSL:P and xalan are deprecated and no
104 more supported.</em>.
105 </td>
106 <td align="center" valign="top">No</td>
107 </tr>
108 <tr>
109 <td valign="top">includes</td>
110 <td valign="top">comma- or space-separated list of patterns of files that must be included.
111 All files are included when omitted.</td>
112 <td valign="top" align="center">No</td>
113 </tr>
114 <tr>
115 <td valign="top">includesfile</td>
116 <td valign="top">the name of a file. Each line of this file is taken to be
117 an include pattern</td>
118 <td valign="top" align="center">No</td>
119 </tr>
120 <tr>
121 <td valign="top">excludes</td>
122 <td valign="top">comma- or space-separated list of patterns of files that must be excluded.
123 No files (except default excludes) are excluded when omitted.</td>
124 <td valign="top" align="center">No</td>
125 </tr>
126 <tr>
127 <td valign="top">excludesfile</td>
128 <td valign="top">the name of a file. Each line of this file is taken to be
129 an exclude pattern</td>
130 <td valign="top" align="center">No</td>
131 </tr>
132 <tr>
133 <td valign="top">defaultexcludes</td>
134 <td valign="top">indicates whether default excludes should be used or not
135 (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
136 <td valign="top" align="center">No</td>
137 </tr>
138 <tr>
139 <td valign="top">in</td>
140 <td valign="top">specifies a single XML document to be styled. Should be used
141 with the out attribute.</td>
142 <td valign="top" align="center">No</td>
143 </tr>
144 <tr>
145 <td valign="top">out</td>
146 <td valign="top">specifies the output name for the styled result from the
147 in attribute.</td>
148 <td valign="top" align="center">No</td>
149 </tr>
150 <tr>
151 <td valign="top">scanincludeddirectories</td>
152 <td valign="top">If any directories are matched by the
153 includes/excludes patterns, try to transform all files in these
154 directories. Default is <code>true</code></td>
155 <td valign="top" align="center">No</td>
156 </tr>
157 <tr>
158 <td valign="top">reloadstylesheet</td>
159 <td valign="top">Control whether the stylesheet transformer is created
160 anew for every transform opertaion. If you set this to true, performance may
161 suffer, but you may work around a bug in certain Xalan-J versions.
162 Default is <code>false</code>. <em>Since Ant 1.5.2</em>.</td>
163 <td valign="top" align="center">No</td>
164 </tr>
165</table>
166<h3>Parameters specified as nested elements</h3>
167<h4>classpath</h4>
168<p>The classpath to load the processor from can be specified via a
169nested <code>&lt;classpath&gt;</code>, as well - that is, a
170<a href="../using.html#path">path</a>-like structure.</p>
171
172<h4>xmlcatalog</h4>
173<p>The <a href="../CoreTypes/xmlcatalog.html">xmlcatalog</a>
174element is used to perform Entity and URI resolution.</p>
175
176<h4>param</h4>
177<p>Param is used to pass a parameter to the XSL stylesheet.</p>
178<h4>Parameters</h4>
179<table width="60%" border="1" cellpadding="2" cellspacing="0">
180 <tr>
181 <td valign="top"><b>Attribute</b></td>
182 <td valign="top"><b>Description</b></td>
183 <td align="center" valign="top"><b>Required</b></td>
184 </tr>
185 <tr>
186 <td valign="top">name</td>
187 <td valign="top">Name of the XSL parameter</td>
188 <td align="center" valign="top">Yes</td>
189 </tr>
190 <tr>
191 <td valign="top">expression</td>
192 <td valign="top">Text value to be placed into the param.<br/>
193 Was originally intended to be an XSL expression.</td>
194 <td align="center" valign="top">Yes</td>
195 </tr>
196 <tr>
197 <td valign="top">if</td>
198 <td valign="top">The param will only passed if this property is set.</td>
199 <td align="center" valign="top">No</td>
200 </tr>
201 <tr>
202 <td valign="top">unless</td>
203 <td valign="top">The param will only passed unless this property is set.</td>
204 <td align="center" valign="top">No</td>
205 </tr>
206
207</table>
208
209<h4>outputproperty ('trax' processors only)</h4>
210<p>Used to specify how you wish the result tree to be output
211as specified in the <a href="http://www.w3.org/TR/xslt#output">
212XSLT specifications</a>.
213<h4>Parameters</h4>
214<table width="60%" border="1" cellpadding="2" cellspacing="0">
215 <tr>
216 <td valign="top"><b>Attribute</b></td>
217 <td valign="top"><b>Description</b></td>
218 <td align="center" valign="top"><b>Required</b></td>
219 </tr>
220 <tr>
221 <td valign="top">name</td>
222 <td valign="top">Name of the property</td>
223 <td align="center" valign="top">Yes</td>
224 </tr>
225 <tr>
226 <td valign="top">value</td>
227 <td valign="top">value of the property.</td>
228 <td align="center" valign="top">Yes</td>
229 </tr>
230</table>
231
232<h4>factory ('trax' processors only)</h4>
233Used to specify factory settings.
234<h4>Parameters</h4>
235<table width="60%" border="1" cellpadding="2" cellspacing="0">
236 <tr>
237 <td valign="top"><b>Attribute</b></td>
238 <td valign="top"><b>Description</b></td>
239 <td align="center" valign="top"><b>Required</b></td>
240 </tr>
241 <tr>
242 <td valign="top">name</td>
243 <td valign="top">fully qualified classname of the
244 transformer factory to use. For example
245 <tt>org.apache.xalan.processor.TransformerFactoryImpl</tt>
246 or <tt>org.apache.xalan.xsltc.trax.TransformerFactoryImpl</tt>
247 or <tt>net.sf.saxon.TransformerFactoryImpl</tt>...
248 </td>
249 <td align="center" valign="top">No. Defaults to the JAXP lookup mechanism.</td>
250 </tr>
251</table>
252<blockquote>
253<h4>attribute </h4>
254<p>Used to specify settings of the processor factory.
255The attribute names and values are entirely processor specific
256so you must be aware of the implementation to figure them out.
257Read the documentation of your processor.
258For example, in Xalan 2.x:
259<ul>
260<li>http://xml.apache.org/xalan/features/optimize (boolean)</li>
261<li>http://xml.apache.org/xalan/features/incremental (boolean)</li>
262<li>...</li>
263</ul>
264And in Saxon 7.x:
265<ul>
266<li>http://saxon.sf.net/feature/allow-external-functions (boolean)</li>
267<li>http://saxon.sf.net/feature/timing (boolean)</li>
268<li>http://saxon.sf.net/feature/traceListener (string)</li>
269<li>http://saxon.sf.net/feature/treeModel (integer)</li>
270<li>http://saxon.sf.net/feature/linenumbering (integer)</li>
271<li>...</li>
272</ul>
273<h4>Parameters</h4>
274<table width="60%" border="1" cellpadding="2" cellspacing="0">
275 <tr>
276 <td valign="top"><b>Attribute</b></td>
277 <td valign="top"><b>Description</b></td>
278 <td align="center" valign="top"><b>Required</b></td>
279 </tr>
280 <tr>
281 <td valign="top">name</td>
282 <td valign="top">Name of the attribute</td>
283 <td align="center" valign="top">Yes</td>
284 </tr>
285 <tr>
286 <td valign="top">value</td>
287 <td valign="top">value of the attribute.</td>
288 <td align="center" valign="top">Yes</td>
289 </tr>
290</table>
291</blockquote>
292
293<h4>mapper</h4>
294
295<p><em>since Ant 1.6.2</em></p>
296
297<p>You can define filename transformations by using a nested <a
298href="../CoreTypes/mapper.html">mapper</a> element. The default mapper
299used by <code>&lt;xslt&gt;</code> removes the file extension from the
300source file and adds the extension specified via the extension
301attribute.</p>
302
303<h3>Examples</h3>
304<blockquote>
305 <pre>
306&lt;style basedir=&quot;doc&quot; destdir=&quot;build/doc&quot;
307 extension=&quot;.html&quot; style=&quot;style/apache.xsl&quot;/&gt;</pre>
308 <h4>Using an xmlcatalog</h4>
309 <pre>&lt;xslt basedir=&quot;doc&quot; destdir=&quot;build/doc&quot;
310 extension=&quot;.html&quot; style=&quot;style/apache.xsl&quot;&gt;
311 &lt;xmlcatalog refid=&quot;mycatalog&quot;/&gt;
312&lt;/xslt&gt;
313
314&lt;xslt basedir=&quot;doc&quot; destdir=&quot;build/doc&quot;
315 extension=&quot;.html&quot; style=&quot;style/apache.xsl&quot;&gt;
316 &lt;xmlcatalog&gt;
317 &lt;dtd
318 publicId=&quot;-//ArielPartners//DTD XML Article V1.0//EN&quot;
319 location=&quot;com/arielpartners/knowledgebase/dtd/article.dtd&quot;/&gt;
320 &lt;/xmlcatalog&gt;
321&lt;/xslt&gt;</pre>
322 <h4>Using XSL parameters</h4>
323<pre>&lt;xslt basedir=&quot;doc&quot; destdir=&quot;build/doc&quot;
324 extension=&quot;.html&quot; style=&quot;style/apache.xsl&quot;&gt;
325 &lt;param name=&quot;date&quot; expression=&quot;07-01-2000&quot;/&gt;
326&lt;/xslt&gt;</pre>
327
328 <p>Then if you declare a global parameter &quot;date&quot; with the top-level
329 element &lt;xsl:param name=&quot;date&quot;/&gt;, the variable
330 <code>$date</code> will subsequently have the value 07-01-2000.
331 </p>
332
333 <h4>Using output properties</h4>
334<pre>&lt;xslt in=&quot;doc.xml&quot; out=&quot;build/doc/output.xml&quot;
335 style=&quot;style/apache.xsl&quot;&gt;
336 &lt;outputproperty name=&quot;method&quot; value=&quot;xml&quot;;/&gt;
337 &lt;outputproperty name=&quot;standalone&quot; value=&quot;yes&quot;/&gt;
338 &lt;outputproperty name=&quot;encoding&quot; value=&quot;iso8859_1&quot;/&gt;
339 &lt;outputproperty name=&quot;indent&quot; value=&quot;yes&quot;/&gt;
340&lt;/xslt&gt;</pre>
341
342 <h4>Using factory settings</h4>
343<pre>&lt;xslt in=&quot;doc.xml&quot; out=&quot;build/doc/output.xml&quot;
344 style=&quot;style/apache.xsl&quot;&gt;
345 &lt;factory name=&quot;org.apache.xalan.processor.TransformerFactoryImpl&quot;&gt;
346 &lt;attribute name=&quot;http://xml.apache.org/xalan/features/optimize&quot; value=&quot;true&quot;/&gt;
347 &lt;/factory&gt;
348&lt;/xslt&gt;</pre>
349
350 <h4>Using a mapper</h4>
351<pre>&lt;xslt basedir=&quot;in&quot; destdir=&quot;out&quot;
352 style=&quot;style/apache.xsl&quot;&gt;
353 &lt;mapper type=&quot;glob&quot; from=&quot;*.xml.en&quot; to=&quot;*.html.en&quot;/&gt;
354&lt;/xslt&gt;</pre>
355
356 </blockquote>
357<hr>
358<p align="center">Copyright &copy; 2000-2004 The Apache Software Foundation. All rights
359Reserved.</p>
360
361</body>
362</html>
Note: See TracBrowser for help on using the repository browser.