To add to the madness you can write XML files that translate XML files to other files (possibly other XML files) in an XML defined language called XSLT. XSLT is a bit like writing in a functional programming language with the worst syntax possible :-).
The reason I say "worst syntax possible" is that the amount of typing you'll do to express something simple in XML is pretty excessive.
You could also use XQuery, which has syntax that functional programmers are used to, but lacks the semantic features you'd want in such a language. I remember I asked one of the MarkLogic XQuery implementation team members about HOF & TCO in the latest version of MarkLogic Server. I was told that TCO isn't on the radar for them, and if you want HOF, uses strings + eval. le sigh.