XSLT as a full functional language

XSLT obviously has much in common with functional programming languages. But it’s not really functional, because you can’t pass around functions (which in the XSLT world are the things called “templates”) as first-class objects, right?

Wrong. Dimitre Novatchev has come up with the amazing hack of using namespaces as a way to identify functions. To pass a function, he passes a placeholder element from that namespace; then the function can be invoked using XSLT’s basic template matching mechanisms. In his article The Functional Programming Language XSLT —A proof through examples—he then goes on to implement major parts of a FP library using his technique. A must-read for the XSLT geek.

Leave a Reply