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