ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Giffin <m1...@earthlink.net>
Subject Re: run XSLT on filelist
Date Thu, 31 May 2012 20:26:58 GMT
Thanks Andy (and Harold in another post), I will check these out.

I use Saxon because I'm doing XSLT 2.0 and the ant default processor is 
XSLT 1.0. I know Saxon can be substituted, but I already had my setup 
running when I found that out. You're right Andy, I use document() to 
access the XML files in the hrefs. Using build.xml to trigger the root 
xsl:template is an interesting trick!

Mark

On 5/31/2012 1:56 AM, Andy Stevens wrote:
> 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="all.docs">
>> <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 output.fo"/>
>> <!-- list of input xml files -->
>> <arg value="..\all-docs.xml"/>
>> <!-- XSLT stylesheet to make XSL-FO -->
>> <arg value="${xslt.fo}"/>
>> </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="path.all.docs">
> <fileset refid="all.docs"/>
> </path>
> <property name="pathstring.all.docs" refid="path.all.docs"/>
> <xslt in="${basedir}/build.xml" out="output.fo" style="${xslt.fo} 
> force="true">
> <param name="files" expression="${pathstring.all.docs}"/>
> <param name="pathseparator" expression="${path.separator}"/>
> </xslt>
>
> 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 changed.
>
> Hope this helps,
>
>
> Andy.


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


Mime
View raw message