I have an xsl:param that I’m trying to use to do a template match on an attribute. By everything I’ve found here and on the Internet, I’m doing this correctly. However, my output is blank.
Here is my xslt
<xsl:param name="strm_name">main</xsl:param>
<xsl:template match="stream[@name='{$strm_name}']"></xsl:template>
If I hardcode the param call to “main”, this works just fine.
Here is the XML tag I’m trying to match to..
<doc><stream name="main"></stream></doc>
Any help is much appreciated!
I see two issues:
'{...}'when referencing your parameter in the predicate. (You’re probably confusing this with an Attribute Value Template.) Use this instead:stream[@name=$strm_name]A possible workaround for issue #1 is to select only those elements that meet the criteria controlled by your param. (You can reference a param in a select expression).
For example, this stylesheet:
Applied to this document:
…matches only the desired nodes. Output: