source: release-kits/lirk3/bin/ant-installer/web/manual1.7.0/manual/CoreTasks/antstructure.html@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 3.5 KB
Line 
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
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16-->
17<html>
18
19<head>
20<meta http-equiv="Content-Language" content="en-us">
21<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
22<title>AntStructure Task</title>
23</head>
24
25<body>
26
27<h2><a name="antstructure">AntStructure</a></h2>
28<h3>Description</h3>
29
30<p>Generates an DTD for Ant buildfiles which contains information
31about all tasks currently known to Ant.</p>
32
33<p>Actually the DTD will not be a real DTD for buildfiles since Ant's
34usage of XML cannot be captured with a DTD. Several elements in Ant
35can have different attribute lists depending on the element that
36contains them. &quot;fail&quot; for example can be <a
37href="fail.html">the task</a> or the nested child element of the <a
38href="../OptionalTasks/sound.html">sound</a> task. Don't consider the
39generated DTD something to rely upon.</p>
40
41<p>Also note that the DTD generated by this task is incomplete, you can
42always add XML entities using <a
43href="taskdef.html"><code>&lt;taskdef&gt;</code></a> or <a
44href="typedef.html"><code>&lt;typedef&gt;</code></a>. See <a
45href="http://www.sdv.fr/pages/casa/html/ant-dtd.en.html"
46target="_top">here</a> for a way to get around this problem.</p>
47<p>This task doesn't know about required attributes, all will be
48listed as <code>#IMPLIED</code>.</p>
49
50<p><em>Since Ant 1.7</em> custom structure printers can be used
51instead of the one that emits a DTD. In order to plug in your own
52structure, you have to implement the interface
53<code>org.apache.tools.ant.taskdefs.AntStructure.StructurePrinter</code>
54and <code>&lt;typedef&gt; your class and use the new type as a nested
55element of this task - see the example below.</code>
56
57<h3>Parameters</h3>
58<table border="1" cellpadding="2" cellspacing="0">
59 <tr>
60 <td valign="top"><b>Attribute</b></td>
61 <td valign="top"><b>Description</b></td>
62 <td align="center" valign="top"><b>Required</b></td>
63 </tr>
64 <tr>
65 <td valign="top">output</td>
66 <td valign="top">file to write the DTD to.</td>
67 <td valign="top" align="center">Yes</td>
68 </tr>
69</table>
70<h3>Examples</h3>
71<blockquote><pre>
72&lt;antstructure output=&quot;project.dtd&quot; /&gt;
73</pre></blockquote>
74
75<p><b>Emitting your own structure instead of a DTD</b></p>
76
77<p>First you need to implement the interface</p>
78
79<pre>
80package org.example;
81import org.apache.tools.ant.taskdefs.AntStructure;
82public class MyPrinter implements AntStructure.StructurePrinter {
83 ...
84}
85</pre>
86
87<p>and then use it via typedef</p>
88
89<pre>
90 &lt;typedef name="myprinter" classname="org.example.MyPrinter" /&gt;
91 &lt;antstructure output="project.my"&gt;
92 &lt;myprinter /&gt;
93 &lt;/antstructure&gt;
94</pre>
95
96<p>Your own StructurePrinter can accept attributes and nested elements
97just like any other Ant type or task.</p>
98
99</body>
100</html>
Note: See TracBrowser for help on using the repository browser.