ISML expressions encode arithmetical, Boolean, and string operations, as well as special function calls. They are used to perform calculations, to compare values, or to produce new values in combination with functions. ISML expressions are evaluated at runtime every time output is generated from a specific template.
Expressions can be composed of:
A sample ISML expression looks as follows:
#len(sub:DisplayName)>15#
It consists of a function (len()
, a template variable sub:DisplayName
, and an operator >
.
An expression always evaluates to a value of a specific data type as shown in the table below:
Data Type | Description | Scope |
---|---|---|
double | Numeric data type with a size of 64 bits | minimum value: ±4.94065645841246544E-224, maximum value: ±1.79769313486231570E308 |
boolean | Logical data type | True or false |
string | Alphanumeric data type | Maximum size is 32K |
Please note the following hints regarding ISML expressions:
ISML expressions must be surrounded with pound signs (#).
=#len(sub:DisplayName) > 15#
This is the universal syntactic description of an ISML expression:
ISML expression := # <operation> #
Note
Currently, no type check of Intershop 7 template expressions is provided during compile. If types do not match, a runtime exception will occur.
The following table lists the different elements that can be used to build ISML expressions.
Element | Syntactic Description |
---|---|
Operation | |
Arithmetic Compare | |
String Compare | |
Arithmetic Expression | |
String Expression | |
Boolean Expression | |
Simple Expression | ( ( <function name> ( [<operation>] ( , [<operation>] )* ) ) < Template Variable >, < UserVariable >, <constant>, ( <operation> ) ) |
ac Operator | |
sc Operator | EQ , NE |
ae Operator | + , - , * , / |
se Operator | .(period) |
be Operator | AND , OR |
Constant | |
Function Name | e.g., hasElements, isSSSenabled, getValue, url, urlex, action, parameter, etc. See Reference - ISML Functions for detailed information. |
Simple Name | 'a-zA-Z' ('a-zA-Z0-9_')* |
ISML Template Identifier |
If the result of an expression is printed out to an HTML page, it is often useful if you can specify how this should be done. For example, a date can be formatted in different ways depending on the store's locale:
For formatting values of the data types Money, Number, Quantity, Date, and Message, Intershop 7 uses specific standard formatter classes. The table below lists the data types and their appropriate formatter class.
Type of Expression Result | Standard Formatter Class |
---|---|
Money | StaticMoneyFormat |
Number | DecimalFormat |
Quantity | StaticQuantityFormat |
Date | SimpleDateFormat |
Message | MessageFormat |
Please mind the following general notes regarding formatters:
A standard formatter class needs a special formatter string. There are three ways to provide such a string:
Styles are pre-defined formatter strings, which are defined in standard formatter classes. You can specify a style
via the style attribute of <ISPRINT>
, or in combination with getValue()
.
This class is used to format expression results of type Money. See the table below for valid styles. As shown in the table, the style identifier is capable of converting between the Euro currency and a predecessor currency, the Deutsche Mark, at the fixed rate of 1 Euro to 1.95583 Deutsche Mark.
Valid Style Identifier | Description | Example |
---|---|---|
MONEY_SHORT | Two digits following decimal separator. No currency symbol. | Input: 3333, Formatted string: "3,333.00" |
MONEY_LONG | Two digits following decimal separator. Leading currency symbol. | Input: 3333, Formatted string: "$3,333.00" |
EURO_SHORT | Currency converted into Euro. Two digits following decimal separator, included in brackets. No currency symbol. | Input: 3DM, Formatted string: "(1.53)" |
EURO_LONG | Currency converted into Euro. Two digits following decimal separator, included in brackets. Leading currency symbol. | Input: 3DM, Formatted string: "(€ 1.53)" |
EURO_COMBINED | Concatenation of MONEY_LONG and EURO_LONG. | Input: 3DM, Formatted string: "DM 3.00 (€ 1.53)" |
This class is used to format expression results of type Number. See the table below for valid styles.
Valid Style Identifier | Description | Example |
---|---|---|
INTEGER | No digits after decimal separator. No decimal separator. | Input: 2200.1234, Formatted string: "2,200" |
DECIMAL | Exactly two digits after decimal separator. | Input: 2200.1234, Formatted string: "2,200.12" |
This class is used to format expression results of type Quantity. See the table below for valid styles.
Valid Style Identifier | Description | Example |
---|---|---|
QUANTITY_SHORT | 0 to 3 digits after decimal separator. No quantity symbol. | Input: 3333 kg, Formatted string: "3,333" |
QUANTITY_LONG | 0 to 3 digits after decimal separator. Following quantity symbol. | Input: 3333 kg, Formatted string: "3,333 kg" |
This class is used to format expression results of type Date. See the table below for valid styles.
Valid Style Identifier | Description | Example |
---|---|---|
DATE_SHORT | Date without clock time in short format. Automatically displays the date in the current time zone. | Formatted string: "09/25/99" |
DATE_SHORT_UTC | Date without clock time in short format. Displays the date fixed in the UTC time zone. Can be used for fixed dates that are independent of time zones, such as birthdays. | Formatted string: "09/25/99" |
DATE_LONG | Date without clock time in long format. Automatically displays the date in the current time zone. | Formatted string: "SEP 25, 1999" |
DATE_LONG_UTC | Date without clock time in long format. Displays the date fixed in the UTC time zone. Can be used for fixed dates that are independent of time zones, such as birthdays. | Formatted string: "SEP 25, 1999" |
DATE_TIME | Clock time. Automatically displays the date in the current time zone. | Formatted string: "7:55:55 PM" |
The styles listed in the following table are available for date/time input fields.
Valid Style Identifier | Description | Example |
---|---|---|
DATE_INPUT | Date without clock time. | Formatted string: "09/25/99" |
TIME_INPUT | Clock time. | Formatted string: "7:55:55 PM" |
DATE_TIME_INPUT | Date and clock time. | Formatted string: "9/25/99 7:55:55 PM" |
This class is used to format expression results of type Message. The formatter of this class cannot be customized. It has a standard behavior. For more information, see the Java documentation in <IS.INSTANCE.SHARE>/docs.
The default style of a formatter class is used if nothing else has been specified by the user, neither a style, nor a user-defined formatter style. See the table below for a list of default styles.
Standard Formatter Class | Default Style |
---|---|
StaticMoneyFormat | MONEY_LONG |
DecimalFormat | DECIMAL |
StaticQuantityFormat | QUANTITY_SHORT |
SimpleDateFormat | DATE_SHORT |
MessageFormat | This class has a standard behavior. For more information, see the Java documentation in <IS.INSTANCE.SHARE>/docs. |
A formatter string is explicitly given by the user via the formatter attribute of <ISPRINT>
or in combination with getValue()
. For more information about valid placeholders, see the Java documentation in <IS.INSTANCE.SHARE>/ docs. See the table below for examples of user-defined formatter strings.
Standard Formatter Class | Example for User-Defined Formatter String |
---|---|
StaticMoneyFormat | Scheme: "* #,#00.0#"Input: 3, Formatted string: "$ 03.00"Input: 3333.123, Formatted string: "$ 3,333.12" |
DecimalFormat | Scheme: "#,#00.0#;(-#,#00.0#)"Input: 3, Formatted string: "03.0"Input: -3333.333, Formatted string: "-3,333.33" |
StaticQuantityFormat | Scheme: "#,#00.0# *;(-#,#00.0# *)"Input: 3, Formatted string: "03.0 kg"Input: 3333.333, Formatted string: "3,333.33 kg" |
SimpleDateFormat | Scheme: "EEE, MMM d, ''yy", Formatted string: "Wed, Jul 10, '96" |
MessageFormat | Cannot be customized. |
It is possible to use national characters, such as Greek or Cyrillic letters, as well as mathematical symbols and any non-ASCII characters in HTML documents. To ensure that a web browser can interpret and display these characters correctly, they need to be encoded using HTML representations. In order to do this, you need to replace characters, such as "<", ">", or "&" with named character entities as defined in the HTML 4.01 standard. Because the result of an expression can be a string that might contain a special character expression, results are automatically encoded if you use <ISPRINT>
to output them. See the example below, which shows the exact string returned by <ISPRINT>
for a string containing a quote sign. The example assumes that the template variable product:name stores the value Nokia 447X Pro 17" Monitor
.
The following ISML code in a template:
<ISPRINT value="#Product:Name#">
generates this HTML code:
"Nokia 447X Pro 17" Monitor"
which is displayed by the browser as:
Nokia 447X Pro 17" Monitor
Expressions outside <ISPRINT>are never automatically encoded. In this case, if you need to encode characters, you have to use the stringToHtml() function.
Note
If you do not encode expressions outside of <ISPRINT>, then you might be vulnerable to Cross Site Scripting.