ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Reilly <peterrei...@apache.org>
Subject Re: Executing for all elements in an xml document...
Date Thu, 09 Sep 2004 16:56:26 GMT
Attached is an xpath iterator (compile with java SE 5.0) that can be used
with ant-contribs's for task as follows:

<project default="compile" xmlns:ac="antlib:net.sf.antcontrib">
  <target name="compile">
    <mkdir dir="classes"/>
    <javac srcdir="src" destdir="classes"/>
  </target>
  <target name="test" depends="compile">
    <typedef name="xpathiter" classname="XPathIterator"
             classpath="classes"/>

    <ac:for param="item">
      <xpathiter expression="/files/file/text()"
                 file="files.xml" trim="true"/>
      <sequential>
        <echo>Widget is @{item}</echo>
      </sequential>
    </ac:for>

  </target>
</project>

Alan J. Zall wrote:

>Any thoughts on this?
>
>-----Original Message-----
>From: Alan J. Zall [mailto:alan@xcipio.com] 
>Sent: Friday, August 27, 2004 5:07 PM
>To: 'Ant Users List'
>Subject: Executing for all elements in an xml document...
>
>	We have a nightly pull procedure that connects to a remote server
>via https with basic authentication and performs a <get> to retrieve a one
>file at a time. The owners of the remote server have set up the server so
>that when I submit to the root directory an xml representation of the
>directory is returned. 
>	My challenge is to perform a series of tasks on each of the files
>listed. Currently I have a list of the files hard-coded in a property that I
>iterate through. I would like to iterate based on the elements in the xml
>document. Is this possible?
>
>Here is the modified result of the directory listing
>
><files>
>	<file id="1">file1.DAT.zip</file>
>	<file id="2">file2.DAT.zip</file>
></files>
>
>Here is the hard coded property file that I use:
>
>agenciesList= file1.DAT.zip, file2.DAT.zip
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>
>
>  
>


Mime
View raw message