I am using the below way to assign value to a variable.
<xsl:variable name="NewValue">
<xsl:value-of select="normalize-space(//root/id/amount)"/>
</xsl:variable>
After the assignment I want to assign new value to the same variable. Like this:-
<xsl:variable name="NewValue" select="normalize-space(//root/id/amountnew)">
Is there any way for this?
Here the sample of XML that I have:
<VolLien>
<Vest_DocType>SDD</Vest_DocType>
<Vest_Instrument>395072</Vest_Instrument>
<Vest_OfOfficialEntity>eee</Vest_OfOfficialEntity>
<Vest_RecDate>12/24/2009</Vest_RecDate>
<Vest_Grantee1>abc dd</Vest_Grantee1>
<Vest_Grantor1>sss</Vest_Grantor1>
<Vest_RejectCode />
<Vest_RejectReason />
<Vest_ImageNum> </Vest_ImageNum>
</VolLien>
My problem is I need to get latest <Vest_RecDate>
of particular <Vest_DocType>
(say SDD) And then I need to search across the xml any date which is before <Vest_RecDate>
of this(same SDD).
If then raise that particular section(<VolLien>
) alone and again latest. If I could have reassignment I would position of the node and get the values associated to that. Now I am doing this using another loop. If something is there I can avoid extrs loops.
Addition to Tomalak's answer.
A variable is limited/local to a block in which it is declared and assigned with value (declaration and assignment happen at once).
Suppose in example:
No. XSLT variables are read-only. They cannot be assigned multiple times.
XSLT is not an imperative programming language like, say, PHP. Reassigning variables is both impossible and unnecessary.
EDIT: According to your comment:
here is an XSLT snippet that can do this for you:
Further addition to previous answers: you're trying to solve some problem using low-level imperative techniques that you have learnt from other programming languages. To help you solve the problem using the declarative approach appropriate to XSLT, we will need a description of the problem. Make it as high level as possible - describe the output as a function of the input, rather than describing the computational steps you think are needed to get from one to the other.