XSLT select question
This is an open discussion with 2 replies, filed under XSLT.
Search
An XPath expression doesn’t support this natively — you can’t dynamically build a node name like that. However what you can do is find a node where the name equals a particular string:
<xsl:value-of select="*[name() = concat($current-language,'-job-title')]"/>
This will look for any direct child node (wildcard *
) in the current scope where (using a predicate [...]
) its node name (name()
is an XPath function) equal to a string. The XSLT concat()
function allows you to join strings together — you can have as many as you like inside the function, separated by commas.
Works like a charm. Thanks very much nick :)
Create an account or sign in to comment.
I’m trying to select an element using a variable for part of the selector. Here’s an example:
What I’m trying to select:
I’m trying to use my $current-language variable to select the appropriate element, but I need a way of telling XSLT that the variable is finished. Here’s my current code:
Is there any way to put like a delimiter in there to tell it where the variable ends? eg: