You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

style.html 27 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. <!--
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. -->
  15. <html>
  16. <head>
  17. <meta http-equiv="Content-Language" content="en-us">
  18. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  19. <title>XSLT Task</title>
  20. </head>
  21. <body>
  22. <h2><a name="style">XSLT</a></h2>
  23. <p><em>The name <code>style</code> is a deprecated name for the same task.</em></p>
  24. <h3>Description</h3>
  25. <p>Process a set of documents via XSLT.</p>
  26. <p>This is useful for building views of XML based documentation,
  27. or for generating code.</p>
  28. <p><b>Note:</b> If you are using JDK 1.4 or higher, this task does not require external libraries
  29. not supplied in the Apache Ant distribution. However, often the built in XSL engine is not as up
  30. to date as a fresh download, so an update is still highly recommended
  31. in particular since the built-in XSLT processors of Java 5 (and to a
  32. certain extent Java 6) are known to have serious issues.
  33. See <a href="../install.html#librarydependencies">Library Dependencies</a> for more information.</p>
  34. <p>It is possible to refine the set of files that are being processed. This can be
  35. done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>, <i>excludesfile</i> and <i>defaultexcludes</i>
  36. attributes. With the <i>includes</i> or <i>includesfile</i> attribute you specify the files you want to
  37. have included by using patterns. The <i>exclude</i> or <i>excludesfile</i> attribute is used to specify
  38. the files you want to have excluded. This is also done with patterns. And
  39. finally with the <i>defaultexcludes</i> attribute, you can specify whether you
  40. want to use default exclusions or not. See the section on <a
  41. href="../dirtasks.html#directorybasedtasks">directory based tasks</a>, on how the
  42. inclusion/exclusion of files works, and how to write patterns.</p>
  43. <p>This task forms an implicit <a href="../Types/fileset.html">FileSet</a> and supports all
  44. attributes of <code>&lt;fileset&gt;</code> (<code>dir</code> becomes <code>basedir</code>)
  45. as well as the nested <code>&lt;include&gt;</code>, <code>&lt;exclude&gt;</code>
  46. and <code>&lt;patternset&gt;</code> elements.</p>
  47. <p><b>Note</b>: Unlike other similar tasks, this task treats
  48. directories that have been matched by the include/exclude patterns of
  49. the implicit fileset in a special way. It will apply the stylesheets
  50. to all files contain in them as well. Since the default include
  51. pattern is <code>**</code> this means it will apply the stylesheet to
  52. all files. If you specify an excludes pattern, it may still work on
  53. the files matched by those patterns because the parent directory has
  54. been matched. If this behavior is not what you want, set the
  55. scanincludedirectories attribute to false.</p>
  56. <p>Starting with Ant 1.7 this task supports nested <a
  57. href="../Types/resources.html#collection">resource collection</a>s
  58. in addition to (or instead of, depending on the useImplicitFileset
  59. attribute) the implicit fileset formed by this task.</p>
  60. <p>This task supports the use of a nested <code>&lt;param&gt;</code> element which is used to pass values
  61. to an <code>&lt;xsl:param&gt;</code> declaration.</p>
  62. <p>This task supports the use of a nested <a href="../Types/xmlcatalog.html">xmlcatalog</a>
  63. element which is used to perform Entity and URI resolution.</p>
  64. <p><b>Note on XSLT extension functions</b>: when using the default
  65. TraX implementation of the Java class library and
  66. a <code>SecurityManager</code> is active - e.g. when running from
  67. within an IDE - XSLT extension functions cannot be used as "secure
  68. processing" is active in Java 7 and above. Ant contains a special
  69. "hack" that allows XSLT extensions to be used in Java 7 and 8, but
  70. this hack fails for Java 9. If you want to use extensions like the
  71. redirect extension that are provided by the Java class library
  72. itself, you can allow them by enabling the
  73. feature <code>http://www.oracle.com/xml/jaxp/properties/enableExtensionFunctions</code>
  74. in Java 9 and above. If you need to use an extension function not
  75. provided by Java itself you can set the
  76. attribute <code>jdk.xml.transform.extensionClassLoader</code> to a
  77. classloader (reference to an Ant PATH-like structure).</p>
  78. <h3>Parameters</h3>
  79. <table border="1" cellpadding="2" cellspacing="0">
  80. <tr>
  81. <td valign="top"><b>Attribute</b></td>
  82. <td valign="top"><b>Description</b></td>
  83. <td align="center" valign="top"><b>Required</b></td>
  84. </tr>
  85. <tr>
  86. <td valign="top">basedir</td>
  87. <td valign="top">where to find the source XML file, default is the
  88. project's basedir.</td>
  89. <td align="center" valign="top">No</td>
  90. </tr>
  91. <tr>
  92. <td valign="top">destdir</td>
  93. <td valign="top">directory in which to store the results.</td>
  94. <td align="center" valign="top">Yes, unless in and out have been
  95. specified.</td>
  96. </tr>
  97. <tr>
  98. <td valign="top">extension</td>
  99. <td valign="top">desired file extension to be used for the targets. If not
  100. specified, the default is &quot;.html&quot;. Will be ignored if
  101. a nested <code>&lt;mapper&gt;</code> or both <code>in</code> and
  102. <code>out</code> have been specified.</td>
  103. <td align="center" valign="top">No</td>
  104. </tr>
  105. <tr>
  106. <td valign="top">style</td>
  107. <td valign="top">name of the stylesheet to use - given either relative
  108. to the project's basedir or as an absolute path.<br/>
  109. <br/>
  110. Alternatively, a nested element which ant can interpret as a resource
  111. can be used to indicate where to find the stylesheet<br/>
  112. <em>deprecated variation :</em> <br/>
  113. If the stylesheet cannot be found, and if you have specified the
  114. attribute basedir for the task, ant will assume that the style
  115. attribute is relative to the basedir of the task.
  116. </td>
  117. <td align="center" valign="top">No, if the location of
  118. the stylesheet is specified using a nested &lt;style&gt; element</td>
  119. </tr>
  120. <tr>
  121. <td valign="top">classpath</td>
  122. <td valign="top">the classpath to use when looking up the XSLT
  123. processor.</td>
  124. <td align="center" valign="top">No</td>
  125. </tr>
  126. <tr>
  127. <td valign="top">classpathref</td>
  128. <td valign="top">the classpath to use, given as <a
  129. href="../using.html#references">reference</a> to a path defined elsewhere.</td>
  130. <td align="center" valign="top">No</td>
  131. </tr>
  132. <tr>
  133. <td valign="top">force</td>
  134. <td valign="top">Recreate target files, even if they are newer
  135. than their corresponding source files or the stylesheet.</td>
  136. <td valign="top" align="center">No; default is false</td>
  137. </tr>
  138. <tr>
  139. <td valign="top">processor</td>
  140. <td valign="top">name of the XSLT processor to use.
  141. Permissible value is :<ul>
  142. <li>&quot;trax&quot; for a TraX compliant processor (ie JAXP interface
  143. implementation such as Xalan 2 or Saxon)</li></ul>
  144. Defaults to trax.
  145. <br/>
  146. Support for xalan1 has been removed in ant 1.7.
  147. </td>
  148. <td align="center" valign="top">No</td>
  149. </tr>
  150. <tr>
  151. <td valign="top">includes</td>
  152. <td valign="top">comma- or space-separated list of patterns of files that must be included.
  153. All files are included when omitted.</td>
  154. <td valign="top" align="center">No</td>
  155. </tr>
  156. <tr>
  157. <td valign="top">includesfile</td>
  158. <td valign="top">the name of a file. Each line of this file is taken to be
  159. an include pattern</td>
  160. <td valign="top" align="center">No</td>
  161. </tr>
  162. <tr>
  163. <td valign="top">excludes</td>
  164. <td valign="top">comma- or space-separated list of patterns of files that must be excluded.
  165. No files (except default excludes) are excluded when omitted.</td>
  166. <td valign="top" align="center">No</td>
  167. </tr>
  168. <tr>
  169. <td valign="top">excludesfile</td>
  170. <td valign="top">the name of a file. Each line of this file is taken to be
  171. an exclude pattern</td>
  172. <td valign="top" align="center">No</td>
  173. </tr>
  174. <tr>
  175. <td valign="top">defaultexcludes</td>
  176. <td valign="top">indicates whether default excludes should be used or not
  177. (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
  178. <td valign="top" align="center">No</td>
  179. </tr>
  180. <tr>
  181. <td valign="top">in</td>
  182. <td valign="top">specifies a single XML document to be styled. Should be used
  183. with the out attribute.</td>
  184. <td valign="top" align="center">No</td>
  185. </tr>
  186. <tr>
  187. <td valign="top">out</td>
  188. <td valign="top">specifies the output name for the styled result from the
  189. in attribute.</td>
  190. <td valign="top" align="center">No</td>
  191. </tr>
  192. <tr>
  193. <td valign="top">scanincludeddirectories</td>
  194. <td valign="top">If any directories are matched by the
  195. includes/excludes patterns, try to transform all files in these
  196. directories. Default is <code>true</code></td>
  197. <td valign="top" align="center">No</td>
  198. </tr>
  199. <tr>
  200. <td valign="top">reloadstylesheet</td>
  201. <td valign="top">Control whether the stylesheet transformer is created
  202. anew for every transform operation. If you set this to true, performance may
  203. suffer, but you may work around a bug in certain Xalan-J versions.
  204. Default is <code>false</code>. <em>Since Ant 1.5.2</em>.</td>
  205. <td valign="top" align="center">No</td>
  206. </tr>
  207. <tr>
  208. <td valign="top">useImplicitFileset</td>
  209. <td valign="top">Whether the implicit fileset formed by this task
  210. shall be used. If you set this to false you must use nested
  211. resource collections - or the in attribute, in which case this
  212. attribute has no impact anyway. Default is <code>true</code>.
  213. <em>Since Ant 1.7</em>.</td>
  214. <td valign="top" align="center">No</td>
  215. </tr>
  216. <tr>
  217. <td valign="top">filenameparameter</td>
  218. <td valign="top">Specifies a xsl parameter for accessing the name
  219. of the current processed file. If not set, the file name is not
  220. passed to the transformation.
  221. <em>Since Ant 1.7</em>.</td>
  222. <td valign="top" align="center">No</td>
  223. </tr>
  224. <tr>
  225. <td valign="top">filedirparameter</td>
  226. <td valign="top">Specifies a xsl parameter for accessing the directory
  227. of the current processed file. For files in the current directory a
  228. value of '.' will be passed to the transformation.
  229. If not set, the directory is not passed to the transformation.
  230. <em>Since Ant 1.7</em>.</td>
  231. <td valign="top" align="center">No</td>
  232. </tr>
  233. <tr>
  234. <td valign="top">suppressWarnings</td>
  235. <td valign="top">Whether processor warnings shall be suppressed.
  236. This option requires support by the processor, it is supported by
  237. the trax processor bundled with Ant.
  238. <em>Since Ant 1.8.0</em>.</td>
  239. <td valign="top" align="center">No, default is false.</td>
  240. </tr>
  241. <tr>
  242. <td valign="top">failOnError</td>
  243. <td valign="top">Whether the build should fail if any error
  244. occurs. Note that transformation errors can still be suppressed by
  245. setting failOnTransformationError to false even if this attribute
  246. is true.
  247. <em>Since Ant 1.8.0</em>.</td>
  248. <td valign="top" align="center">No, default is true.</td>
  249. </tr>
  250. <tr>
  251. <td valign="top">failOnTransformationError</td>
  252. <td valign="top">Whether the build should fail if an error occurs
  253. while transforming the document. Note that this attribute has no
  254. effect of <code>failOnError</code> is false.
  255. <em>Since Ant 1.8.0</em>.</td>
  256. <td valign="top" align="center">No, default is true.</td>
  257. </tr>
  258. <tr>
  259. <td valign="top">failOnNoResources</td>
  260. <td valign="top">Whether the build should fail if the nested
  261. resource collection is empty. Note that this attribute has no
  262. effect of <code>failOnError</code> is false.
  263. <em>Since Ant 1.8.0</em>.</td>
  264. <td valign="top" align="center">No, default is true.</td>
  265. </tr>
  266. </table>
  267. <h3>Parameters specified as nested elements</h3>
  268. <h4>any <a href="../Types/resources.html#collection">resource
  269. collection</a></h4>
  270. <p><em>since Ant 1.7</em></p>
  271. <p>Use resource collections to specify resources that the stylesheet
  272. should be applied to. Use a nested mapper and the task's destdir
  273. attribute to specify the output files.</p>
  274. <h4><a name="classpath">classpath</a></h4>
  275. <p>The classpath to load the processor from can be specified via a
  276. nested <code>&lt;classpath&gt;</code>, as well - that is, a
  277. <a href="../using.html#path">path</a>-like structure.</p>
  278. <h4>xmlcatalog</h4>
  279. <p>The <a href="../Types/xmlcatalog.html">xmlcatalog</a>
  280. element is used to perform Entity and URI resolution.</p>
  281. <h4>param</h4>
  282. <p>Param is used to pass a parameter to the XSL stylesheet.</p>
  283. <blockquote>
  284. <h4>Parameters</h4>
  285. <table width="60%" border="1" cellpadding="2" cellspacing="0">
  286. <tr>
  287. <td valign="top"><b>Attribute</b></td>
  288. <td valign="top"><b>Description</b></td>
  289. <td align="center" valign="top"><b>Required</b></td>
  290. </tr>
  291. <tr>
  292. <td valign="top">name</td>
  293. <td valign="top">Name of the XSL parameter</td>
  294. <td align="center" valign="top">Yes</td>
  295. </tr>
  296. <tr>
  297. <td valign="top">expression</td>
  298. <td valign="top">
  299. The value to be placed into the param or an XPath expression
  300. (depending on <code>type</code>).
  301. </td>
  302. <td align="center" valign="top">Yes</td>
  303. </tr>
  304. <tr>
  305. <td valign="top">type</td>
  306. <td valign="top">
  307. Data type of the parameter. Possible values are:
  308. <ul>
  309. <li><code>STRING</code></li>
  310. <li><code>BOOLEAN</code></li>
  311. <li><code>INT</code></li>
  312. <li><code>LONG</code></li>
  313. <li><code>DOUBLE</code></li>
  314. <li><code>XPATH_STRING</code></li>
  315. <li><code>XPATH_BOOLEAN</code></li>
  316. <li><code>XPATH_NUMBER</code></li>
  317. <li><code>XPATH_NODE</code></li>
  318. <li><code>XPATH_NODESET</code></li>
  319. </ul>
  320. <em>since Ant 1.9.3</em>
  321. </td>
  322. <td align="center" valign="top">No; default is <code>STRING</code></td>
  323. </tr>
  324. <tr>
  325. <td valign="top">if</td>
  326. <td valign="top">The param will only be passed <a href="../properties.html#if+unless">if this property is set</a>.</td>
  327. <td align="center" valign="top">No</td>
  328. </tr>
  329. <tr>
  330. <td valign="top">unless</td>
  331. <td valign="top">The param will not be passed <a href="../properties.html#if+unless">if this property is set</a>.</td>
  332. <td align="center" valign="top">No</td>
  333. </tr>
  334. </table>
  335. </blockquote>
  336. <p>
  337. The <code>XPATH_*</code> types says that the <code>expression</code> is not just a primitive-type value but an XPath expression.
  338. 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.
  339. In these expressions the declared Ant properties can be used as XPath variables e.g. <code>$someProperty</code>.
  340. So you can compute something using standard XPath functions and operators.
  341. </p>
  342. <p>
  343. If you write <code>${someProperty}</code> instead of <code>$someProperty</code>,
  344. the value will be simply substituted by Ant before evaluating the XPath expression
  345. (this substitution works also for primitive types).
  346. </p>
  347. <h4>outputproperty ('trax' processors only)</h4>
  348. <p>Used to specify how you wish the result tree to be output
  349. as specified in the <a href="http://www.w3.org/TR/xslt#output">
  350. XSLT specifications</a>.
  351. <blockquote>
  352. <h4>Parameters</h4>
  353. <table width="60%" border="1" cellpadding="2" cellspacing="0">
  354. <tr>
  355. <td valign="top"><b>Attribute</b></td>
  356. <td valign="top"><b>Description</b></td>
  357. <td align="center" valign="top"><b>Required</b></td>
  358. </tr>
  359. <tr>
  360. <td valign="top">name</td>
  361. <td valign="top">Name of the property</td>
  362. <td align="center" valign="top">Yes</td>
  363. </tr>
  364. <tr>
  365. <td valign="top">value</td>
  366. <td valign="top">value of the property.</td>
  367. <td align="center" valign="top">Yes</td>
  368. </tr>
  369. </table>
  370. </blockquote>
  371. <h4><a name="factory">factory ('trax' processors only)</a></h4>
  372. Used to specify factory settings.
  373. <blockquote>
  374. <h4>Parameters</h4>
  375. <table width="60%" border="1" cellpadding="2" cellspacing="0">
  376. <tr>
  377. <td valign="top"><b>Attribute</b></td>
  378. <td valign="top"><b>Description</b></td>
  379. <td align="center" valign="top"><b>Required</b></td>
  380. </tr>
  381. <tr>
  382. <td valign="top">name</td>
  383. <td valign="top">fully qualified classname of the
  384. transformer factory to use. For example
  385. <tt>org.apache.xalan.processor.TransformerFactoryImpl</tt>
  386. or <tt>org.apache.xalan.xsltc.trax.TransformerFactoryImpl</tt>
  387. or <tt>net.sf.saxon.TransformerFactoryImpl</tt>...
  388. </td>
  389. <td align="center" valign="top">No. Defaults to the JAXP lookup mechanism.</td>
  390. </tr>
  391. </table>
  392. <h3>Parameters specified as nested elements</h3>
  393. <h4>attribute</h4>
  394. <p>Used to specify settings of the processor factory.
  395. The attribute names and values are entirely processor specific
  396. so you must be aware of the implementation to figure them out.
  397. Read the documentation of your processor.
  398. For example, in Xalan 2.x:
  399. <ul>
  400. <li>http://xml.apache.org/xalan/features/optimize (boolean)</li>
  401. <li>http://xml.apache.org/xalan/features/incremental (boolean)</li>
  402. <li>...</li>
  403. </ul>
  404. And in Saxon 7.x:
  405. <ul>
  406. <li>http://saxon.sf.net/feature/allow-external-functions (boolean)</li>
  407. <li>http://saxon.sf.net/feature/timing (boolean)</li>
  408. <li>http://saxon.sf.net/feature/traceListener (string)</li>
  409. <li>http://saxon.sf.net/feature/treeModel (integer)</li>
  410. <li>http://saxon.sf.net/feature/linenumbering (integer)</li>
  411. <li>...</li>
  412. </ul>
  413. <blockquote>
  414. <h4>Parameters</h4>
  415. <table width="60%" border="1" cellpadding="2" cellspacing="0">
  416. <tr>
  417. <td valign="top"><b>Attribute</b></td>
  418. <td valign="top"><b>Description</b></td>
  419. <td align="center" valign="top"><b>Required</b></td>
  420. </tr>
  421. <tr>
  422. <td valign="top">name</td>
  423. <td valign="top">Name of the attribute</td>
  424. <td align="center" valign="top">Yes</td>
  425. </tr>
  426. <tr>
  427. <td valign="top">value</td>
  428. <td valign="top">value of the attribute.</td>
  429. <td align="center" valign="middle" rowspan="3">Exactly one of these</td>
  430. </tr>
  431. <tr>
  432. <td valign="top">valueref</td>
  433. <td valign="top">value of the attribute is the value of the
  434. project reference with the given id. <em>since Ant 1.9.8</em></td>
  435. </tr>
  436. <tr>
  437. <td valign="top">classloaderforpath</td>
  438. <td valign="top">value of the attribute is a classloader that uses
  439. the classpath specified by a path that is the project reference
  440. with the given id. <em>since Ant 1.9.8</em></td>
  441. </tr>
  442. </table>
  443. <h4>Examples</h4>
  444. <pre>
  445. &lt;path id="extension-path"&gt;
  446. ...
  447. &lt;/path&gt;
  448. &lt;xslt ...&gt;
  449. &lt;factory&gt;
  450. &lt;attribute name="jdk.xml.transform.extensionClassLoader"
  451. classloaderforpath="extension-path"/&gt;
  452. &lt;/factory&gt;
  453. &lt;/xslt ...&gt;
  454. </pre>
  455. <p>Sets the classloader to use when loading extension functions to a
  456. classloader using the <code>path</code> with the
  457. id <code>extension-path</code>.
  458. </blockquote>
  459. <h4>feature</h4>
  460. <p><em>since Ant 1.9.8</em></p>
  461. <p>Used to specify settings of the processor factory. The feature
  462. names are mostly processor specific so you must be aware of the
  463. implementation to figure them out. Read the documentation of your
  464. processor. The only feature all implementations are required to
  465. support
  466. is <code>http://javax.xml.XMLConstants/feature/secure-processing</code>.
  467. <blockquote>
  468. <h4>Parameters</h4>
  469. <table width="60%" border="1" cellpadding="2" cellspacing="0">
  470. <tr>
  471. <td valign="top"><b>Attribute</b></td>
  472. <td valign="top"><b>Description</b></td>
  473. <td align="center" valign="top"><b>Required</b></td>
  474. </tr>
  475. <tr>
  476. <td valign="top">name</td>
  477. <td valign="top">Name of the feature</td>
  478. <td align="center" valign="top">Yes</td>
  479. </tr>
  480. <tr>
  481. <td valign="top">value</td>
  482. <td valign="top">value of the feature. A boolean value
  483. (i.e. permitted values are true,false,yes,no,on,off).</td>
  484. <td align="center" valign="top">No, defaults to false</td>
  485. </tr>
  486. </table>
  487. </blockquote>
  488. </blockquote>
  489. <h4>mapper</h4>
  490. <p><em>since Ant 1.6.2</em></p>
  491. <p>You can define filename transformations by using a nested <a
  492. href="../Types/mapper.html">mapper</a> element. The default mapper
  493. used by <code>&lt;xslt&gt;</code> removes the file extension from the
  494. source file and adds the extension specified via the extension
  495. attribute.</p>
  496. <h4>style</h4>
  497. <p><em>Since Ant 1.7</em></p>
  498. <p>The nested style element can be used to specify your stylesheet in terms
  499. of Ant's <a href="../Types/resources.html">resource</a> types. With
  500. this element, the stylesheet should be specified as a nested resource or
  501. single-element collection. Alternatively, use the <code>refid</code> to
  502. specify the resource or collection as a reference.</p>
  503. <h4>sysproperty</h4>
  504. <p>Use nested <code>&lt;sysproperty&gt;</code> elements to specify
  505. system properties required by the factory or transformation. These
  506. properties will be made available to the VM during the execution of
  507. the class. The attributes for this element are the same as
  508. for <a href="exec.html#env">environment variables</a>.</p>
  509. <p><em>since Ant 1.8.0</em>.</p>
  510. <h4>syspropertyset</h4>
  511. <p>You can specify a set of properties to be used as system properties
  512. with <a href="../Types/propertyset.html">syspropertyset</a>s.</p>
  513. <p><em>since Ant 1.8.0</em>.</p>
  514. <h3>Examples</h3>
  515. <blockquote>
  516. <pre>
  517. &lt;xslt basedir=&quot;doc&quot; destdir=&quot;build/doc&quot;
  518. extension=&quot;.html&quot; style=&quot;style/apache.xsl&quot;/&gt;</pre>
  519. <h4>Using an xmlcatalog</h4>
  520. <pre>
  521. &lt;xslt basedir=&quot;doc&quot; destdir=&quot;build/doc&quot;
  522. extension=&quot;.html&quot; style=&quot;style/apache.xsl&quot;&gt;
  523. &lt;xmlcatalog refid=&quot;mycatalog&quot;/&gt;
  524. &lt;/xslt&gt;
  525. &lt;xslt basedir=&quot;doc&quot; destdir=&quot;build/doc&quot;
  526. extension=&quot;.html&quot; style=&quot;style/apache.xsl&quot;&gt;
  527. &lt;xmlcatalog&gt;
  528. &lt;dtd
  529. publicId=&quot;-//ArielPartners//DTD XML Article V1.0//EN&quot;
  530. location=&quot;com/arielpartners/knowledgebase/dtd/article.dtd&quot;/&gt;
  531. &lt;/xmlcatalog&gt;
  532. &lt;/xslt&gt;
  533. </pre>
  534. <h4>Using XSL parameters</h4>
  535. <p>Simple String parameter:</p>
  536. <pre>
  537. &lt;xslt basedir=&quot;doc&quot; destdir=&quot;build/doc&quot;
  538. extension=&quot;.html&quot; style=&quot;style/apache.xsl&quot;&gt;
  539. &lt;param name=&quot;date&quot; expression=&quot;07-01-2000&quot;/&gt;
  540. &lt;/xslt&gt;</pre>
  541. <p>Then if you declare a global parameter &quot;date&quot; with the top-level
  542. element &lt;xsl:param name=&quot;date&quot;/&gt;, the variable
  543. <code>$date</code> will subsequently have the value 07-01-2000.
  544. </p>
  545. <p>Various data types and XPath expressions:</p>
  546. <pre>&lt;property name="antProperty1" value="ANT_PROPERTY_1"/&gt;
  547. &lt;property name="antProperty2" value="ANT_PROPERTY_2"/&gt;
  548. &lt;property name="antProperty3" value="3"/&gt;
  549. &lt;property name="antProperty4" value="substring-before"/&gt;
  550. &lt;!--
  551. ${this} is substituted by Ant itself
  552. and $this is evaluated by XPath as a variable
  553. --&gt;
  554. &lt;xslt in="in.xml" out="out.xml" style="template.xsl"&gt;
  555. &lt;!-- Simple String parameter: --&gt;
  556. &lt;param name="p0" expression="some nice string" type="STRING"/&gt;
  557. &lt;!-- A value substituted by Ant --&gt;
  558. &lt;param name="p1" expression="some string with ${antProperty1} constructed by Ant" type="STRING"/&gt;
  559. &lt;!-- XPath resulting in: and this is done in XPath: ANT_PROPERTY_2 --&gt;
  560. &lt;param name="p2" expression="concat('and this is done in XPath: ', $antProperty2)" type="XPATH_STRING"/&gt;
  561. &lt;!-- Some XPath math, result: 42 --&gt;
  562. &lt;param name="p3" expression="64 * 64 div 128 + 10" type="XPATH_NUMBER"/&gt;
  563. &lt;!-- Some numeric parameter: --&gt;
  564. &lt;param name="p4" expression="123.45" type="DOUBLE"/&gt;
  565. &lt;!-- XPath expression, result: true boolean --&gt;
  566. &lt;param name="p5" expression="$antProperty1 = 'ANT_PROPERTY_1'" type="XPATH_BOOLEAN"/&gt;
  567. &lt;!-- First one is an XPath variable, second one is a text substituted by Ant, result: true boolean --&gt;
  568. &lt;param name="p6" expression="$antProperty2 = '${antProperty2}'" type="XPATH_BOOLEAN"/&gt;
  569. &lt;!-- Some XPath math with a variable, result: 64 --&gt;
  570. &lt;param name="p7" expression="$antProperty3 * 4 * 5 + 4" type="XPATH_NUMBER"/&gt;
  571. &lt;!--
  572. XPath expression with substituted function name and a variable:
  573. substring-before($antProperty2, '_')
  574. result: ANT
  575. --&gt;
  576. &lt;param name="p8" expression="${antProperty4}($antProperty2, '_')" type="XPATH_STRING"/&gt;
  577. &lt;!-- Without type attribute: --&gt;
  578. &lt;param name="p9" expression="default type is String"/&gt;
  579. &lt;/xslt&gt;</pre>
  580. <h4>Using output properties</h4>
  581. <pre>
  582. &lt;xslt in=&quot;doc.xml&quot; out=&quot;build/doc/output.xml&quot;
  583. style=&quot;style/apache.xsl&quot;&gt;
  584. &lt;outputproperty name=&quot;method&quot; value=&quot;xml&quot;/&gt;
  585. &lt;outputproperty name=&quot;standalone&quot; value=&quot;yes&quot;/&gt;
  586. &lt;outputproperty name=&quot;encoding&quot; value=&quot;iso8859_1&quot;/&gt;
  587. &lt;outputproperty name=&quot;indent&quot; value=&quot;yes&quot;/&gt;
  588. &lt;/xslt&gt;
  589. </pre>
  590. <h4>Using factory settings</h4>
  591. <pre>
  592. &lt;xslt in=&quot;doc.xml&quot; out=&quot;build/doc/output.xml&quot;
  593. style=&quot;style/apache.xsl&quot;&gt;
  594. &lt;factory name=&quot;org.apache.xalan.processor.TransformerFactoryImpl&quot;&gt;
  595. &lt;attribute name=&quot;http://xml.apache.org/xalan/features/optimize&quot; value=&quot;true&quot;/&gt;
  596. &lt;/factory&gt;
  597. &lt;/xslt&gt;</pre>
  598. <h4>Using a mapper</h4>
  599. <pre>
  600. &lt;xslt basedir=&quot;in&quot; destdir=&quot;out&quot;
  601. style=&quot;style/apache.xsl&quot;&gt;
  602. &lt;mapper type=&quot;glob&quot; from=&quot;*.xml.en&quot; to=&quot;*.html.en&quot;/&gt;
  603. &lt;/xslt&gt;</pre>
  604. <h4>Using a nested resource to define the stylesheet</h4>
  605. <pre>
  606. &lt;xslt in="data.xml" out="${out.dir}/out.xml"&gt;
  607. &lt;style&gt;
  608. &lt;url url="${printParams.xsl.url}"/&gt;
  609. &lt;/style&gt;
  610. &lt;param name="set" expression="value"/&gt;
  611. &lt;/xslt&gt;</pre>
  612. <h4>Print the current processed file name</h4>
  613. <pre>
  614. &lt;project&gt;
  615. &lt;xslt style=&quot;printFilename.xsl&quot; destdir=&quot;out&quot; basedir=&quot;in&quot; extension=&quot;.txt&quot;
  616. filenameparameter=&quot;filename&quot;
  617. filedirparameter=&quot;filedir&quot;
  618. /&gt;
  619. &lt;/project&gt;
  620. &lt;xsl:stylesheet
  621. version=&quot;1.0&quot;
  622. xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;&gt;
  623. &lt;xsl:param name=&quot;filename&quot;&gt;&lt;/xsl:param&gt;
  624. &lt;xsl:param name=&quot;filedir&quot;&gt;.&lt;/xsl:param&gt;
  625. &lt;xsl:template match=&quot;/&quot;&gt;
  626. Current file is &lt;xsl:value-of select=&quot;$filename&quot;/&gt; in directory &lt;xsl:value-of select=&quot;$filedir&quot;/&gt;.
  627. &lt;/xsl:template&gt;
  628. &lt;/xsl:stylesheet&gt;
  629. </pre>
  630. <h4>Use an XInclude-aware version of Xerces while transforming</h4>
  631. <pre>
  632. &lt;xslt ...&gt;
  633. &lt;sysproperty key="org.apache.xerces.xni.parser.XMLParserConfiguration"
  634. value="org.apache.xerces.parsers.XIncludeParserConfiguration"
  635. /&gt;
  636. &lt;xslt&gt;
  637. </pre>
  638. </blockquote>
  639. </body>
  640. </html>