XSPP stands for XSLT Stylesheet PreProcessor. It can be used to
simplify writing XSLT stylesheets. It is result of author being
terrified by xsl:call-template size :)
You need OCaml and CamlP4 to compile XSPP. I used OCaml version
3.04, earlier versions might or might not work. Starting with OCaml
3.04 CamlP4 is included in OCaml source distribution, so there
is no need to look for it separately. You can download
OCaml from http://www.ocaml.org/.
You will also need GNU Make and Bourne shell.
To compile XSPP just run make(1).
-
Terse syntax for most frequently used XSLT elements, for example
template "foo" { ... } for
<xsl:template match="foo"> ... </xsl:template>.
-
Even terser syntax for <xsl:call-template ...> like:
foo(bar = "baz", qux = {<xsl:value-of
select="@quxx">}).
-
Perl-like quotations: q|foo bar|, q{bar baz}
etc.
-
v{X} (or v|X|, v#X#, v(...)
or whatever) is <xsl:value-of select="X">.
-
It is possible to specify mode for block of templates, like in:
mode "toc" {
template "foo" { ... }
template "baz" { ... }
}
|
-
Macros. They are similar to named templates, but complex markup
can be passed as arguments:
macro page(body = {<p>Nothing special</p>}, title = "no name")
{
<html>
<head>
<title>macro-arg title</title>
</head>
<body>
macro-arg body
</body>
</html>
}
template "sth" {
%page(title = "foo", body = { apply; })
}
|
It is possible to have macros, expansion of which doesn't give
proper XML, like in:
macro header(title = "")
{
<html>
<head>
<title>macro-arg title</title>
</head>
<body>
}
macro footer()
{
</body>
</html>
}
template "sth" {
%header("...")
<p>....</p>
%footer()
}
|
-
Newlines in v{...} are changed to space.
-
Shorthand syntax for entering markup, like:
template "xxx" {
%xsl:comment { "foo" }
%table {
%tr {
%td { "bar" }
%td { "baz" }
}
}
}
|
I don't like it personally, though :)
-
else for if
Ok, here we go with language description. You can look into
grammar.html file to find out more...
I assume knowledge about XSLT.
Examples of valid XSPP strings:
# this is comment
"foo bar ain't qux"
'but it cannot be "quux"'
q#Isn't is "strange"??# # and here we start a comment
q{Well... it's not # this is still string}
|
Examples of
invalid XSPP strings:
"foo\"bar" # string 'foo\"' followed id 'bar' and
# double quote
q<braces <doesn't nest> uh..>
|
Comments are introduced by the '#' character, and
continues until end of line. The '#' character isn't
special in quoted strings though.
Strings can be quoted with '"' and ''' characters.
There is
no '\' escape. qXstringX where X is
non-alphanumeric
character can also be used. If X is one of '{',
'[', '(' or '<'
matching '}', ']', ')' or '>'
has to be used.
Reader will probably note, that q|foo| convention was shamelessly
stolen from perl ;)
It is also possible to use e or v instead of
q. It will be discussed later.
XSPP was written by Michal Moskal,
<malekith /at/ pld-linux.org>. Please send any
bugreports, suggestions and patches to author.