How to read previous-sibling variable value?
This is an open discussion with 3 replies, filed under XSLT.
Search
It's normal because each <td>
contains it's own context.
Define your variable in the second <td>
and it will live in that context:
<td> ... </td> <td> <xsl:variable name="minutes" select="substring-after(mytime, '.')"> <xsl:value select="$minutes" /> <!-- all good --> </td>
Thanks Vlad,
also, could it be possible to do something like this?
<xsl:for-each select="task"> <tr> <td><xsl:variable name="subtotal" select="fee" /></td> </tr> </xsl:for-each> <tr> <td><xsl:value-of select="sum($subtotal)"/></td> </tr>
sum($subtotal) returns 'subtotal is undeclared', for scope reasons I believe. Is there some way to make it anyway?
Thanks..
no not quite... that doesn't make much sense...
In XSL you can only define a variable once, also that would not output the fee in the td
, also the $subtotal
is contextual to your for-each so cannot be used outside...
What you need is something like this
<xsl:for-each select="task"> <tr> <td><xsl:value-of select="fee" /></td> </tr> </xsl:for-each> <tr> <td><xsl:value-of select="sum(task/fee)"/></td> </tr>
Create an account or sign in to comment.
I'm having troubles reading the content of a variable
Thanks..