I have
<xsl:for-each select="ancestor-or-self::*">
<xsl:variable name="expression" select="name()" ></xsl:variable>
</xsl:for-each>
below I have href and i want to set the value this expression variable in href #######
<a href="/myplan?expression={$expression}" class="deleteIcon">Delete</a>
I also tried with :
<a href="concat('/myplan?expression={',$expression)}" class="deleteIcon">Delete</a>
None of them worked.
Can Anybody help me out how to do that?
Basically my task is to find the expression for current node and send the expression for the same in href?
Adding More Info :
<br/><xsl:for-each select="ancestor-or-self::*">
<xsl:variable name="expression" select="name()" />
</xsl:for-each>
<b><a href="{concat('/admin/eapp/deleteQuestions?expression=',$expression)}"></a>Click Me</b>
when above xsl code is transformed it is giving below error:
Variable or parameter 'expression' is undefined.
Very simply, variables are scoped in XSL and exist only within the containing tag. Thus the variable named
expressionexists only within thefor-eachblock. Also, variables can only be set once. Attempting to set a variable value a second time has no effect.Therfore you have to declare the variable at or above the level where you want to use it, and put all the code to generate the value inside the variable declaration. If you can use XSLT2, the following will do what you want:
I know it can also be done in XSLT 1 with a recursive template, but I don’t have an example handy.