NiceXSL logo Contents Download Update-Site NiceXSL logo

NiceXSL Language

NiceXSL defines a conventional textual representation of XSL that is more amenable to conventional editing. XML overheads are much reduced and abbreviated syntaxes are provided for all XSLT 2.0 constructs.

A simple example may be found in the overview.

A more substantial example is provided by the source and the generated stylesheet for the XSL to NIceXSL reverse translator. This also demonstrates pretty printing of awkward characters.

See NiceXML.html for a full NiceXML syntax summary.

See NiceXSL.html for a full NiceXSL syntax summary.

Abbreviated XML Syntax

NiceXSL eliminates the XML prohibitions on lexical nesting and makes the repetitive end-of construct keywords optional. A NiceXSL construct that starts with < therefore ends at the matching > . NiceXSL allows XML tag names to be re-specified at the end of a construct, and this may be used for documentation or diagnosis of deep hierarchies.

The XML <a><b/></a> must therefore be rewritten in NiceXSL, to use hierarchical nesting as <a <b> >. Use of additional construct closers as in <a <b/> /> or <a <b /b> /a> is optional.

Text nodes must be written in quotes, so the XML <a>some text</a> must be written as <a "some text"> or <a 'some text'>

The standard XML &amp; &gt; &lt; &quot; &#decimal ; and &#xhexadecimal; policies for character references in strings are supported; A new line should therefore be entered as &#xA; (not as \n).

A group of child nodes may be enclosed in braces to assist structuring: <a { @b = "c" <d> } >.

XML comments can be provided using the standard <!-- introducer and --> terminator. Alternatively purely local comments can be placed at the end of a line following --. Local comments are not translated to XSLT.

Abbreviated XSLT Syntax

Abbreviated non <> syntaxes are provided using { }'s and ; in a way that should be familiar to C or Java programmers. Abbreviated XSLT constructs of the form such as <xsl:otherwise> may be written otherwise ... ; when there is at most one child abbreviated XSLT construct, or otherwise ... { ... } when there are any number of child abbreviated XSLT constructs. XML nodes (elements, attributes, namespaces, text, comments, processing-instructions) are not abbreviated XSL constructs and so may be placed as required in either of the ellipsis positions. Braced groups of XML nodes (and abbreviated XSLT constructs) may only be placed within braces.

Primary XPath attribute

The introductory name for XSLT constructs with a mandatory primary attribute, such as select or test, may be omitted immecditaely preceding the parenthesised XPath expression.

  <xsl:value-of select="concat('prefix',$suffix)"/>

may be abbreviated to

  value-of (concat('prefix',$suffix));

Primary non-XPath attribute

The introductory name for other XSLT constructs with a mandatory primary attribute such as elements href, or method may also be omitted. No punctuation is needed for the mandaotory argument.

  <xsl:include href="b"/>

may be abbreviated to

  include "b";
  <xsl:output method="text"/>

may be abbreviated to

  output text;
  <xsl:preserve-space elements="title nested:*"/>

may be abbreviated to

  preserve-space title,nested:*;

Secondary attributes

Some constructs have a secondary attribute which may be specified with an = prefix:

  <xsl:namespace-alias stylesheet-prefix="a" result-prefix="b"/>

may be abbreviated to

  namespace-alias "a" = "b" ... ;
  <xsl:variable name="a" select="b"/>

may be abbreviated to

  variable a = (b);

Other attributes

Only the primary (and secondary) attribute can be supplied without a keyword; other attributes are specified normally:

  value-of (name) disable-output-escaping="no";

Parameter lists

Parameter lists are specified in parentheses following the template function name, template match expression, or the stylesheet keyword.

  <xsl:call-template name="yyy" ... >
    <xsl:with-param name="a" select="b"/>
    <xsl:with-param name="c">...</xsl:with-param>
    ...
  </xsl:call-template>

may be abbreviated to

  call yyy(a := b, c := { ... }) ... ;

  <xsl:apply-templates select="yyy" ... >
    <xsl:with-param name="a" select="b"/>
    <xsl:with-param name="c">...</xsl:with-param>
    ...
  </xsl:apply-templates>

may be abbreviated to

  apply-templates (yyy)(a := b, c := { ... }) ... ;

  <xsl:stylesheet ... >
    <xsl:param name="a" select="b"/>
    ...
  </xsl:stylesheet>

may be abbreviated to

  stylesheet(a := b, ... ) ... ;

  <xsl:template name="yyy" ... >
    <xsl:param name="a" select="b"/>
    ...
  </xsl:template>

may be abbreviated to

  template yyy(a := b, ... ) ... ;

  <xsl:template match="yyy" ... >
    <xsl:param name="a" select="b"/>
    ...
  </xsl:template>

may be abbreviated to

  match yyy(a := b, ... ) ... ;

The case of a template with both a name and match expression may be defined by adding a match attribute to a template or a name attribute to a match:.

  match yyy(a := b, ... ) name="zzz"... ;

or

  template zzz(a := b, ... ) match="yyy" ... ;

Within parentheses or following :=, it is not necessary to provide additional parentheses around the XPath expression (unless it is a sequence. The use of := rather than the deprecated = is intended to avoid the confusion with the XPath comparison operator. )

if else if else

The abbreviated form of if is extended to recognise trailing else if and elseclauses. This is equivalent to (and translated to) a choose enclosing when and otherwise clauses, but is a little easier to type, and of course suffers from all the traditional dangling else problems. It is therefore advisable to use braces to ensure that multiple abbreviated XSLT constructs are grouped as children of the intended else.