I tried following code and for me it works:

<target name="runall">
<foreach param="xmlfile" target="runone">
<path>
<fileset dir="xmlsources" includes="*.xml"/>
</path>
</foreach>
</target>

<target name="runone">
<basename property="myfile" file="${xmlfile}"/>
<echo message="doing ${myfile}"/>
<xslt in="xmlsources/${myfile}" out="output/${myfile}.html"
style="layout/simple.xsl">
<param name="filename" expression="${myfile}"/>
</xslt>
</target>

In this case the output filenames have extension .xml.html

I don't see an error in your code, maybe the processor ?
Don't mention a basedir because if you do not defined an "includes" attribute it reads all files from the basedir.

hope this could help.


From: "Cox, Charlie" <[EMAIL PROTECTED]>
Reply-To: "Ant Users List" <[EMAIL PROTECTED]>
To: 'Ant Users List' <[EMAIL PROTECTED]>
Subject: RE: xslt task with foreach
Date: Fri, 7 Feb 2003 10:03:31 -0500

yes, but I couldn't get it to translate my property instead of passing the
propertname in:

<xslt in="html/${baseName}" out="xsl/${baseName}" style="myxsl.xsl"
processor="trax">

this causes the filename to be passed as "$(baseName)" instead of resolving
the property.

Can I use a property for 'in' and 'out'?

thanks,
Charlie

> -----Original Message-----
> From: Java Burre [mailto:[EMAIL PROTECTED]]
> Sent: Friday, February 07, 2003 9:52 AM
> To: [EMAIL PROTECTED]
> Subject: Re: xslt task with foreach
>
>
> already tried with in and out attributes of xslt task ?
> Did not test it.
>
>
>
> >From: "Cox, Charlie" <[EMAIL PROTECTED]>
> >Reply-To: "Ant Users List" <[EMAIL PROTECTED]>
> >To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
> >Subject: xslt task with foreach
> >Date: Fri, 7 Feb 2003 08:25:19 -0500
> >
> >I'm having trouble getting this task to work. What I need is
> to run an xslt
> >task for each file in the directory and I need the filename
> to be passed as
> >a parameter to the xslt.
> >
> >This is what I have so far and it works for one file, but
> when I have many
> >files, the xslt task processes all the files passing in the
> name of the
> >first file to each one, then it tries to complete the
> foreach by running
> >the
> >xslt task for the rest, which does nothing since it already
> did them all.
> >
> ><target name="all">
> >	<foreach param="htmlFileName" target="convertXsl">
> >		<fileset dir="html" includes="*.htm"/>
> >	</foreach>
> ></target>
> >
> ><!-- process a given file. called by the 'all' target -->
> ><target name="convertXsl">
> >	<!-- get the name of the document without the path -->
> >	<basename file="${htmlFileName}" property="baseName"/>
> >	<echo message="processing....${baseName}"/>
> >	<!-- convert the style first -->
> >	<xslt basedir="html" destdir="xsl" extension=".xsl"
> >style="myxsl.xsl" processor="trax" >
> >		<param name="myFormName" expression="${baseName}"/>
> >		<xmlcatalog>
> >			<dtd publicId="-//W3C//DTD XHTML 1.0
> >Transitional//EN" location="xhtml.dtd"/>
> >		</xmlcatalog>
> >	</xslt>
> ></target>
> >
> >I tried adding includes="$(baseName)" for the xslt task,
> which caused it to
> >not process any files. Likewise for includes="$(htmlFileName)".
> >
> >how can I get the foreach to go through the list of files
> and the xslt to
> >process only the given file?
> >
> >thanks,
> >Charlie
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> _________________________________________________________________
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

_________________________________________________________________



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to