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

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