ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Fuller <>
Subject Re: Converting new or changed files with an batch file called from within ant
Date Tue, 12 Apr 2005 08:29:45 GMT
Huditsch Roman wrote:

>Hi list,
>Although I search the archives, I could not find any useful hint for my problem.
>I recently started using ant for controlling my XSLT transformations.
>Actually, I need ant to take control over the execution of the appropriate batch file
for a given target.
>These target-specific batch-files are handling my stylesheet calls using Saxon.
>So far, everything works fine.
>The proplem is taht everytime I start the transformation, all files of my input folder
are converted.
>I would like ant to just produce new or changed files (since the last transformation call).
>the source folder is specified within my batch file, so I am nor sure if I need to rewrite
my ant and abtch files....
>Any help is greatly appreciated.
>My Ant file:
><?xml version="1.0" encoding="ISO-8859-1"?>
><project name="Content Produktion" default="GLP_Legislation" basedir=".">
>	<target name="GLP_Legislation" description="Normen, Verordnungen, Staatsverträge,...">
>		<exec dir="R:\Produktion\Legislations" executable="cmd">
>			<arg line="/c transform_legislations.bat"/>
>		</exec>
>	</target>

why not control Saxon directly from Ant ?

You can use the <xslt/> Ant task or use <java/> to invoke saxon...which
may or may not have the built in up to date checking you desire

the following is a macrodef which you can use to invoke Saxon as a task
using <java/>;

<macrodef name="saxon">
   <attribute name="current"/>
   <attribute name="src"/>
   <attribute name="dest"/>

    <mkdir dir="${dir.dist}/@{current}"/>

    <java classname="net.sf.saxon.Transform"

     <!-- these are just saxon specific switches, change as u see fit -->
      <arg value="-w1"/>     

     <arg value="-o"/>
     <arg value="@{dest}/@{current}"/>

         <arg value="-a"/>
         <arg value="@{src}/@{current}"/>
         <!-- examples of passing in parameters -->
         <arg value="lang=en"/>
         <arg value="usedublincore=yes"/>
         <arg value="client=web"/>
         <arg value="tstamp=${ts.DSTAMP}:${ts.TSTAMP}"/>

           <pathelement location="${jar.saxon}"/>



though I would suggest trying out the <xslt/> task first...this is a
good example of wrapping up a <java/> call and effectively making it a
new task to call;

you will need to supply the various properties, but to invoke this in
your Targets just do

<saxon current="" dest="" src=""/>


dest= top level dest dir
src= top level src dir
current= specific dir to process under src

it depends on exactly how you have decided to perform transformation to
use such things as <uptodate/>....need a little more info.

gl, Jim Fuller

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

View raw message