Search code examples
xmlxsltfunctional-programming

Compile to xslt?


The answer to this may very well be no, as much searching has turned up nothing. I thought long ago I saw something like this, but it may all have been a mirage.

Basically, it's so atrociously awful writing xslt out by hand. It's not the functional paradigm that bothers me. What bothers me is the fact that it uses XML based syntax. I wonder if there's anything available that can compile from some simpler more legible syntax into an XSLT stylesheet. Doesn't have to have curly brackets, but the angle brackets are a bit eye boggling.


Solution

  • You could translate S-expressions as SXML to XML. Instead of using angle brackets, this would use parentheses with a slightly less cluttered syntax:

    (xsl:template (@ (name "mytemplate"))
      (xsl:if (@ (test "foo = 'bar'"))
        (xsl:value-of (@ (select "@baz")))))
    

    Whether this is an improvement over XML depends on your personal tastes, of course.