|
|
@@ -5,11 +5,72 @@ |
|
|
|
|
|
|
|
<body> |
|
|
|
|
|
|
|
|
|
|
|
<h2><a name="xmlproperty">XmlProperty</a></h2> |
|
|
|
<h3>Description</h3> |
|
|
|
<p> |
|
|
|
Loads property values from a valid xml file. |
|
|
|
Loads property values from a valid xml file. This XML property file: |
|
|
|
<pre> |
|
|
|
<root> |
|
|
|
<properties> |
|
|
|
<foo>bar</foo> |
|
|
|
</properties> |
|
|
|
</root> |
|
|
|
</pre> |
|
|
|
is roughly equivalent to this java property file: |
|
|
|
<pre> |
|
|
|
root.properties.foo = bar |
|
|
|
</pre> |
|
|
|
|
|
|
|
<p> |
|
|
|
By default, this load |
|
|
|
does <em>no</em> processing of the input. In particular, unlike the |
|
|
|
<a href="property.html">Property task</a>, property references |
|
|
|
(i.e., ${foo}) are not resolved. |
|
|
|
<p> |
|
|
|
<a name="semanticAttributes"> |
|
|
|
<h3>Semantic Attributes</h3> |
|
|
|
</a> |
|
|
|
Input processing can be enabled by using the <b>semanticAttributes</b> |
|
|
|
attribute. If this attribute is set to <i>true</i> (its default is |
|
|
|
<i>false</i>), the following processing occurs as the input XML file |
|
|
|
is loaded: |
|
|
|
<ul> |
|
|
|
<li>Property references are resolved.</li> |
|
|
|
<li>The following attriubtes are treated differently: |
|
|
|
<ul> |
|
|
|
<li><b>id</b>: The property is associated with the given id value.</li> |
|
|
|
<li><b>location</b>: The property is treated as a file location</li> |
|
|
|
<li><b>refid</b>: The property is set to the value of the |
|
|
|
referenced property.</li> |
|
|
|
<li><b>value</b>: The property is set to the value indicated.</li> |
|
|
|
</ul> |
|
|
|
</li> |
|
|
|
<li><a href="../using.html#path">Path-like Structures</a> can be defined |
|
|
|
by use of the following attributes: |
|
|
|
<ul> |
|
|
|
<li><b>pathid</b>: The given id is used to identify a path. The |
|
|
|
nested XML tag name is ignored. Child elements can be used |
|
|
|
(XML tag names are ignored) to identify elements of the path.</li> |
|
|
|
</ul> |
|
|
|
</li> |
|
|
|
</ul> |
|
|
|
<p> |
|
|
|
For example, with semantic attribute processing enabled, this XML property |
|
|
|
file: |
|
|
|
<pre> |
|
|
|
<root> |
|
|
|
<properties> |
|
|
|
<foo location="bar"/> |
|
|
|
<quux>${root.properties.foo}</quux> |
|
|
|
</properties> |
|
|
|
</root> |
|
|
|
</pre> |
|
|
|
is roughly equivalent to the following fragments in a build.xml file: |
|
|
|
<pre> |
|
|
|
<property name="root.properties.foo" location="bar"/> |
|
|
|
<property name="root.properties.quux" value="${root.properties.foo}"/> |
|
|
|
</pre> |
|
|
|
|
|
|
|
</p> |
|
|
|
|
|
|
|
<h3>Parameters</h3> |
|
|
@@ -31,29 +92,51 @@ Loads property values from a valid xml file. |
|
|
|
</tr> |
|
|
|
<tr> |
|
|
|
<td valign="top">keepRoot</td> |
|
|
|
<td valign="top">If false, it doesn't include the xml root tag as a first |
|
|
|
value in the property name.</td> |
|
|
|
<td valign="top">Keep the xml root tag as the |
|
|
|
first value in the property name.</td> |
|
|
|
<td valign="top" align="center">No, default is <i>true</i>.</td> |
|
|
|
</tr> |
|
|
|
<tr> |
|
|
|
<td valign="top">validate</td> |
|
|
|
<td valign="top">If true, it enables validation.</td> |
|
|
|
<td valign="top">Validate the input file.</td> |
|
|
|
<td valign="top" align="center">No, default is <i>false</i>.</td> |
|
|
|
</tr> |
|
|
|
<tr> |
|
|
|
<td valign="top">collapseAttributes</td> |
|
|
|
<td valign="top">If true, it treats attributes as nested elements.</td> |
|
|
|
<td valign="top">Treat attributes as nested elements.</td> |
|
|
|
<td valign="top" align="center">No, default is <i>false</i>.</td> |
|
|
|
</tr> |
|
|
|
<tr> |
|
|
|
<td valign="top">semanticAttributes</td> |
|
|
|
<td valign="top">Enable special handling of certain attribute names. |
|
|
|
See the <a href="#semanticAttributes">Semantic Attributes</a> |
|
|
|
section for more information.</td> |
|
|
|
<td valign="top" align="center">No, default is <i>false</i>.</td> |
|
|
|
</tr> |
|
|
|
<tr> |
|
|
|
<td valign="top">includeSemanticAttribute</td> |
|
|
|
<td valign="top">Include the semantic attribute name |
|
|
|
as part of the property name. Ignored if |
|
|
|
<i>semanticAttributes</i> is not set to <i>true</i>. |
|
|
|
See the <a href="#semanticAttributes">Semantic Attributes</a> |
|
|
|
section for more information.</td> |
|
|
|
<td valign="top" align="center">No, default is <i>false</i>.</td> |
|
|
|
</tr> |
|
|
|
<tr> |
|
|
|
<td valign="top">rootDirectory</td> |
|
|
|
<td valign="top">The directory to use for resolving file references. Ignored |
|
|
|
if <i>semanticAttributes</i> is not set to <i>true</i>.</td> |
|
|
|
<td valign="top" align="center">No, default is <i>${basedir}</i>.</td> |
|
|
|
</tr> |
|
|
|
</table> |
|
|
|
|
|
|
|
|
|
|
|
<a name="examples"> |
|
|
|
<h3>Examples</h3> |
|
|
|
<pre> <xmlproperty file="somefile.xml" /></pre> |
|
|
|
</a> |
|
|
|
|
|
|
|
<h4>Non-semantic Attributes</h4> |
|
|
|
|
|
|
|
<p>Load contents of somefile.xml as Ant properties, |
|
|
|
generating the property names from the |
|
|
|
file's element and attribute names.</p> |
|
|
|
<p>Here is an example xml file that does not have any semantic attributes.</p> |
|
|
|
|
|
|
|
<pre> |
|
|
|
<root-tag myattr="true"> |
|
|
@@ -62,28 +145,110 @@ file's element and attribute names.</p> |
|
|
|
</root-tag> |
|
|
|
</pre> |
|
|
|
|
|
|
|
<p>This is an example xml file.</p> |
|
|
|
|
|
|
|
<pre> root-tag(myattr)=true |
|
|
|
<h5>default loading</h5> |
|
|
|
<p>This entry in a build file: |
|
|
|
<pre> <xmlproperty file="somefile.xml" /></pre> |
|
|
|
is equivalent to the following properties: |
|
|
|
<pre> |
|
|
|
root-tag(myattr)=true |
|
|
|
root-tag.inner-tag=Text |
|
|
|
root-tag.inner-tag(someattr)=val |
|
|
|
root-tag.a2.a3.a4=false |
|
|
|
</pre> |
|
|
|
|
|
|
|
<p>These are the properties loaded by this task from the previous example file.</p> |
|
|
|
|
|
|
|
<h5>collapseAttributes=false</h5> |
|
|
|
<p>This entry in a build file: |
|
|
|
<pre> <xmlproperty file="somefile.xml" collapseAttributes="true"/></pre> |
|
|
|
|
|
|
|
<p>Load contents of somefile.xml as Ant properties collapsing attributes as nodes.</p> |
|
|
|
|
|
|
|
<pre> root-tag.myattr=true |
|
|
|
is equivalent to the following properties: |
|
|
|
<pre> |
|
|
|
root-tag.myattr=true |
|
|
|
root-tag.inner-tag=Text |
|
|
|
root-tag.inner-tag.someatt=val |
|
|
|
root-tag.a2.a3.a4=false |
|
|
|
</pre> |
|
|
|
|
|
|
|
<p>These are the properties loaded by this task from the previous example file, with |
|
|
|
attribute collapsing true.</p> |
|
|
|
<h5>keepRoot=false</h5> |
|
|
|
<p>This entry in a build file: |
|
|
|
<pre> <xmlproperty file="somefile.xml" keepRoot="false"/></pre> |
|
|
|
is equivalent to the following properties: |
|
|
|
<pre> |
|
|
|
inner-tag=Text |
|
|
|
inner-tag(someattr)=val |
|
|
|
a2.a3.a4=false |
|
|
|
</pre> |
|
|
|
|
|
|
|
<h4>Semantic Attributes</h4> |
|
|
|
|
|
|
|
<p>Here is an example xml file that has semantic attributes.</p> |
|
|
|
<pre> |
|
|
|
<root-tag> |
|
|
|
<version value="0.0.1"/> |
|
|
|
<build folder="build"> |
|
|
|
<classes id="build.classes" location="${build.folder}/classes"/> |
|
|
|
<reference refid="build.classes"/> |
|
|
|
</build> |
|
|
|
<compile> |
|
|
|
<classpath pathid="compile.classpath"> |
|
|
|
<pathelement location="${build.classes}"/> |
|
|
|
</classpath> |
|
|
|
</compile> |
|
|
|
<run-time> |
|
|
|
<jars>*.jar</jars> |
|
|
|
<classpath pathid="run-time.classpath"> |
|
|
|
<path refid="compile.classpath"/> |
|
|
|
<pathelement path="${run-time.jars}"/> |
|
|
|
</classpath> |
|
|
|
</run-time> |
|
|
|
</root-tag> |
|
|
|
</pre> |
|
|
|
|
|
|
|
<h5>default loading (semanticAttributes=true)</h5> |
|
|
|
<p>This entry in a build file: |
|
|
|
<pre> <xmlproperty file="somefile.xml" |
|
|
|
semanticAttributes="true"/></pre> |
|
|
|
is equivalent to the following entries in a build file: |
|
|
|
<pre> |
|
|
|
<property name="version" value="0.0.1"/> |
|
|
|
<property name="build.folder" value="build"/> |
|
|
|
<property name="build.classes" location="${build.folder}/classes" id="build.classes"/> |
|
|
|
<property name="build.reference" refid="build.classes"/> |
|
|
|
|
|
|
|
<property name="run-time.jars" value="*.jar/> |
|
|
|
|
|
|
|
<classpath id="compile.classpath"> |
|
|
|
<pathelement location="${build.classes}"/> |
|
|
|
</classpath> |
|
|
|
|
|
|
|
<classpath id="run-time.classpath"> |
|
|
|
<path refid="compile.classpath"/> |
|
|
|
<pathelement path="${run-time.jars}"/> |
|
|
|
</classpath> |
|
|
|
</pre> |
|
|
|
|
|
|
|
<h5>includeSemanticAttribute="true"</h5> |
|
|
|
<p>This entry in a build file: |
|
|
|
<pre> <xmlproperty file="somefile.xml" |
|
|
|
semanticAttributes="true" |
|
|
|
includeSemanticAttribute="true"/> |
|
|
|
</pre> |
|
|
|
is equivalent to the following entries in a build file: |
|
|
|
<pre> |
|
|
|
<property name="version.value" value="0.0.1"/> |
|
|
|
<property name="build.folder" value="build"/> |
|
|
|
<property name="build.classes.location" location="${build.folder}/classes"/> |
|
|
|
<property name="build.reference.refid" refid="build.location"/> |
|
|
|
|
|
|
|
<property name="run-time.jars" value="*.jar/> |
|
|
|
|
|
|
|
<classpath id="compile.classpath"> |
|
|
|
<pathelement location="${build.classes}"/> |
|
|
|
</classpath> |
|
|
|
|
|
|
|
<classpath id="run-time.classpath"> |
|
|
|
<path refid="compile.classpath"/> |
|
|
|
<pathelement path="${run-time.jars}"/> |
|
|
|
</classpath> |
|
|
|
</pre> |
|
|
|
|
|
|
|
<hr/> |
|
|
|
|
|
|
|