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
|
---|
31 | about all tasks currently known to Ant.</p>
|
---|
32 |
|
---|
33 | <p>Actually the DTD will not be a real DTD for buildfiles since Ant's
|
---|
34 | usage of XML cannot be captured with a DTD. Several elements in Ant
|
---|
35 | can have different attribute lists depending on the element that
|
---|
36 | contains them. "fail" for example can be <a
|
---|
37 | href="fail.html">the task</a> or the nested child element of the <a
|
---|
38 | href="../OptionalTasks/sound.html">sound</a> task. Don't consider the
|
---|
39 | generated DTD something to rely upon.</p>
|
---|
40 |
|
---|
41 | <p>Also note that the DTD generated by this task is incomplete, you can
|
---|
42 | always add XML entities using <a
|
---|
43 | href="taskdef.html"><code><taskdef></code></a> or <a
|
---|
44 | href="typedef.html"><code><typedef></code></a>. See <a
|
---|
45 | href="http://www.sdv.fr/pages/casa/html/ant-dtd.en.html"
|
---|
46 | target="_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
|
---|
48 | listed as <code>#IMPLIED</code>.</p>
|
---|
49 |
|
---|
50 | <p><em>Since Ant 1.7</em> custom structure printers can be used
|
---|
51 | instead of the one that emits a DTD. In order to plug in your own
|
---|
52 | structure, you have to implement the interface
|
---|
53 | <code>org.apache.tools.ant.taskdefs.AntStructure.StructurePrinter</code>
|
---|
54 | and <code><typedef> your class and use the new type as a nested
|
---|
55 | element 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 | <antstructure output="project.dtd" />
|
---|
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>
|
---|
80 | package org.example;
|
---|
81 | import org.apache.tools.ant.taskdefs.AntStructure;
|
---|
82 | public class MyPrinter implements AntStructure.StructurePrinter {
|
---|
83 | ...
|
---|
84 | }
|
---|
85 | </pre>
|
---|
86 |
|
---|
87 | <p>and then use it via typedef</p>
|
---|
88 |
|
---|
89 | <pre>
|
---|
90 | <typedef name="myprinter" classname="org.example.MyPrinter" />
|
---|
91 | <antstructure output="project.my">
|
---|
92 | <myprinter />
|
---|
93 | </antstructure>
|
---|
94 | </pre>
|
---|
95 |
|
---|
96 | <p>Your own StructurePrinter can accept attributes and nested elements
|
---|
97 | just like any other Ant type or task.</p>
|
---|
98 |
|
---|
99 | </body>
|
---|
100 | </html>
|
---|