ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ckn...@onebox.com
Subject XSLT default parameters and Ant-supplied parameters conflict
Date Wed, 12 Jul 2006 17:58:12 GMT
How can I set up my build.xml file to pass Ant command-line parameters to an XSLT stylesheet
without clobbering the default values defined in the stylesheet in case a command-line parameter
is not supplied?

I have an Ant task that performs an XSLT transformation. In the stylesheet I have defined
four parameters with default values. From time to time it may be necessary to provide alternate
values for one or more of these parameters, so I have set up my build.xml file like this (relevant
section only).


<project name="hiring-reports" default="gen-report" basedir="." xmlns:ora="antlib:net.sf.incanto">

	<property name="sql.dir" value="./plsql" />
	<property name="xml.dir" value="./xml" />
	<property name="xslt.dir" value="./xslt" />
	<property name="rpts.dir" value="./rpts" />
	<property name="weekly.start.date" value="" />
	<property name="weekly.end.date" value="" />
	<property name="cumulative.start.date" value="" />
	<property name="cumulative.end.date" value="" />


<task>
  <style
     style="${xslt.dir}/@{stylesheet}"
     in = "${xml.dir}/@{infile}"
     out="${rpts.dir}/@{outfile}" processor="trax">

     <param name="weekly-end-date" expression="${weekly.end.date}"/>
     <param name="weekly-start-date" expression="${weekly.start.date}"/>
     <param name="cumulative-end-date" expression="${cumulative.end.date}"/>
     <param name="cumulative-start-date" expression="${cumulative.start.date}"/>
  </style>
</task>


When I supply command-line parameter name and value to Ant for any of these <param>
elements, the values are passed through to the stylesheet.

On the other hand, if I fail to provide a command-line parameter name and value, Ant "seems"
to supply an empty string as the value to the stylesheet parameter. My stylesheet then replaces
the default value defined there with the empty string, causing my transformation to fail.
-- 
Charles Knell
cknell@onebox.com - email

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message