variables - Increment a value in XSLT -
I'm quite new to xlst and if there is any way to store a value and change it later, For example, enlarging a variable in a loop
I'm a little amazed because I have not been able to change the value of a set after the set, I do not understand, making it more of a constant .
For example, I want to do something like this:
& lt; Xsl: variable name = "i" = "0" /> & Lt; Xsl: each selection = "data / post / entry" & gt; & Lt; Xsl: variable name = "i" = "$ i + 1" /> & Lt ;! - Do something - & gt; & Lt; / XSL: for-each & gt;
If someone can understand about this, is there an alternative way of doing this thanks
XSLT is a functional language and among other things it means that are temporary in XSLT and once defined they They can not be of value
& lt; Xsl: stylesheet version = "1.0" xmlns: How can the same effect be achieved in XSLT & Lt; Xsl: strip-space element = "*" /> & Lt; Xsl: template match = "/" & gt; & Lt; Posts & gt; & Lt; Xsl: each selection = "data / post / entry" & gt; & Lt; Xsl: variable name = "i" Select = "position ()" /> & Lt; XSL: Copy & gt; & Lt; Xsl: Select Value = "Context ('$ i =', $ i)" /> & Lt; / XSL: Copy & gt; & Lt; / XSL: for-each & gt; & Lt; / Posts & gt; & Lt; / XSL: Templates & gt; & Lt; / XSL: stylesheet & gt;
When this change applies to the following XML document :
& lt; Data & gt; & Lt; Posts & gt; & Lt; Entry / & gt; & Lt; Entry / & gt; & Lt; Entry / & gt; & Lt; Entry / & gt; & Lt; Entry / & gt; & Lt; / Posts & gt; & Lt; / Data & gt;
Results :
Comments
Post a Comment