整形式なXMLファイルからプロパティ値を読み込みます。「整形式」以外の制約はありません。レイアウトは任意のものを選択できます。たとえば、次のXMLプロパティファイルは
<root>
<properties>
<foo>bar</foo>
</properties>
</root>
このJavaプロパティファイルと同等です
root.properties.foo = bar
既定では、この読み込みは入力の処理を行いません。特に、Propertyタスクとは異なり、プロパティ参照(つまり、${foo})は解決されません。
semanticAttributes属性を使用すると、入力処理を有効にできます。この属性がtrue
に設定されている場合(既定はfalse
)、入力XMLファイルが読み込まれると、次の処理が行われます。/p>
たとえば、セマンティック属性処理を有効にすると、次のXMLプロパティファイル
<root>
<properties>
<foo location="bar"/>
<quux>${root.properties.foo}</quux>
</properties>
</root>
は、build.xmlファイルの次のフラグメントと同等です
<property name="root.properties.foo" location="bar"/>
<property name="root.properties.quux" value="${root.properties.foo}"/>
| 属性 | 説明 | 必須 |
|---|---|---|
| file | 解析するXMLファイルです。 | はい、または入れ子のリソースコレクション |
| prefix | 各プロパティに先頭に付けるプレフィックスです。 | いいえ |
| keepRoot | XMLのルートタグをプロパティ名の最初の値として保持します。 | いいえ、既定はtrueです |
| validate | 入力ファイルを検証します(DTDなど)。それ以外の場合は、XMLは整形式である必要があります。 | いいえ、既定はfalseです |
| collapseAttributes | 属性を入れ子の要素として処理します。 | いいえ、既定はfalseです |
| semanticAttributes | 特定の属性名の特別な処理を有効にします。詳細は、意味属性セクションを参照してください。 | いいえ、既定はfalseです |
| includeSemanticAttribute | semanticAttributesがtrueに設定されていない場合は無視されます。詳細は、意味属性セクションを参照してください。 |
いいえ、既定はfalseです |
| rootDirectory | ファイル参照の解決に使用するディレクトリです。semanticAttributesがtrueに設定されていない場合は無視されます。 |
いいえ、既定はbasedirです |
| delimiter | 複数の値を分割するための区切り記号です。 Apache Ant 1.7.1以降 |
いいえ、既定は,(カンマ) |
<xmlcatalog>要素を使用して、エンティティの解決を実行します。
指定されたリソースは入力として使用されます。
意味属性を持たないXMLファイルの例を次に示します。
<root-tag myattr="true"> <inner-tag someattr="val">Text</inner-tag> <a2><a3><a4>false</a4></a3></a2> </root-tag>
ビルドファイル内のこのエントリ
<xmlproperty file="somefile.xml"/>
は、次のプロパティと同等です
root-tag(myattr)=true root-tag.inner-tag=Text root-tag.inner-tag(someattr)=val root-tag.a2.a3.a4=false
false
ビルドファイル内のこのエントリ
<xmlproperty file="somefile.xml" collapseAttributes="true"/>
は、次のプロパティと同等です
root-tag.myattr=true root-tag.inner-tag=Text root-tag.inner-tag.someatt=val root-tag.a2.a3.a4=false
false
ビルドファイル内のこのエントリ
<xmlproperty file="somefile.xml" keepRoot="false"/>
は、次のプロパティと同等です
inner-tag=Text inner-tag(someattr)=val a2.a3.a4=false
意味属性を持つXMLファイルの例を次に示します。
<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>
true)
ビルドファイル内のこのエントリ
<xmlproperty file="somefile.xml" keepRoot="false"
semanticAttributes="true"/>
は、ビルドファイル内の次のエントリと同等です
<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"/>
<path id="compile.classpath">
<pathelement location="${build.classes}"/>
</path>
<path id="run-time.classpath">
<path refid="compile.classpath"/>
<pathelement path="${run-time.jars}"/>
</path>
true
ビルドファイル内のこのエントリ
<xmlproperty file="somefile.xml"
semanticAttributes="true" keepRoot="false"
includeSemanticAttribute="true"/>
は、ビルドファイル内の次のエントリと同等です
<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.classes"/>
<property name="run-time.jars" value="*.jar"/>
<path id="compile.classpath">
<pathelement location="${build.classes}"/>
</path>
<path id="run-time.classpath">
<path refid="compile.classpath"/>
<pathelement path="${run-time.jars}"/>
</path>