1 | <html>
|
---|
2 | <head>
|
---|
3 | <title>XmlProperty Task</title>
|
---|
4 | <link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
|
---|
5 | </head>
|
---|
6 |
|
---|
7 | <body>
|
---|
8 |
|
---|
9 | <h2><a name="xmlproperty">XmlProperty</a></h2>
|
---|
10 | <h3>Description</h3>
|
---|
11 | <p>
|
---|
12 | Loads property values from a well-formed xml file. There are no other restrictions
|
---|
13 | than "well-formed". You can choose the layout you want. For example this XML property file:
|
---|
14 | <pre>
|
---|
15 | <root>
|
---|
16 | <properties>
|
---|
17 | <foo>bar</foo>
|
---|
18 | </properties>
|
---|
19 | </root>
|
---|
20 | </pre>
|
---|
21 | is roughly equivalent to this Java property file:
|
---|
22 | <pre>
|
---|
23 | root.properties.foo = bar
|
---|
24 | </pre>
|
---|
25 |
|
---|
26 | <p>
|
---|
27 | By default, this load
|
---|
28 | does <em>no</em> processing of the input. In particular, unlike the
|
---|
29 | <a href="property.html">Property task</a>, property references
|
---|
30 | (i.e., <samp>${foo}</samp>) are not resolved.
|
---|
31 | <p>
|
---|
32 | <a name="semanticAttributes">
|
---|
33 | <h3>Semantic Attributes</h3>
|
---|
34 | </a>
|
---|
35 | Input processing can be enabled by using the <b>semanticAttributes</b>
|
---|
36 | attribute. If this attribute is set to <i>true</i> (its default is
|
---|
37 | <i>false</i>), the following processing occurs as the input XML file
|
---|
38 | is loaded:
|
---|
39 | <ul>
|
---|
40 | <li>Property references are resolved.</li>
|
---|
41 | <li>The following attriubtes are treated differently:
|
---|
42 | <ul>
|
---|
43 | <li><b>id</b>: The property is associated with the given id value.</li>
|
---|
44 | <li><b>location</b>: The property is treated as a file location</li>
|
---|
45 | <li><b>refid</b>: The property is set to the value of the
|
---|
46 | referenced property.</li>
|
---|
47 | <li><b>value</b>: The property is set to the value indicated.</li>
|
---|
48 | </ul>
|
---|
49 | </li>
|
---|
50 | <li><a href="../using.html#path">Path-like Structures</a> can be defined
|
---|
51 | by use of the following attributes:
|
---|
52 | <ul>
|
---|
53 | <li><b>pathid</b>: The given id is used to identify a path. The
|
---|
54 | nested XML tag name is ignored. Child elements can be used
|
---|
55 | (XML tag names are ignored) to identify elements of the path.</li>
|
---|
56 | </ul>
|
---|
57 | </li>
|
---|
58 | </ul>
|
---|
59 | <p>
|
---|
60 | For example, with semantic attribute processing enabled, this XML property
|
---|
61 | file:
|
---|
62 | <pre>
|
---|
63 | <root>
|
---|
64 | <properties>
|
---|
65 | <foo location="bar"/>
|
---|
66 | <quux>${root.properties.foo}</quux>
|
---|
67 | </properties>
|
---|
68 | </root>
|
---|
69 | </pre>
|
---|
70 | is roughly equivalent to the following fragments in a build.xml file:
|
---|
71 | <pre>
|
---|
72 | <property name="root.properties.foo" location="bar"/>
|
---|
73 | <property name="root.properties.quux" value="${root.properties.foo}"/>
|
---|
74 | </pre>
|
---|
75 |
|
---|
76 | </p>
|
---|
77 |
|
---|
78 | <h3>Parameters</h3>
|
---|
79 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
80 | <tr>
|
---|
81 | <td valign="top"><b>Attribute</b></td>
|
---|
82 | <td valign="top"><b>Description</b></td>
|
---|
83 | <td align="center" valign="top"><b>Required</b></td>
|
---|
84 | </tr>
|
---|
85 | <tr>
|
---|
86 | <td valign="top">file</td>
|
---|
87 | <td valign="top">The XML file to parse.</td>
|
---|
88 | <td valign="top" align="center">Yes</td>
|
---|
89 | </tr>
|
---|
90 | <tr>
|
---|
91 | <td valign="top">prefix</td>
|
---|
92 | <td valign="top">The prefix to prepend to each property</td>
|
---|
93 | <td valign="top" align="center">No</td>
|
---|
94 | </tr>
|
---|
95 | <tr>
|
---|
96 | <td valign="top">keepRoot</td>
|
---|
97 | <td valign="top">Keep the xml root tag as the
|
---|
98 | first value in the property name.</td>
|
---|
99 | <td valign="top" align="center">No, default is <i>true</i>.</td>
|
---|
100 | </tr>
|
---|
101 | <tr>
|
---|
102 | <td valign="top">validate</td>
|
---|
103 | <td valign="top">Validate the input file (e.g. by a DTD). Otherwise the XML must only be well-formed.</td>
|
---|
104 | <td valign="top" align="center">No, default is <i>false</i>.</td>
|
---|
105 | </tr>
|
---|
106 | <tr>
|
---|
107 | <td valign="top">collapseAttributes</td>
|
---|
108 | <td valign="top">Treat attributes as nested elements.</td>
|
---|
109 | <td valign="top" align="center">No, default is <i>false</i>.</td>
|
---|
110 | </tr>
|
---|
111 | <tr>
|
---|
112 | <td valign="top">semanticAttributes</td>
|
---|
113 | <td valign="top">Enable special handling of certain attribute names.
|
---|
114 | See the <a href="#semanticAttributes">Semantic Attributes</a>
|
---|
115 | section for more information.</td>
|
---|
116 | <td valign="top" align="center">No, default is <i>false</i>.</td>
|
---|
117 | </tr>
|
---|
118 | <tr>
|
---|
119 | <td valign="top">includeSemanticAttribute</td>
|
---|
120 | <td valign="top">Include the semantic attribute name
|
---|
121 | as part of the property name. Ignored if
|
---|
122 | <i>semanticAttributes</i> is not set to <i>true</i>.
|
---|
123 | See the <a href="#semanticAttributes">Semantic Attributes</a>
|
---|
124 | section for more information.</td>
|
---|
125 | <td valign="top" align="center">No, default is <i>false</i>.</td>
|
---|
126 | </tr>
|
---|
127 | <tr>
|
---|
128 | <td valign="top">rootDirectory</td>
|
---|
129 | <td valign="top">The directory to use for resolving file references. Ignored
|
---|
130 | if <i>semanticAttributes</i> is not set to <i>true</i>.</td>
|
---|
131 | <td valign="top" align="center">No, default is <i>${basedir}</i>.</td>
|
---|
132 | </tr>
|
---|
133 | </table>
|
---|
134 |
|
---|
135 | <a name="examples">
|
---|
136 | <h3>Examples</h3>
|
---|
137 | </a>
|
---|
138 |
|
---|
139 | <h4>Non-semantic Attributes</h4>
|
---|
140 |
|
---|
141 | <p>Here is an example xml file that does not have any semantic attributes.</p>
|
---|
142 |
|
---|
143 | <pre>
|
---|
144 | <root-tag myattr="true">
|
---|
145 | <inner-tag someattr="val">Text</inner-tag>
|
---|
146 | <a2><a3><a4>false</a4></a3></a2>
|
---|
147 | </root-tag>
|
---|
148 | </pre>
|
---|
149 |
|
---|
150 | <h5>default loading</h5>
|
---|
151 | <p>This entry in a build file:
|
---|
152 | <pre> <xmlproperty file="somefile.xml" /></pre>
|
---|
153 | is equivalent to the following properties:
|
---|
154 | <pre>
|
---|
155 | root-tag(myattr)=true
|
---|
156 | root-tag.inner-tag=Text
|
---|
157 | root-tag.inner-tag(someattr)=val
|
---|
158 | root-tag.a2.a3.a4=false
|
---|
159 | </pre>
|
---|
160 |
|
---|
161 | <h5>collapseAttributes=false</h5>
|
---|
162 | <p>This entry in a build file:
|
---|
163 | <pre> <xmlproperty file="somefile.xml" collapseAttributes="true"/></pre>
|
---|
164 | is equivalent to the following properties:
|
---|
165 | <pre>
|
---|
166 | root-tag.myattr=true
|
---|
167 | root-tag.inner-tag=Text
|
---|
168 | root-tag.inner-tag.someatt=val
|
---|
169 | root-tag.a2.a3.a4=false
|
---|
170 | </pre>
|
---|
171 |
|
---|
172 | <h5>keepRoot=false</h5>
|
---|
173 | <p>This entry in a build file:
|
---|
174 | <pre> <xmlproperty file="somefile.xml" keepRoot="false"/></pre>
|
---|
175 | is equivalent to the following properties:
|
---|
176 | <pre>
|
---|
177 | inner-tag=Text
|
---|
178 | inner-tag(someattr)=val
|
---|
179 | a2.a3.a4=false
|
---|
180 | </pre>
|
---|
181 |
|
---|
182 | <h4>Semantic Attributes</h4>
|
---|
183 |
|
---|
184 | <p>Here is an example xml file that has semantic attributes.</p>
|
---|
185 | <pre>
|
---|
186 | <root-tag>
|
---|
187 | <version value="0.0.1"/>
|
---|
188 | <build folder="build">
|
---|
189 | <classes id="build.classes" location="${build.folder}/classes"/>
|
---|
190 | <reference refid="build.classes"/>
|
---|
191 | </build>
|
---|
192 | <compile>
|
---|
193 | <classpath pathid="compile.classpath">
|
---|
194 | <pathelement location="${build.classes}"/>
|
---|
195 | </classpath>
|
---|
196 | </compile>
|
---|
197 | <run-time>
|
---|
198 | <jars>*.jar</jars>
|
---|
199 | <classpath pathid="run-time.classpath">
|
---|
200 | <path refid="compile.classpath"/>
|
---|
201 | <pathelement path="${run-time.jars}"/>
|
---|
202 | </classpath>
|
---|
203 | </run-time>
|
---|
204 | </root-tag>
|
---|
205 | </pre>
|
---|
206 |
|
---|
207 | <h5>default loading (semanticAttributes=true)</h5>
|
---|
208 | <p>This entry in a build file:
|
---|
209 | <pre> <xmlproperty file="somefile.xml"
|
---|
210 | semanticAttributes="true"/></pre>
|
---|
211 | is equivalent to the following entries in a build file:
|
---|
212 | <pre>
|
---|
213 | <property name="version" value="0.0.1"/>
|
---|
214 | <property name="build.folder" value="build"/>
|
---|
215 | <property name="build.classes" location="${build.folder}/classes" id="build.classes"/>
|
---|
216 | <property name="build.reference" refid="build.classes"/>
|
---|
217 |
|
---|
218 | <property name="run-time.jars" value="*.jar/>
|
---|
219 |
|
---|
220 | <classpath id="compile.classpath">
|
---|
221 | <pathelement location="${build.classes}"/>
|
---|
222 | </classpath>
|
---|
223 |
|
---|
224 | <classpath id="run-time.classpath">
|
---|
225 | <path refid="compile.classpath"/>
|
---|
226 | <pathelement path="${run-time.jars}"/>
|
---|
227 | </classpath>
|
---|
228 | </pre>
|
---|
229 |
|
---|
230 | <h5>includeSemanticAttribute="true"</h5>
|
---|
231 | <p>This entry in a build file:
|
---|
232 | <pre> <xmlproperty file="somefile.xml"
|
---|
233 | semanticAttributes="true"
|
---|
234 | includeSemanticAttribute="true"/>
|
---|
235 | </pre>
|
---|
236 | is equivalent to the following entries in a build file:
|
---|
237 | <pre>
|
---|
238 | <property name="version.value" value="0.0.1"/>
|
---|
239 | <property name="build.folder" value="build"/>
|
---|
240 | <property name="build.classes.location" location="${build.folder}/classes"/>
|
---|
241 | <property name="build.reference.refid" refid="build.location"/>
|
---|
242 |
|
---|
243 | <property name="run-time.jars" value="*.jar/>
|
---|
244 |
|
---|
245 | <classpath id="compile.classpath">
|
---|
246 | <pathelement location="${build.classes}"/>
|
---|
247 | </classpath>
|
---|
248 |
|
---|
249 | <classpath id="run-time.classpath">
|
---|
250 | <path refid="compile.classpath"/>
|
---|
251 | <pathelement path="${run-time.jars}"/>
|
---|
252 | </classpath>
|
---|
253 | </pre>
|
---|
254 |
|
---|
255 | <hr>
|
---|
256 |
|
---|
257 | <p align="center">Copyright © 2002-2004 The Apache Software Foundation. All rights
|
---|
258 | Reserved.</p>
|
---|
259 |
|
---|
260 | </body>
|
---|
261 | </html>
|
---|