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.4 KiB

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