DocFlex Technology - FlexQuery Reference

Overview

FlexQuery-expressions are small scripts with the Java-based syntax, which are widely used in DocFlex templates to specify all kinds of dynamically computed settings, such as

Data Types

FlexQuery scripts operate with values of the following data types:

Data Type Java Class Usage
String java.lang.String string values
Number java.lang.Number numeric values of all kinds (both integers and floats)
Boolean java.lang.Boolean boolean values
Object java.lang.Object any other values

In addition to this, the FlexQuery processor recognizes objects of Generator Object Model types (backed by the corresponding Java classes of DocFlex API). Those object types have registered their properties which can be accessed using member operator (for example: element.id).

Some utility functions, which can be used within FlexQuery scripts, may accept parameters or return values of only specific Java classes (e.g. java.lang.Object[] or java.util.Enumeration). In such cases, those types are also tracked to ensure the parameters passed to a function have correct types. (For that matter, there are special conversion function, which should be used to convert values from one specific type to another when necessary.)

Constants

Data Type Constants
String Each string constant should start and end with the same single- or double-quote character, for example: "blue" or 'green'.

If a quote character is not used as the string delimiter, it may appear inside the string: e.g. "what's new?". Otherwise, the quote character should be encoded as escape sequence.

The supported escape sequences are the following:

\\, \", \', \n, \r, \t, \uxxxx
The last one allows to specify any Unicode character encoded with the four hexadecimal digits. For example, '\u20AC' will represent Euro Sign '€'.

Note: Although internally, strings are represented by java.lang.String objects, within FlexQuery expressions, strings never assume null values. All null string references received from function are always converted to empty strings.

Boolean There are two boolean constants recognized in FlexQuery expressions: true and false
Object Same as in Java, null keyword represents null reference.

Script Structure

Each script may consist of any number of statements delimited with semicolon:
variable_1 = expression_1 ;
variable_2 = expression_2 ;
. . .
result_expression
Currently, only assignment statements are supported. The assigned variables can be used within the statements following them.

The last statement should be an expression returning the result value of the whole script.

Operators

The following operators can be used within the expressions:

Category Operators
Arithmetical +, -, *, /, %
String concatenation +
Number comparison ==, !=, <, <=, >, >=
String and other types comparison ==, !=
Logical !, &&, ||
Conditional cond ? expr1 : expr2
Function call func (args)
Property/method access -> or .

Note: Some utility functions are focused on processing of objects of some specific types, so they actually behave like methods of those objects. To make calls of such functions look in more method-like style, the first parameter of any function call may be moved before the function name separated with the property access operator '.' or '->'.

For example, the call
substring(str,1,5)
may be written as
str.substring(1,5)
or
str->substring(1,5)

Comments

Comments can be the same as in Java:
  1. A single line comment, e.g.

    name = getParam("Name"); // comment

  2. A multiline comment: /* comment */
If an expression is totally commented, it is considered an empty expression.

Expression Editors and Assistant Dialog

When designing templates using DocFlex Template Designer, everywhere the FlexQuery-expressions may be specified, they are entered within special Expression Editors:

Expression Editor
Such an editor is supplied with the “Check Expression” button () which allows to check if the entered script is correct and the result data type it returns is appropriate to the given field.

Another button () that appears in the editor is the “Expression Assistant” button. It invokes the FlexQuery Expression Assistant Dialog:

Expression Assistant Dialog
This dialog provides a lot of information about everything that can be used in the expression: This information is always up-to-date as it is obtained not only from the static help files but collected dynamically from all available resources. Here, you can also select a necessary identifier and automatically insert it directly into the edited expression.

Besides this, the Expression Assistant Dialog contains three additional tools:

Location Path Builder

This tool allows to easily construct element/attribute Location Paths of any complexity, which can be further used to specify parameters for such functions as findElementsByLPath(), getValuesByLPath().

Location Path Builder

As soon as the neccessary Location Path is ready, you can quickly insert it into the expression editor by clicking the “Select” button. The Location Path will be automatically converted into a valid string constant enclosed in quotes.

Location Rule Builder

This dialog provides a convenient way for writing a definition of an Element Location Rule instantly encoded in the form of a LocationRule() function call, which is necessary to specify a parameter for findElementsByLRules() function:

Location Rule Builder

By clicking the “Select” button, you can insert the prepared Location Rule definition into the expression editor.

Subexpression Editor

This tool may help you to write and check the FlexQuery subexpressions you want to specify as a parameter for one of such functions: execSubquery(), generateVector(), filterElements(), findElementsByKey(), findElementsByLRules().

Subexpression Editor

Once the subexpression is finished, you can quickly insert it into the editor of the main expression by clicking the “Select” button. The subexpression will be automatically converted into a valid string constant enclosed in quotes.


Copyright© 2003-2009 Filigris Works, Leonid Rudy Softwareprodukte. All rights reserved.
To contact us, please visit www.filigris.com or e-mail to: contact@filigris.com