blob: 8cda7fe49bf72b16bc74f8b90153a6a25f7f23f5 [file] [log] [blame]
<!DOCTYPE html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
<title>AntStructure Task</title>
</head>
<body>
<h2 id="antstructure">AntStructure</h2>
<h3>Description</h3>
<p>Generates an DTD for Apache Ant buildfiles which contains information about all tasks currently
known to Ant.</p>
<p>Actually the DTD will not be a real DTD for buildfiles since Ant's usage of XML cannot be
captured with a DTD. Several elements in Ant can have different attribute lists depending on the
element that contains them. <a href="fail.html"><code>&lt;fail&gt;</code></a> for example can be a
task or a nested child element of the <a href="../Tasks/sound.html"><code>&lt;sound&gt;</code></a>
task. Don't consider the generated DTD something to rely upon.</p>
<p>Also note that the DTD generated by this task is incomplete, you can always add XML entities
using <a href="taskdef.html"><code>&lt;taskdef&gt;</code></a>
or <a href="typedef.html"><code>&lt;typedef&gt;</code></a>.
See <a href="https://web.archive.org/web/20071231061243/http://www.sdv.fr/pages/casa/html/ant-dtd.en.html"
target="_top">here</a> for a way to get around this problem.</p>
<p>This task doesn't know about required attributes, all will be listed
as <code>#IMPLIED</code>.</p>
<p><em>Since Ant 1.7</em> custom structure printers can be used instead of the one that emits a DTD.
In order to plug in your own structure, you have to implement the
interface <code class="code">org.apache.tools.ant.taskdefs.AntStructure.StructurePrinter</code>
and <code>&lt;typedef&gt;</code> your class and use the new type as a nested element of this
task&mdash;see the example below.
<h3>Parameters</h3>
<table class="attr">
<tr>
<th scope="col">Attribute</th>
<th scope="col">Description</th>
<th scope="col">Required</th>
</tr>
<tr>
<td>output</td>
<td>file to write the DTD to.</td>
<td>Yes</td>
</tr>
</table>
<h3>Examples</h3>
<p>Basic usage</p>
<pre>&lt;antstructure output=&quot;project.dtd&quot;/&gt;</pre>
<p>Emit your own structure instead of a DTD: first you need to implement the interface</p>
<pre>
package org.example;
import org.apache.tools.ant.taskdefs.AntStructure;
public class MyPrinter implements AntStructure.StructurePrinter {
...
}</pre>
<p>and then use it via typedef</p>
<pre>
&lt;typedef name="myprinter" classname="org.example.MyPrinter"/&gt;
&lt;antstructure output="project.my"&gt;
&lt;myprinter/&gt;
&lt;/antstructure&gt;</pre>
<p>Your own <code class="code">StructurePrinter</code> can accept attributes and nested elements
just like any other Ant type or task.</p>
</body>
</html>