You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Alan J. Zall" <al...@xcipio.com> on 2004/08/27 23:07:11 UTC
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
RE: Executing for all elements in an xml document...
Posted by Victor Volle <v....@computer.org>.
Why not use a XSLTransformation to retrieve the necessary information in a
more Ant-friendly format?
Victor
Zitat von "Alan J. Zall" <al...@xcipio.com>:
> 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Executing for all elements in an xml document...
Posted by Peter Reilly <pe...@apache.org>.
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
>
>
>
>
>
RE: Executing for all elements in an xml document...
Posted by Bill Rich <bi...@attglobal.net>.
I use a similar XML file in one of my Ant files. I use a reg exp to extract
the relevant info from each <file> line. I put the relevant info into a
semi-colon delimited property then use that later in the Ant file for
further processing.
Here is the target I use for reading the XML file, selecting the
translatable files from the list, and making the projXLFileList property.
<target name="loadprojxlfilelist" depends="init">
<loadfile property="projXLFileList" srcFile="${PROJECTFILE}">
<filterchain>
<tokenfilter delimOutput=";">
<ignoreblank/>
<containsregex
pattern=".*<file.*type="([^"]*)".*translate="XL"
.*inputname="([^"]*)".*outputname="([^"]*)".*"
flags="is" replace="/type "\1" /inputname "\2"
/outputname "\3""/>
</tokenfilter>
</filterchain>
</loadfile>
</target>
You should be able to modify the reg exp to do what you want in your
particular file. You can also change the delimiter to a comma if you want.
Bill Rich
Wilandra Consulting LLC
1325 Addiewell Place
San Jose, CA 95120-3905
phone: +1 408 268-2452
mobile: +1 408 410-9713
Santa Cruz: +1 831 464-9007
fax: +1 413 669-9716
bill@wilandra.com
http://www.wilandra.com
-----Original Message-----
From: Brian Agnew [mailto:brian@oopsconsultancy.com]
Sent: Thursday, September 09, 2004 8:11 AM
To: Ant Users List
Subject: Re: Executing for all elements in an xml document...
Have a look at xmltask. This can execute ant targets for nodes in a given
xml file. Which looks like exactly what you need.
http://www.oopsconsultancy.com/software/xmltask
Brian
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
---------------------------------------------------------------------
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
Re: Executing for all elements in an xml document...
Posted by Brian Agnew <br...@oopsconsultancy.com>.
Have a look at xmltask. This can execute ant targets for nodes in a
given xml file. Which looks like exactly what you need.
http://www.oopsconsultancy.com/software/xmltask
Brian
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
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
RE: Executing for all elements in an xml document...
Posted by "Alan J. Zall" <al...@xcipio.com>.
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
Re: Executing for all elements in an xml document...
Posted by Matt Benson <gu...@yahoo.com>.
For each file listed in the XML structure you want to
perform a series of operations: store the remote file
locally using <get>, then do some arbitrary
processing, correct? Without knowing much about XSLT,
you might use that or some home-brewed means (custom
Task) of converting the XML to a list like you are
already using. You might experiment with making the
conversion using regular expressions, perhaps with
AC's <propertyregexp>. It might take a true regexp
guru, but I think it may be possible.
-Matt
--- "Alan J. Zall" <al...@xcipio.com> wrote:
> 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
>
>
_______________________________
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
http://promotions.yahoo.com/goldrush
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org