This is a piece of my xslt 2.0 file:
<xsl:template match="test-one">
<xsl:apply-templates select="document('../test.xml')//class"/>
</xsl:template>
As it is seen path ../test.xml
is hard coded. Now I want to pass path as parameter using xml-maven-plugin. So I do:
<transformationSet>
<dir>src/test/resources</dir>
<includes>foo.xml</includes>
<stylesheet>xslfile.xsl</stylesheet>
<parameters>
<parameter>
<name>path</name>
<value>../test.xml</value>
</parameter>
</parameters>
<outputDir>${project.build.directory}/test-classes/META-INF</outputDir>
</transformationSet>
However, I can't understand how to add this path to xslt file. I tried:
<xsl:template match="test-one">
<xsl:apply-templates select="document('$path')//class"/>
</xsl:template>
But it didn't work. Could anyone say how to do it?
For XSLT, to use external parameters, you need to declare them at the top level, i.e. as children of xsl:stylesheet
or xsl:transform
: <xsl:param name="path"/>
.