I’m working at a java application that performs some xslt transformation.
I would like to match nodes into the xslt document, using a parameter provided by java.
Which is the right way to do something like:
<xsl:template match="//m:properties/*[contains($pattern,name())]">
because when I launch my application, it claims it’s not able to compile the stylesheet, since pattern is not defined but I’m setting it using the setParameter method and I was able to use another parameter defined in the same way but in a different context.
Thanks in advance
Fil
You need an
in your stylesheet to declare the parameter, the
setParametercall is not sufficient on its own. However there is a further problem that, according to the XSLT 1.0 spec, match expressions are not allowed to contain variable/parameter references like$pattern. Some processors do permit them anyway (including at least some versions of Xalan), but if it doesn’t work then you need to change the matching logic, e.g. by defining the template to match//m:properties/*but then only callingapply-templatesfor those elements that match your pattern.