What i'm trying to do here is to pass in the value of a variable as a parameter to an xsl:value-of's select attribute. (instead of just passing in a variable).
So I have a variable dataAlias where i set the value to be passed ($currentPage/data[@alias='someproperty'])
However, I haven't been able to figure out how actually pass in the value of $dataAlias.
The above code simply emits $currentPage/data[@alias='someproperty']. However, I would like the select attribute to work with the content of the variable and not just the variable.
Here's the full snippet.
Snippet
<xsl:paramname="currentPage"/><xsl:paramname="mostPopularProperty"/><xsl:variablename="dataAlias"> <xsl:text>$currentPage/data[@alias = '</xsl:text>$mostPopularProperty<xsl:text>']</xsl:text></xsl:variable><xsl:templatematch="/">
<!--Would like to substitute string($dataAlias) with it's value <xsl:variablename="content"> <xsl:value-ofselect="string($dataAlias)"disable-output-escaping="yes"/> </xsl:variable>
Sorry, for the repost, but here's the portion of the snippet( i wasn't able to edit the typo in the previous post)
<!--Would like to substitute string($dataAlias) with the value of $dataAlias--> <xsl:variablename="content"> <xsl:value-ofselect="string($dataAlias)"disable-output-escaping="yes"/> </xsl:variable>
Thanks for the links, but I don't think it'll fit the bill here because the values I want to swap in are obtained from the parameter. From what I saw, entities are used for swapping values with literal strings.(essentially, a way to write shorthand in xslt)
Get the value of a (value of a variable)
What i'm trying to do here is to pass in the value of a variable as a parameter to an xsl:value-of's select attribute. (instead of just passing in a variable).
So I have a variable dataAlias where i set the value to be passed ($currentPage/data[@alias='someproperty'])
However, I haven't been able to figure out how actually pass in the value of $dataAlias.
The above code simply emits $currentPage/data[@alias='someproperty']. However, I would like the select attribute to work with the content of the variable and not just the variable.
Here's the full snippet.
Snippet
Sorry, for the repost, but here's the portion of the snippet( i wasn't able to edit the typo in the previous post)
Hi Arviman
I don't think you can achieve what you're trying to do by using xsl:value-of.
However I think that the solution to your problem could maybe be to play around with entities.
Therefore I think you should have a look at Chriztian's articles on the subject.
http://pimpmyxslt.com/articles/entity-tricks-part1/
http://pimpmyxslt.com/articles/entity-tricks-part2/
I hope this helps...
/Jan
Hi Jan,
Thanks for the links, but I don't think it'll fit the bill here because the values I want to swap in are obtained from the parameter. From what I saw, entities are used for swapping values with literal strings.(essentially, a way to write shorthand in xslt)
Thanks,
Arviman
Never mind, i realized i had it right the first time around :-) The issue was with how i was reading the parameter :embarrassed:
Here's the simple solution.
Snippet
is working on a reply...