FAQ

[Ant-user] Ant xmlproperty question

Gilbert Rebhan
Feb 26, 2010 at 7:55 pm

-------- Original Message --------
Subject: Re: Ant xmlproperty question
From: canadatom <tomoodesign@gmail.com>
To: user@ant.apache.org
Date: 26.02.2010 15:43


thanks for reply, I used xmlproperty, now I am trying to extract url from
psf.project.reference

<psf>
<project reference="v1.0,http://blahblahblah1,desc1"/>
<project reference="v1.1,http://blahblahblah2,desc2"/>
<project reference="v1.2,http://blahblahblah3,desc3"/>
</psf>

<for list="${psf.project.reference}" param="ref">
<sequential>
<propertyregex property="url" input="@{ref}"
regexp="(http)(.*)" select="\0"/>
<echo>${url}</echo>
</sequential>
</for>
The above code doesn't work properly, please advice. Is there a better way
to do it?
i would use the xmltask [1] (recommended for xml related stuff),
combined with xpath [2] =


<?xml version="1.0" encoding="UTF-8"?>
<project>
<!-- Import XMLTask -->
<taskdef name="xmltask"
classname="com.oopsconsultancy.xmltask.ant.XmlTask"/>

<target name="depends">
<xmltask source="./example.xml">
<regexp path="//@reference" pattern=".+,(h.+),.+" replace="$1"/>
<copy path="//@reference" append="true" property="foobar"
propertyseparator="${line.separator}"/>
</xmltask>
</target>

<target name="main" depends="depends">
<echo>$${foobar} = ${line.separator}${foobar}</echo>
</target>
</project>


Buildfile: /home/ant/foo.xml
depends:
[xmltask] Cannot append values to properties
[xmltask] Cannot append values to properties
[xmltask] Cannot append values to properties
main:
[echo] ${foobar} =
[echo] http://blahblahblah1
[echo] http://blahblahblah2
[echo] http://blahblahblah3
BUILD SUCCESSFUL
Total time: 388 milliseconds


the message "Cannot append values to properties"
is a bit annoying but you may simply ignore it, i don't know
how to get rid of it


[1] http://www.oopsconsultancy.com/software/xmltask/
[2] http://www.zvon.org/xxl/XPathTutorial/General/examples.html



Regards, Gilbert





---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
reply

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions