Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: XSLT for-each get previous item [Thread Next] Re: XSLT for-each get previous itemTo: NULL Date: 2/9/2009 7:49:00 PM * DustWolf:
> On 6 feb., 05:39, Mukul Gandhi <gandhi.mu...@gmail.com> wrote:
>> you should be able to do this by using a variable,
>>
>> <xsl:for-each select="/values/value">
>> Â <xsl:variable name="pos" select="position()" />
>> <item last="{/values/value[$pos-1]}" current="{.}" />
>> </xsl:for-each>
>>
>> This is not tested though.
>
> It works (interestingly, as I found answers all over the web
> specifically stating that this could not be done, e.g. that an XSLT
> variable is actually a constant which's value cannot be changed once
> defined),
actually, $pos *is* a constant. It just goes out of scope
at the end of each for-each iteration, and the next round's
$pos is a new one.
| Â <xsl:variable name="pos" select="$pos + 1" />
would not work, however.
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
