Another case of sufficiently inappropriate technology being
indistinguishable from magic:
RC4 in XSLT
This turned out to be much harder than
RC4 in a shell skript.
Findings
XSLT relates
to general purpose programming as Cholera relates to dinner invitations.
Variables in XSLT aren't, and there's no imperative iterative statement,
so state must be kept on stack and recursion is the only way of iteration.
Combined with the fact that most XSLT compilers that we tried do not
utilize tail recursion, this quickly leads to stack overflows even
for small inputs.
Thanks to Meredith L. Patterson
for cool tricks to save space on stacks
Typing is non-existant, strings are cast to integers, whole XML subtrees
to strings and so on.
The XPath
query language can be used to select elements or subtrees of XML documents.
Subtrees resulting from such selections can be assigned to variables
and passed as such to functions (templates in XSLT-speak)
but their elements cannot be accessed by XPath any more.
Although XSLT abhors brakets, ampersands and double quotes,
it is possible to clobber together arbitrary strings. But
it not possible to output them in HTML format contexts,
so it is necessary to hark back to hacks including iframes
with data: url hrefs.