0

I am new in XSLT and I only know a basic functions in XSLT. I have this requirements to generate a sequential alphabet in order every time I did a testing or every time I run the test file. And, it will reset the letter the following day. For example, my first testing is A, second test is B, third test is C, so on and so forth. If it reach the end letter which is Z, it will start again to A. And, if I tried to test it the next day, it will start again to A.

I don't know if it is possible to do it in XSLT. And, if it is I don't know how will I do that. I am using a processor of SAXON-HE 9.7 and the version of XSLT is 2.0.

Thank you in advance. Your feedback is much appreciated.

Charlotte
  • 17
  • 5
  • 2
    XSLT has no memory of previous transformations. If you want to advance your "counter" by 1 every time you run a transformation, you will need to store it somewhere and pass the value to the XSLT during runtime. You can use a sequential number if you like - converting it to a letter of the alphabet is trivial. Alternatively, you could generate the letter by date - but then every transformation run on the same date would be assigned the same letter. – michael.hor257k Mar 23 '17 at 13:06
  • XSLT is a functional and not an imperative language. Account that. The differences are tremendous and are explained in this [SO answer](http://stackoverflow.com/a/23290/1305969). – zx485 Mar 23 '17 at 13:47

1 Answers1

1

The way you have described the problem, you will need to maintain the "current letter" somewhere in persistent storage. You can't do that in pure XSLT; though you could do it for example by exploiting the EXPath File extension to read and write files in filestore.

A simpler way is probably for your test driver application to keep track of how many test runs there have been since the start of the day, and pass this value to the XSLT transformation as a stylesheet parameter.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164