How to cite this paper

Braaksma, Abel. “Easing the road to declarative programming in XSLT for imperative programmers.” Presented at Balisage: The Markup Conference 2018, Washington, DC, July 31 - August 3, 2018. In Proceedings of Balisage: The Markup Conference 2018. Balisage Series on Markup Technologies, vol. 21 (2018).

Balisage: The Markup Conference 2018
July 31 - August 3, 2018

Balisage Paper: Easing the road to declarative programming in XSLT for imperative programmers

Abel Braaksma

Abel Braaksma is an invited expert of the XSL and XQuery Working Group and is creator and owner of Exselt, a streaming XSLT 3.0 processor. Next to his XSL work for the Working Group he runs a consultancy and outsourcing firm Abrasoft, specializing in data aggregation and XML in .NET environments. He has over 15 years experience in XML and related technologies. You can contact him about Exselt or XML, XSLT and C# / F# related inquiries.


As most programmers learn their trait in mainstream languages like C, C#, Java or nowadays in Python, PHP, Objective-C or Ruby, it is sometimes challenging to switch the mindset from such imperative languages to the declarative nature of XSLT. In this talk I will represent a way to map your imperative mindset to the declarative and functional one of XSLT and XPath.

We will be revisiting the structure of an XSLT stylesheet and how you can understand its flow from an imperative standpoint, or how to make changes to existing stylesheets without resorting to frustratingly deeply nested xsl:if and and xsl:choose elements. You may already have come to understand that you should not think in opening and closing tags, but instead in trees and traversals, but if you haven't then this may help you get there.

In imperative languages you tell the computer what to do, step by step. In declarative and functional languages, you tell the computer what result you wish for, and how it depends on your input. You guide the processor with a soft hand and give it suggestions, instead of imperatively making finite decisions for the compiler one by one. There's no need to become a fully fledged functional programmer and understand all its paradigms before you can be relatively versatile with writing effective XSLT stylesheets. I hope this talk will provide insights that help both the seasoned XSLT programmer and the beginning or interested imperative programmers to improve their skills and, most importantly, to not be afraid of the wolf.

Author's keywords for this paper:
XML; XSLT 3.0; XPath 3.0; Imperative programming; Declarative programming; Functional programming