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.

antstructure.html 2.8 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  5. <title>AntStructure Task</title>
  6. </head>
  7. <body>
  8. <h2><a name="antstructure">AntStructure</a></h2>
  9. <h3>Description</h3>
  10. <p>Generates an DTD for Ant buildfiles which contains information
  11. about all tasks currently known to Ant.</p>
  12. <p>Actually the DTD will not be a real DTD for buildfiles since Ant's
  13. usage of XML cannot be captured with a DTD. Several elements in Ant
  14. can have different attribute lists depending on the element that
  15. contains them. &quot;fail&quot; for example can be <a
  16. href="fail.html">the task</a> or the nested child element of the <a
  17. href="../OptionalTasks/sound.html">sound</a> task. Don't consider the
  18. generated DTD something to rely upon.</p>
  19. <p>Also note that the DTD generated by this task is incomplete, you can
  20. always add XML entities using <a
  21. href="taskdef.html"><code>&lt;taskdef&gt;</code></a> or <a
  22. href="typedef.html"><code>&lt;typedef&gt;</code></a>. See <a
  23. href="http://www.sdv.fr/pages/casa/html/ant-dtd.en.html"
  24. target="_top">here</a> for a way to get around this problem.</p>
  25. <p>This task doesn't know about required attributes, all will be
  26. listed as <code>#IMPLIED</code>.</p>
  27. <p><em>Since Ant 1.7</em> custom structure printers can be used
  28. instead of the one that emits a DTD. In order to plug in your own
  29. structure, you have to implement the interface
  30. <code>org.apache.tools.ant.taskdefs.AntStructure.StructurePrinter</code>
  31. and <code>&lt;typedef&gt; your class and use the new type as a nested
  32. element of this task - see the example below.</code>
  33. <h3>Parameters</h3>
  34. <table border="1" cellpadding="2" cellspacing="0">
  35. <tr>
  36. <td valign="top"><b>Attribute</b></td>
  37. <td valign="top"><b>Description</b></td>
  38. <td align="center" valign="top"><b>Required</b></td>
  39. </tr>
  40. <tr>
  41. <td valign="top">output</td>
  42. <td valign="top">file to write the DTD to.</td>
  43. <td valign="top" align="center">Yes</td>
  44. </tr>
  45. </table>
  46. <h3>Examples</h3>
  47. <blockquote><pre>
  48. &lt;antstructure output=&quot;project.dtd&quot;/&gt;
  49. </pre></blockquote>
  50. <p><b>Emitting your own structure instead of a DTD</b></p>
  51. <p>First you need to implement the interface</p>
  52. <pre>
  53. package org.example;
  54. import org.apache.tools.ant.taskdefs.AntStructure;
  55. public class MyPrinter implements AntStructure.StructurePrinter {
  56. ...
  57. }
  58. </pre>
  59. <p>and then use it via typedef</p>
  60. <pre>
  61. &lt;typedef name="myprinter" classname="org.example.MyPrinter"/&gt;
  62. &lt;antstructure output="project.my"&gt;
  63. &lt;myprinter/&gt;
  64. &lt;antstructure&gt;
  65. </pre>
  66. <p>Your own StructurePrinter can accept attributes and nested elements
  67. just like any other Ant type or task.</p>
  68. <hr><p align="center">Copyright &copy; 2000-2002,2004-2005 The Apache Software Foundation. All rights
  69. Reserved.</p>
  70. </body>
  71. </html>