Return-Path:
-Loads property values from a valid xml file.
+Loads property values from a valid xml file. This XML property file:
+
+By default, this load
+does no processing of the input. In particular, unlike the
+Property task, property references
+(i.e., ${foo}) are not resolved.
+
+
+
+For example, with semantic attribute processing enabled, this XML property
+file:
+XmlProperty
Description
+ <root>
+ <properties>
+ <foo>bar</foo>
+ </properties>
+ </root>
+
+is roughly equivalent to this java property file:
+
+ root.properties.foo = bar
+
+
+Semantic Attributes
+
+Input processing can be enabled by using the semanticAttributes
+attribute. If this attribute is set to true (its default is
+false), the following processing occurs as the input XML file
+is loaded:
+
+
+
+
+
+
+
+ <root>
+ <properties>
+ <foo location="bar"/>
+ <quux>${root.properties.foo}</quux>
+ </properties>
+ </root>
+
+is roughly equivalent to the following fragments in a build.xml file:
+
+ <property name="root.properties.foo" location="bar"/>
+ <property name="root.properties.quux" value="${root.properties.foo}"/>
+
+
<xmlproperty file="somefile.xml" />+ + +
Load contents of somefile.xml as Ant properties, -generating the property names from the -file's element and attribute names.
+Here is an example xml file that does not have any semantic attributes.
<root-tag myattr="true"> @@ -62,28 +145,110 @@ </root-tag>-
This is an example xml file.
- -root-tag(myattr)=true +default loading
+This entry in a build file: +
<xmlproperty file="somefile.xml" />+is equivalent to the following properties: ++ 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.
- +collapseAttributes=false
+This entry in a build file:
<xmlproperty file="somefile.xml" collapseAttributes="true"/>- -Load contents of somefile.xml as Ant properties collapsing attributes as nodes.
- -root-tag.myattr=true +is equivalent to the following properties: ++ 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.
+keepRoot=false
+This entry in a build file: +
<xmlproperty file="somefile.xml" keepRoot="false"/>+is equivalent to the following properties: ++ inner-tag=Text + inner-tag(someattr)=val + a2.a3.a4=false ++ +Semantic Attributes
+ +Here is an example xml file that has semantic attributes.
++ <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> ++ +default loading (semanticAttributes=true)
+This entry in a build file: +
<xmlproperty file="somefile.xml" + semanticAttributes="true"/>+is equivalent to the following entries in a build file: ++ <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> ++ +includeSemanticAttribute="true"
+This entry in a build file: +
<xmlproperty file="somefile.xml" + semanticAttributes="true" + includeSemanticAttribute="true"/> ++is equivalent to the following entries in a build file: ++ <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> +
1.1 jakarta-ant/src/etc/testcases/taskdefs/xmlproperty/goldfiles/keeproot-collapse-original.properties Index: keeproot-collapse-original.properties =================================================================== root-tag.myattr=true root-tag.inner-tag=Text root-tag.inner-tag.someattr=val root-tag.a2.a3.a4=false 1.1 jakarta-ant/src/etc/testcases/taskdefs/xmlproperty/goldfiles/keeproot-nocollapse-original.properties Index: keeproot-nocollapse-original.properties =================================================================== root-tag(myattr)=true root-tag.inner-tag=Text root-tag.inner-tag(someattr)=val root-tag.a2.a3.a4=false 1.1 jakarta-ant/src/etc/testcases/taskdefs/xmlproperty/goldfiles/nokeeproot-collapse-original.properties Index: nokeeproot-collapse-original.properties =================================================================== inner-tag=Text inner-tag.someattr=val a2.a3.a4=false 1.1 jakarta-ant/src/etc/testcases/taskdefs/xmlproperty/goldfiles/nokeeproot-nocollapse-original.properties Index: nokeeproot-nocollapse-original.properties =================================================================== inner-tag=Text inner-tag(someattr)=val a2.a3.a4=false 1.2 +5 -0 jakarta-ant/src/etc/testcases/taskdefs/xmlproperty/inputs/override.xml Index: override.xml =================================================================== RCS file: /home/cvs/jakarta-ant/src/etc/testcases/taskdefs/xmlproperty/inputs/override.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- override.xml 5 Nov 2002 14:51:52 -0000 1.1 +++ override.xml 6 Nov 2002 08:43:45 -0000 1.2 @@ -1,5 +1,10 @@1.1 jakarta-ant/src/etc/testcases/taskdefs/xmlproperty/inputs/original.xml Index: original.xml =================================================================== + 1.9 +20 -9 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java Index: XmlProperty.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- XmlProperty.java 5 Nov 2002 14:51:52 -0000 1.8 +++ XmlProperty.java 6 Nov 2002 08:43:45 -0000 1.9 @@ -113,7 +113,7 @@ * * Text false Optionally, to more closely mirror the abilities of the Property * task, a selected set of attributes can be treated specially. To - * enable this behavior, the "semanticAttribute" property of this task + * enable this behavior, the "semanticAttributes" property of this task * must be set to true (it defaults to false). If this attribute is * specified, the following attributes take on special meaning * (setting this to true implicitly sets collapseAttributes to true as @@ -133,9 +133,10 @@ * *
* <root-tag> - * <build location="build"> - * <classes id="build.classes" location="${build.location}/classes"/> - * <reference refid="build.location"/> + * <build> + * <build folder="build"> + * <classes id="build.classes" location="${build.folder}/classes"/> + * <reference refid="build.classes"/> * </build> * <compile> * <classpath pathid="compile.classpath"> @@ -155,9 +156,9 @@ *is equivalent to the following entries in a build file:
* *- * <property name="build.location" location="build"/> - * <property name="build.classes.location" location="${build.location}/classes"/> - * <property name="build.reference" refid="build.location"/> + * <property name="build" location="build"/> + * <property name="build.classes" location="${build.location}/classes"/> + * <property name="build.reference" refid="build.classes"/> * * <property name="run-time.jars" value="*.jar/> * @@ -193,13 +194,13 @@ *