Quantcast
Channel: Gradle Forums - Latest posts
Viewing all articles
Browse latest Browse all 19854

How to pass XSLT params to ant.xslt() task?

$
0
0

Hi,

I am struggling with figuring out how to pass nested parameters to ant.xslt() task, which is done in Ant like this

<xslt basedir="doc" destdir="build/doc"
  extension=".html" style="style/apache.xsl">
    <param name="date" expression="07-01-2000"/>
</xslt>

so that those parameters could be referred to via xsl:param in XSLT itself.

Gradle documentation suggests that the proper way of passing nested elements is specifying them in a closure like this

task zip {
    doLast {
        ant.zip(destfile: 'archive.zip') {
            fileset(dir: 'src') {
                include(name: '**.xml')
                exclude(name: '**.java')
            }
        }
    }
}

This email topic suggests something similar, however it doesn’t seem to work for me as the closure gets invoked before the target XSLTProcess is actually created, moreover there is no such method as param() discovered anywhere in the current context.

task myReport << {
    ant.xslt() { p ->
        param(name: 'name', expression: 'expression') // doesn't work, also I've checked that p is null here
    }
}

So I’ve looked at the org.apache.tools.ant.taskdefs.XSLTProcess class in generated-gradle-jars and I can see that it’s got createParam() method, but I can’t wrap my head around how to call it, as ant.xslt() initiates that process and executes it right away and, as I mentioned above, the closure is invoked before XSLTProcess is instantiated.

Does anyone know how to solve this? Any help will be greatly appreciated.


Viewing all articles
Browse latest Browse all 19854

Trending Articles