You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Huditsch Roman <Ro...@lexisnexis.at> on 2005/04/12 10:16:46 UTC
Converting new or changed files with an batch file called from within ant
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>
</project>
One of my batch files:
================
@echo off
set JAVA_HOME=R:\Produktion\Tools\jdk1.5.0_01;
set PATH=.;R:\Produktion\Tools\jdk1.5.0_01\bin;
mkdir added
java net.sf.saxon.Transform -o added/ source/ stylesheets/add_versioning_information.xslt
echo Adding version information done
mkdir splitted
java net.sf.saxon.Transform -o splitted/ added/ stylesheets/split_legislation.xslt
rd /S /Q added
echo Splitting done
java net.sf.saxon.Transform -o result/ normalized/ stylesheets/convert_to_LNDE.xslt
rd /S /Q normalized
echo Conversion finished
echo ===================
echo ==============================
echo Process finished successfully
echo ==============================
wbr,
Roman
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Converting new or changed files with an batch file called from
within ant
Posted by James Fuller <ji...@ruminate.co.uk>.
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>
></project>
>
>
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"/>
<sequential>
<mkdir dir="${dir.dist}/@{current}"/>
<java classname="net.sf.saxon.Transform"
fork="true"
failonerror="false"
maxmemory="256m">
<!-- 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}"/>
<classpath>
<pathelement location="${jar.saxon}"/>
</classpath>
</java>
</sequential>
</macrodef>
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=""/>
where;
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: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org