ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jakob Fix <>
Subject xmltask problem
Date Wed, 21 Apr 2004 14:31:04 GMT

I am using xmltask (v1.10) from
and Ant 1.6.

xmltask allows to create and modify xml documents from inside an Ant task.  It
is neither a core nor optional Ant task, but very useful nevertheless.

My problem is the following:  I need to update a small XML document through an
auto-generated build file.  The XML document in question looks like this:

 <publication id="p1">...</publication>
 <publication id="p2">...</publication>

The build file is auto-generated, and it contains a property which holds the ID
value of the publication.  

The build file should have some way to find out whether a <publication> section
with this ID exists already in the XML file, and therefore it should execute
xmltask's <replace> command.  Otherwise, it should execute the <insert> command.

I thought initially that I could use the xmltask's <copy> command to verify
whether the ID exists, and if yes copy it into a regular Ant <property>, and
then have two targets deal with the modify/create actions, using
"if='property'".  However it seems, that I cannot do it this way:

<project basedir="." default="test-existence" name="xmltask-test">
 <taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask"/>
 <property name="pid" value="NOTGOOD"/>
 <target name="test-existence">
  <xmltask source="data/pub.xml">
   <copy path="/publications/publication[@id='p1']/@id" property="pid"/>

[echo] should display "p1", but shows "NOTGOOD".

Anybody understands what I'd like to do?  And better yet, has a way to do it?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message