Document Properties
Kbid2Q4786
Last Modified04-Feb-2020
Added to KB20-Jun-2013
Public AccessEveryone
StatusOnline
Doc TypeReferences
Product
  • ICM 7.6
  • ICM 7.7
  • ICM 7.8
  • ICM 7.9
  • ICM 7.10

Reference - ISML Expressions

1 Introduction

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:

2 Expression Example

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

3 Expression Conventions

Please note the following hints regarding ISML expressions:

  • ISML expressions must be surrounded with pound signs (#).

    Example
    =#len(sub:DisplayName) > 15#
    
  • Do not use expressions outside of tags, in order to be sure that the expressions are properly parsed by HTML editors during the design phase.
  • This is the universal syntactic description of an ISML expression:

    Syntax
    ISML expression := # <operation> #
    
  • You can use different elements to build ISML expressions, see Expressions Syntaxfor details.

Note

Currently, no type check of Intershop 7 template expressions is provided during compile. If types do not match, a runtime exception will occur.

4 Expression Syntax

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

 

5 ISML Formatting Expression Results

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:

  • 12 March 1999
  • 12.03.1999
  • 03/12/99

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

5.1 General

Please mind the following general notes regarding formatters:

  • All formatter are additionally customized by regional settings.
  • Objects of classes other than Money, Date, Message, Quantity and Number will not be formatted and the result of formatting these objects is not standardized.
  • The EURO-styles are a temporary work-around for the direct support of multicurrency pages.

A standard formatter class needs a special formatter string. There are three ways to provide such a string:

  • Specifying one of the formatter strings pre-defined by a formatter class (they are called styles).
  • Using the default style of a formatter class.
  • Providing a user-defined formatter string.

5.2 Using Styles

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().

5.3 StaticMoneyFormat

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)"

5.4 DecimalFormat

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"

5.5 StaticQuantityFormat

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"
Input: 3333.1 kg, Formatted string: "3,333.1"
Input: 3333.1234 kg, Formatted string: "3,333.123"

QUANTITY_LONG

0 to 3 digits after decimal separator. Following quantity symbol.

Input: 3333 kg, Formatted string: "3,333 kg"
Input: 3333.1 kg, Formatted string: "3,333.1 kg"
Input: 3333.1234 kg, Formatted string: "3,333.123 kg"

5.6 SimpleDateFormat

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.

Formatted string: "09/25/99"

DATE_LONG

Date without clock time in long format.

Formatted string: "SEP 25, 1999"

DATE_TIME

Clock time.

Formatted string: "7:55:55 PM"

For date/time input fields, the styles listed in table below are available.

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"

5.7 MessageFormat

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.

5.8 Using the Default Style of a Formatter Class

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.

5.9 Specifying User-defined Formatter Strings

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"
Scheme: "h:mm a", Formatted string: "12:08 PM"
Scheme: "K:mm a, z", Formatted string: "0:00 PM, PST"
Scheme: "yyyyy.MMMMM.dd GGG hh:mm aaa", Formatted string: "1996.July.10 AD 12:08 PM"

MessageFormat

Cannot be customized.

6 Encoding Expression Results

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&quot; 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.

Reference - ISML Reference

Disclaimer

The information provided in the Knowledge Base may not be applicable to all systems and situations. Intershop Communications will not be liable to any party for any direct or indirect damages resulting from the use of the Customer Support section of the Intershop Corporate Web site, including, without limitation, any lost profits, business interruption, loss of programs or other data on your information handling system.

Customer Support
Knowledge Base
Product Resources
Support Tickets