XSPP grammar

Michal Moskal <malekith /at/ pld-linux.org>

 
Contents
Declarations

XSPP program is a list of declarations.

encoding

'encoding' string

Is used to set 'encoding' attribute in <?xml ...>.

template

'template' match-string [ attributes ] '{' actions '}'

is translated into:

<xsl:template match="match-string" attributes> actions </xsl:template>

def

'def' name '(' arg-1 '=' simple-action-1 ',' ... ',' arg-N '=' simple-action-N ')'
[ attributes ] '{' actions '}'

is translated into:

<xsl:template name="name" attributes>
<xsl:param name="arg-1">simple-action-1</xsl:param>
...
<xsl:param name="arg-N">simple-action-N</xsl:param>
actions
</xsl:template>

N >= 0.

output

'output' attributes

is translated into:

<xsl:output attributes/>

var

'var' name '=' simple-action

is translated into:

<xsl:variable name="name">simple-action</xsl:variable>

'variable' can be used instead of 'var'.

mode

'mode' name '{' declarations '}'

Set default mode for declarations. It applies to 'template' and 'apply'. Mode can be always overridden with explicit 'mode="..."' setting.

macro

'macro' name '(' arg-1 '=' simple-action-1 ',' ... ',' arg-N '=' simple-action-N ')'
'{' actions '}'

Define macro named name. Arguments can be referred to with 'macro-arg' command. Macro can be called with '%' command.

Actions

simple-action is either a quoted string, a-, e- or v-quotation or list of zero or more actions enclosed in '{' and '}'.

action is either simple-action, markup or one of things below.

Quoted strings and markup are copied into output as is.

apply

'apply' attributes ';'

is translated into:

<xsl:apply-templates attributes/>

'{ }' can be used instead of ';'.

% (markup)

'%' name attributes '{' actions '}'

is translated into:

<name attributes>actions</name>

% (macro call)

'%' name '(' arg-1 '=' simple-action-1 ',' ... ',' arg-N '=' simple-action-N ')'

Call macro name.

call-template

name '(' arg-1 '=' simple-action-1 ',' ... ',' arg-N '=' simple-action-N ')'

is translated into:

<xsl:call-template name="name" attributes>
<xsl:with-param name="arg-1">simple-action-1</xsl:with-param>
...
<xsl:with-param name="arg-N">simple-action-N</xsl:with-param>
</xsl:call-template>

N >= 0.

e-quotation

'e' D name D

is translated into:

<xsl:text disable-output-escaping="yes"> &amp;name; </xsl:text>

If you know better way to insert &nbsp; into output, let me know ;) D is delimeter.

t-quotation

't' D text D

is translated into:

<xsl:text disable-output-escaping="yes"> text </xsl:text>

text is quoted. I.e. <, > and & are replaced with &lt;, &gt; and &amp; respectively.

a-quotation

'a' D name D

Same as 'macro-arg'.

v-quotation

'v' D name D

is translated into:

<xsl:value-of select="name"/>

nbsp

'nbsp'

Same as 'e{nbsp}'.

macro-arg

'macro-arg' name

Refer to macro argument name.

redirect

'redirect' name [ attributes ] '{' actions '}'

Use xalan redirect extension to redirect output to file name.

if

'if' test [ attrs ] '{' actions '}' [ 'else' '{' actions '}' ]

is translated into:

<xsl:if test="test" attrs> actions </xsl:if>

If there is 'else' part, it is translated into '<xsl:choose ...>' appropriately.

choose

'choose' [ attrs ] '{' when-clauses '}'

is translated into:

<xsl:choose attrs> when-clauses </xsl:choose>

when-clause is one of 'when "foo" { ... }' or 'otherwise { ... }' ('else' can be used instead of 'otherwise').

var

Same as var declaration.

for-each

'for-each' select [ attrs ] '{' actions '}'

is translated into:

<xsl:for-each select="select" attrs> actions </xsl:for-each>