Problem solve Get help with specific problems with your technologies, process and projects.

Insert an XSL variable into an XPath expression

I want to be able to declare an XSL variable, and then insert its value into an XPath expression like this:


However, this never works and I suspect the variable is being converted to a string, and what is expected by XPath is a nodeset. I have tried converting to a node-set first to get around this, but it doesn't work. I know I could use another language to do this, but I need to do it with XSLT for project-specific reasons. Is there any way to assign a value to a variable, and then embed that variable within an XPath or other expression?
This e-mail may answer your question:

Note the difference between:
<xsl:variable name="target" select="elementname"/>
<xsl:variable name="target" select="'elementname'"/>

Dig Deeper on Topics Archive

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.