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

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

initial import of LiRK3

File size: 8.4 KB
Line 
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>
12Loads property values from a well-formed xml file. There are no other restrictions
13than "well-formed". You can choose the layout you want. For example this XML property file:
14<pre>
15 &lt;root&gt;
16 &lt;properties&gt;
17 &lt;foo&gt;bar&lt;/foo&gt;
18 &lt;/properties&gt;
19 &lt;/root&gt;
20</pre>
21is roughly equivalent to this Java property file:
22<pre>
23 root.properties.foo = bar
24</pre>
25
26<p>
27By default, this load
28does <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>
35Input processing can be enabled by using the <b>semanticAttributes</b>
36attribute. 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
38is 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>
60For example, with semantic attribute processing enabled, this XML property
61file:
62<pre>
63 &lt;root&gt;
64 &lt;properties&gt;
65 &lt;foo location="bar"/&gt;
66 &lt;quux&gt;${root.properties.foo}&lt;/quux&gt;
67 &lt;/properties&gt;
68 &lt;/root&gt;
69</pre>
70is roughly equivalent to the following fragments in a build.xml file:
71<pre>
72 &lt;property name="root.properties.foo" location="bar"/&gt;
73 &lt;property name="root.properties.quux" value="${root.properties.foo}"/&gt;
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 &lt;root-tag myattr="true"&gt;
145 &lt;inner-tag someattr="val"&gt;Text&lt;/inner-tag&gt;
146 &lt;a2&gt;&lt;a3&gt;&lt;a4&gt;false&lt;/a4&gt;&lt;/a3&gt;&lt;/a2&gt;
147 &lt;/root-tag&gt;
148</pre>
149
150<h5>default loading</h5>
151<p>This entry in a build file:
152<pre> &lt;xmlproperty file="somefile.xml" /&gt;</pre>
153is 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> &lt;xmlproperty file="somefile.xml" collapseAttributes="true"/&gt;</pre>
164is 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> &lt;xmlproperty file="somefile.xml" keepRoot="false"/&gt;</pre>
175is 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 &lt;root-tag&gt;
187 &lt;version value="0.0.1"/&gt;
188 &lt;build folder="build"&gt;
189 &lt;classes id="build.classes" location="${build.folder}/classes"/&gt;
190 &lt;reference refid="build.classes"/&gt;
191 &lt;/build&gt;
192 &lt;compile&gt;
193 &lt;classpath pathid="compile.classpath"&gt;
194 &lt;pathelement location="${build.classes}"/&gt;
195 &lt;/classpath&gt;
196 &lt;/compile&gt;
197 &lt;run-time&gt;
198 &lt;jars&gt;*.jar&lt;/jars&gt;
199 &lt;classpath pathid="run-time.classpath"&gt;
200 &lt;path refid="compile.classpath"/&gt;
201 &lt;pathelement path="${run-time.jars}"/&gt;
202 &lt;/classpath&gt;
203 &lt;/run-time&gt;
204 &lt;/root-tag&gt;
205</pre>
206
207<h5>default loading (semanticAttributes=true)</h5>
208<p>This entry in a build file:
209<pre> &lt;xmlproperty file="somefile.xml"
210 semanticAttributes="true"/&gt;</pre>
211is equivalent to the following entries in a build file:
212<pre>
213 &lt;property name="version" value="0.0.1"/&gt;
214 &lt;property name="build.folder" value="build"/&gt;
215 &lt;property name="build.classes" location="${build.folder}/classes" id="build.classes"/&gt;
216 &lt;property name="build.reference" refid="build.classes"/&gt;
217
218 &lt;property name="run-time.jars" value="*.jar/&gt;
219
220 &lt;classpath id="compile.classpath"&gt;
221 &lt;pathelement location="${build.classes}"/&gt;
222 &lt;/classpath&gt;
223
224 &lt;classpath id="run-time.classpath"&gt;
225 &lt;path refid="compile.classpath"/&gt;
226 &lt;pathelement path="${run-time.jars}"/&gt;
227 &lt;/classpath&gt;
228</pre>
229
230<h5>includeSemanticAttribute="true"</h5>
231<p>This entry in a build file:
232<pre> &lt;xmlproperty file="somefile.xml"
233 semanticAttributes="true"
234 includeSemanticAttribute="true"/&gt;
235</pre>
236is equivalent to the following entries in a build file:
237<pre>
238 &lt;property name="version.value" value="0.0.1"/&gt;
239 &lt;property name="build.folder" value="build"/&gt;
240 &lt;property name="build.classes.location" location="${build.folder}/classes"/&gt;
241 &lt;property name="build.reference.refid" refid="build.location"/&gt;
242
243 &lt;property name="run-time.jars" value="*.jar/&gt;
244
245 &lt;classpath id="compile.classpath"&gt;
246 &lt;pathelement location="${build.classes}"/&gt;
247 &lt;/classpath&gt;
248
249 &lt;classpath id="run-time.classpath"&gt;
250 &lt;path refid="compile.classpath"/&gt;
251 &lt;pathelement path="${run-time.jars}"/&gt;
252 &lt;/classpath&gt;
253</pre>
254
255<hr>
256
257<p align="center">Copyright &copy; 2002-2004 The Apache Software Foundation. All rights
258Reserved.</p>
259
260</body>
261</html>
Note: See TracBrowser for help on using the repository browser.