Page 1 of 1

Ant task to transform all files in a folder

Posted: Thu Jun 26, 2014 11:54 pm
by martindholmes
I'm having trouble getting a fairly simple Ant task to work. I'm trying to run an XSLT transformation on all the files in a folder and output the results to another folder. This is what the relevant bit of the build file looks like at the moment:

Code: Select all


  <target name="poemsToHTML">
<echo>Create output for all poems in the anthology folder.</echo>
<xslt force="true" style="${pd}/xsl/poem.xsl" includes="${pd}/anthology" basedir="${pd}/xsl" destdir="${pd}/html" extension=".html" scanincludeddirectories="true">
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
<classpath location="${oxygenlib}/saxon9ee.jar"/>
</xslt>
</target>
I get this output in the console, but nothing is created:

Code: Select all

poemsToHTML:
[echo]Create output for all poems in the anthology folder.
[xslt] Transforming into /media/Data/mholmes/Documents/english/VictorianPoetryNetwork/svnrepo/html
According to how I read the Ant docs, this should scan the included directory (anthology) and process all of the files in it.

Can anyone see what I'm missing?

Re: Ant task to transform all files in a folder

Posted: Fri Jun 27, 2014 12:30 am
by martindholmes
Answering my own question, in case it helps someone else. I had to use a fileset:

Code: Select all


    <fileset id="anthologyFiles" dir="${pd}/anthology" includes="*.xml"></fileset>

<xslt force="true" style="${pd}/xsl/poem.xsl" destdir="${pd}/html" extension=".html" useImplicitFileset="false">
<fileset refid="anthologyFiles"/>
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
<classpath location="${oxygenlib}/saxon9ee.jar"/>
</xslt>

Re: Ant task to transform all files in a folder

Posted: Fri Jun 27, 2014 8:19 am
by Radu
Hi Martin,

Thanks for updating the post with a solution.

Regards,
Radu