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 7.9 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Apache Ant User Manual</title>
  5. </head>
  6. <body>
  7. <h2><a name="style">Style</a></h2>
  8. <h3>Description</h3>
  9. <p>Process a set of documents via XSLT.</p>
  10. <p>This is useful for building views of XML based documentation,
  11. or for generating code.</p>
  12. <p><b>Note:</b> This task depends on external libraries not included in the Ant distribution.
  13. See <a href="../install.html#librarydependencies">Library Dependencies</a> for more information.</p>
  14. <p>It is possible to refine the set of files that are being processed. This can be
  15. done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>, <i>excludesfile</i> and <i>defaultexcludes</i>
  16. attributes. With the <i>includes</i> or <i>includesfile</i> attribute you specify the files you want to
  17. have included by using patterns. The <i>exclude</i> or <i>excludesfile</i> attribute is used to specify
  18. the files you want to have excluded. This is also done with patterns. And
  19. finally with the <i>defaultexcludes</i> attribute, you can specify whether you
  20. want to use default exclusions or not. See the section on <a
  21. href="../dirtasks.html#directorybasedtasks">directory based tasks</a>, on how the
  22. inclusion/exclusion of files works, and how to write patterns.</p>
  23. <p>This task forms an implicit <a href="../CoreTypes/fileset.html">FileSet</a> and supports all
  24. attributes of <code>&lt;fileset&gt;</code> (<code>dir</code> becomes <code>basedir</code>)
  25. as well as the nested <code>&lt;include&gt;</code>, <code>&lt;exclude&gt;</code>
  26. and <code>&lt;patternset&gt;</code> elements.</p>
  27. <p>Style supports the use of a &lt;param&gt; element which is used to pass values
  28. to an &lt;xsl:param&gt; declaration.</p>
  29. <p>If you want to use Xalan-J 1 or XSL:P, you also need Ant's optional.jar</p>
  30. <h3>Parameters</h3>
  31. <table border="1" cellpadding="2" cellspacing="0">
  32. <tr>
  33. <td valign="top"><b>Attribute</b></td>
  34. <td valign="top"><b>Description</b></td>
  35. <td align="center" valign="top"><b>Required</b></td>
  36. </tr>
  37. <tr>
  38. <td valign="top">basedir</td>
  39. <td valign="top">where to find the source XML file, default is the
  40. project's basedir.</td>
  41. <td align="center" valign="top">No</td>
  42. </tr>
  43. <tr>
  44. <td valign="top">destdir</td>
  45. <td valign="top">directory in which to store the results.</td>
  46. <td align="center" valign="top">Yes, unless in and out have been
  47. specified.</td>
  48. </tr>
  49. <tr>
  50. <td valign="top">extension</td>
  51. <td valign="top">desired file extension to be used for the targets. If not
  52. specified, the default is &quot;.html&quot;.</td>
  53. <td align="center" valign="top">No</td>
  54. </tr>
  55. <tr>
  56. <td valign="top">style</td>
  57. <td valign="top">name of the stylesheet to use - given either relative
  58. to the project's basedir or as an absolute path
  59. <em><strong>DEPRECATED</strong> - can be specified as a path relative
  60. to the basedir attribute of this task as well</em>.
  61. </td>
  62. <td align="center" valign="top">Yes</td>
  63. </tr>
  64. <tr>
  65. <td valign="top">classpath</td>
  66. <td valign="top">the classpath to use when looking up the XSLT
  67. processor.</td>
  68. <td align="center" valign="top">No</td>
  69. </tr>
  70. <tr>
  71. <td valign="top">classpathref</td>
  72. <td valign="top">the classpath to use, given as <a
  73. href="../using.html#references">reference</a> to a path defined elsewhere.</td>
  74. <td align="center" valign="top">No</td>
  75. </tr>
  76. <tr>
  77. <td valign="top">force</td>
  78. <td valign="top">Recreate target files, even if they are newer
  79. than their corresponding source files or the stylesheet.</td>
  80. <td valign="top" align="center">No</td>
  81. </tr>
  82. <tr>
  83. <td valign="top">processor</td>
  84. <td valign="top">name of the XSLT processor to use. Permissible values are
  85. &quot;trax&quot; for a TraX compliant processor, &quot;xslp&quot; for the
  86. XSL:P processor, &quot;xalan&quot; for the Apache XML Xalan (version 1)
  87. processor, &quot;adaptx&quot; for the Exolab Adaptx processor
  88. or the name of an arbitrary XSLTLiaison class. Defaults to trax,
  89. followed by xalan, then adaptx and then xslp (in that
  90. order). The first one found in your class path is the one that
  91. is used.
  92. <em><strong>DEPRECATED</strong> - XSL:P and Adaptx are
  93. deprecated and will be removed in the next version. Use trax or
  94. xalan instead.</em>.
  95. </td>
  96. <td align="center" valign="top">No</td>
  97. </tr>
  98. <tr>
  99. <td valign="top">includes</td>
  100. <td valign="top">comma separated list of patterns of files that must be included.
  101. All files are included when omitted.</td>
  102. <td valign="top" align="center">No</td>
  103. </tr>
  104. <tr>
  105. <td valign="top">includesfile</td>
  106. <td valign="top">the name of a file. Each line of this file is taken to be
  107. an include pattern</td>
  108. <td valign="top" align="center">No</td>
  109. </tr>
  110. <tr>
  111. <td valign="top">excludes</td>
  112. <td valign="top">comma separated list of patterns of files that must be excluded.
  113. No files (except default excludes) are excluded when omitted.</td>
  114. <td valign="top" align="center">No</td>
  115. </tr>
  116. <tr>
  117. <td valign="top">excludesfile</td>
  118. <td valign="top">the name of a file. Each line of this file is taken to be
  119. an exclude pattern</td>
  120. <td valign="top" align="center">No</td>
  121. </tr>
  122. <tr>
  123. <td valign="top">defaultexcludes</td>
  124. <td valign="top">indicates whether default excludes should be used or not
  125. (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
  126. <td valign="top" align="center">No</td>
  127. </tr>
  128. <tr>
  129. <td valign="top">in</td>
  130. <td valign="top">specifies a single XML document to be styled. Should be used
  131. with the out attribute.</td>
  132. <td valign="top" align="center">No</td>
  133. </tr>
  134. <tr>
  135. <td valign="top">out</td>
  136. <td valign="top">specifies the output name for the styled result from the
  137. in attribute.</td>
  138. <td valign="top" align="center">No</td>
  139. </tr>
  140. <tr>
  141. <td valign="top">outputtype</td>
  142. <td valign="top">specifies the output method to be used. Only "xml" is
  143. guaranteed to be supported by all translators. Xalan2 supports "xml",
  144. "html", and "text"</td>
  145. <td valign="top" align="center">No</td>
  146. </tr>
  147. </table>
  148. <h3>Parameters specified as nested elements</h3>
  149. <h4>classpath</h4>
  150. <p>The classpath to load the processor from can be specified via a
  151. nested <code>&lt;classpath&gt;</code>, as well - that is, a
  152. <a href="../using.html#path">path</a>-like structure.</p>
  153. <h4>param</h4>
  154. <p>Param is used to pass a parameter to the XSL stylesheet.</p>
  155. <h4>Parameters</h4>
  156. <table width="60%" border="1" cellpadding="2" cellspacing="0">
  157. <tr>
  158. <td valign="top"><b>Attribute</b></td>
  159. <td valign="top"><b>Description</b></td>
  160. <td align="center" valign="top"><b>Required</b></td>
  161. </tr>
  162. <tr>
  163. <td valign="top">name</td>
  164. <td valign="top">Name of the XSL parameter</td>
  165. <td align="center" valign="top">Yes</td>
  166. </tr>
  167. <tr>
  168. <td valign="top">expression</td>
  169. <td valign="top">XSL expression to be placed into the param. To pass a text
  170. value into the style sheet it needs to be escaped using single quotes.</td>
  171. <td align="center" valign="top">Yes</td>
  172. </tr>
  173. </table>
  174. <h3>Examples</h3>
  175. <blockquote>
  176. <pre>
  177. &lt;style basedir=&quot;doc&quot; destdir=&quot;build/doc&quot;
  178. extension=&quot;.html&quot; style=&quot;style/apache.xsl&quot;/&gt;</pre>
  179. <h4>Using XSL parameters</h4>
  180. <pre>&lt;style basedir=&quot;doc&quot; destdir=&quot;build/doc&quot;
  181. extension=&quot;.html&quot; style=&quot;style/apache.xsl&quot;&gt;
  182. &lt;param name=&quot;date&quot; expression=&quot;07-01-2000&quot;/&gt;
  183. &lt;/style&gt;</pre>
  184. <p>Then if you declare a global parameter &quot;date&quot; with the top-level
  185. element &lt;xsl:param name=&quot;date&quot;/&gt;, the variable
  186. <code>$date</code> will subsequently have the value 07-01-2000.
  187. </p>
  188. </blockquote>
  189. <hr>
  190. <p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
  191. Reserved.</p>
  192. </body>
  193. </html>