I have a simple question. How do you combine a path from two template parameters? I would like to do something like that:
<xsl:template match="*[namespace-uri()='show:show']">
<xsl:param name="arg1"/>
<xsl:param name="arg2"/>
<tr>
<td>
<xsl:value-of select="concat($arg1,$arg2)"/>
</td>
</tr>
to get path like: arg1/arg2 but it doesn’t work. How can I do that properly?
or can you do sth like
<xsl:value-of select="path/path/$arg2"/>
?
arg1 is complete path from root and arg2 is single element name.
To build path expressions as strings and then evaluate them you need an extension function (at least in XSLT 1.0 and 2.0), there’s nothing in the core spec to support it but most processors provide a suitable function. The expression
would result in a string containing the string value of
arg1, a slash, and the string value ofarg2. But if arg1 is a node set and you restrict arg2 to be just an element name then you can do something like this(or
copy-ofas appropriate) and call the template likeIf you wanted to allow for arg2 to name an attribute rather than an element use
Or to allow it to be either (assuming the target of
arg1doesn’t have an attribute and a child element with the same name)