XmlProperty

Description

Loads property values from a valid xml file.

Parameters

Attribute Description Required
file The XML file to parse. Yes
prefix The prefix to prepend to each property No
keepRoot If false, it doesn't include the xml root tag as a first value in the property name. No, default is true.
validate If true, it enables validation. No, default is false.
collapseAttributes If true, it treats attributes as nested elements. No, default is false.

Examples

   <xmlproperty file="somefile.xml" />

Load contents of somefile.xml as Ant properties, generating the property names from the file's element and attribute names.

 

   <root-tag myattr="true">

    <inner-tag someattr="val">Text</inner-tag>

    <a2><a3><a4>false</a4></a3></a2>

   </root-tag>

This is an example xml file.

   root-tag(myattr)=true

   root-tag.inner-tag=Text

   root-tag.inner-tag(someattr)=val

   root-tag.a2.a3.a4=false

These are the properties loaded by this task from the previous example file.

   <xmlproperty file="somefile.xml" collapseAttributes="true"/>

Load contents of somefile.xml as Ant properties collapsing attributes as nodes.

   root-tag.myattr=true

   root-tag.inner-tag=Text

   root-tag.inner-tag.someatt=val

   root-tag.a2.a3.a4=false

These are the properties loaded by this task from the previous example file, with attribute collapsing true.


Copyright © 2002 Apache Software Foundation. All rights Reserved.