SLAX Elements and Element Attributes Overview

Slax Elements Overview

SLAX elements are written with only the open tag. The contents of the tag appear immediately following the open tag. The contents can be either a simple expression or a more complex expression placed inside braces:

<top> {
    <one>;
    <two> {
        <three>;
        <four>;
        <five> <six>;
    }
}

The XSLT equivalent:

<top>
    <one/>
    <two>
        <three/>
        <four/>
        <five>
            <six/>
        </five>
    </two>
</top>

Using these nesting techniques and removing the close tag reduces clutter and increases code clarity.

SLAX Element Attributes Overview

Attributes of elements follow the style of XML. The attribute name is followed by an equal sign (=) and the value of the attribute.

<element attr1="one" attr2="two">;

Where XSLT allows attribute value templates using curly braces, SLAX uses the normal expression syntax. Attribute values can include any XPath syntax, including quoted strings, parameters, variables, numbers, and the SLAX concatenation operator, which is an underscore (_).

<location state=$location/state zip=$location/zip5 _ "-" _ $location/zip4>;

The XSLT equivalent:

<location state="{$location/state}" 
                 zip="{concat($location/zip5, "-", $location/zip4}"/>

Curly braces placed inside quote strings are not interpreted as attribute value templates. Instead, they are interpreted as plain-text curly braces.

An escape sequence causes a character to be treated as plain text and not as a special operator. For example, in HTML, an ampersand (&) followed by lt causes the less-than symbol (<) to be printed.

In XSLT, the double curly braces ({{ and }}) are escape sequences that cause opening and closing curly braces to be treated as plain text. When a SLAX script is converted to XSLT, the curly braces inside quote strings are converted to double curly braces:

<avt sign="{here}">;

The XSLT equivalent is:

<avt sign="{{here}}"/>