ON THIS PAGE
SLAX Elements and Element Attributes Overview
SLAX Elements
SLAX elements are written with only the opening tag. The contents of the tag appear immediately following the opening tag. The contents can be either a simple expression or a more complex expression placed inside curly braces. For example:
<top> { <one>; <two> { <three>; <four>; <five> { <six>; } } }
The XSLT equivalent is:
<top> <one/> <two> <three/> <four/> <five> <six/> </five> </two> </top>
Using these nesting techniques and removing the closing tag reduces clutter and increases code clarity.
SLAX Element Attributes
SLAX element attributes follow the style of XML. Attributes are included in the opening tag and consist of an attribute name and value pair. The attribute syntax consists of the attribute name followed by an equals sign and then the attribute value enclosed in quotation marks. Multiple attributes are separated by spaces.
<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 (_
). In
the following example, the SLAX element location
has two attributes, state
and zip
:
<location state=$location/state zip=$location/zip5 _ "-" _ $location/zip4>;
The XSLT equivalent is:
<location state="{$location/state}" zip="{concat($location/zip5, "-", $location/zip4}"/>
In SLAX, 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}}"/>