7

I just discovered HAML, and love its succinctness and readability. Is there any kind of equivalent for XSLT? In particular, I would love something that makes it easier to distinguish between the angle-bracket-containing output and the angle-bracket-containing markup itself.

If there is not a specialised XSLT abstraction language, is there at least a generic form for XML which would also work?

EDIT For fun, I just did a quick test of using actual Haml (actually HamlPy) to generate XSLT. Shortcomings I observed:

  • hyphenated element names aren't supported (in HamlPy at least)
  • %xsl:foo is not succinct enough. A special character for the XLS namespace, like #foo would be better.
  • HTML-specific rules get in the way (in my case, the special self-closing tag rules for <meta> are a problem)
  • %xsl:attribute(name="foo" value="blah") is still way too verbose. something like .foo="blah" would be better.
  • certain attributes like select are very common, and could be made implicit: #value-of "./a[@href]"
  • features like - and = for processing logic aren't needed, so could be repurposed for something like xquery or xpath. Or maybe {foo} could be a shorthand for <xsl:value-of select="foo"/>. That'd be cool: %p(style={../[@style]})
Steve Bennett
  • 114,604
  • 39
  • 168
  • 219
  • `is there at least a generic form for XML` - XSLT is a generic form for XML, it can process any XML document into any other document. – Sergiu Dumitriu Jan 09 '13 at 04:41

2 Answers2

2

There have been many attempts to define "user-friendly" or "compact" non-XML concrete syntax for XSLT. As far as I know, none of them have ever been used in anger by anyone other than the inventor. In the end, having a good editor that understands XSLT (e.g. oXygen) gives a much better productivity boost than having a more concise syntax.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
  • Thanks - do you have any pointers to any of those attempts, out of curiosity? – Steve Bennett Jan 11 '13 at 04:11
  • One or two of the early ones have disappeared from the web without trace. But googling for "compact syntax for XSLT" comes up with three good hits near the top of the page. – Michael Kay Jan 11 '13 at 10:23
2

Thanks to pointers from Michael Kay:

RXSLT

"Real XSLT": http://www.wilmott.ca/rxslt/rxslt.html

template doc
   apply-templates
 template doc/title
   <H1>{apply-templates}</H1>
 template doc/para
   <P>{apply-templates}</P>

XSLTXT

Very old (2002), abandoned long ago. Example:

tpl .name "foo" ("a", "b")
  "SELECT "
  val "$a"
  " FROM "
  val "$b"

http://savannah.nongnu.org/projects/xsltxt

LX

A lisp-ish compact XML notation. Not sure if there is any special treatment for XSLT:

;; The XSLT identity transformation
(lx:namespace ((#f "http://www.w3.org/1999/XSL/Transform"))
  (stylesheet version: 1.0
    (template match: "node()|@*"
      (copy
        (apply-templates select: "@*|node()")))))

http://nxg.me.uk/dist/lx/

Steve Bennett
  • 114,604
  • 39
  • 168
  • 219