ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Stevens <>
Subject Re: run XSLT on filelist
Date Thu, 31 May 2012 08:56:06 GMT
Hi Mark,

On 29/05/12 23:37, Mark Giffin wrote:
> I'm making a single PDF out of a group of XML documentation files. 
> It's an API reference document and the items will be alphabetized so 
> input order doesn't matter.
> I want to use a fileset of XML files as input to an XSLT script, 
> something like this:
> <fileset dir="${src.dir}" id="">
> <include name="*.xml"/>
> </fileset>
> I have been accomplishing this in the past with a manually-maintained 
> XML file like this:
> <docroot>
> <root href="myfile1.xml" />
> <root href="myfile2.xml" />
> <root href="myfile3.xml" />
> <root href="myfile4.xml" />
> <!-- etc. -->
> </root>
> Right now I pass in the file above to the XSLT processor like this:
> <target name="xslt-fo" description="XML to XSL-FO">
> <echo>Output FO...</echo>
> <java jar="${jar.saxon}" fork="true" failonerror="true" maxmemory="256m">
> <arg line="-w2"/>
> <!-- output filename -->
> <arg line="-o"/>
> <!-- list of input xml files -->
> <arg value="..\all-docs.xml"/>
> <!-- XSLT stylesheet to make XSL-FO -->
> <arg value="${}"/>
> </java>
> </target>
> But I'd like to automate it. Is there a way to pass in a fileset instead?

I did something a bit like this recently.  How about

<path id="">
<fileset refid=""/>
<property name="" refid=""/>
<xslt in="${basedir}/build.xml" out="" style="${} 
<param name="files" expression="${}"/>
<param name="pathseparator" expression="${path.separator}"/>

or whatever your saxon equivalent is.  Actually, it's possible to have 
<xslt> use saxon as its processor, but I don't know offhand how to 
configure things for that.
The in="${basedir}/build.xml" is just to give it something to trigger 
the root xsl:template, the XSLT can then use the supplied xsl:param 
values to tokenise the path, loop over the individual files and load 
them with document() for processing (I'm guessing you currently do 
something similar with your <root> entries).
The force="true" is because the build.xml rarely changes, so by default 
the template wouldn't be re-run when the XML files change.  You'll 
probably want to combine it with an <uptodate> check on the fileset & 
XSLT file, though, to avoid running it again when the XML files haven't 

Hope this helps,

Raising money for leukaemia research

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

View raw message