Each instance of the expression editor in an Oracle Commerce Platform user interface is configured at runtime by an XCL template, which exposes the grammar as a graph of Java objects implementing the atg.ui.expreditor.Construct
interface. In this graph, each Construct represents one of the following fundamental types of grammatical constructs:
Token: a unitary word or phrase within the expression such as
People whose
,named
, oris not
. The content of a token cannot be edited by the user directly, but tokens can be selected from a list or from a dialog box. A token may have a visible representation different from its intrinsic value, which is always of String type.Literal: a constant value that the user can supply and freely edit within an expression, such as a number or a string. In the expression
People whose name is Nate
, the termNate
would be a literal supplied by the user.Choice: a set of alternative constructs, exactly one of which is allowed to occupy a particular place in the expression. The user is permitted to select the member of the choice set. For example, in the alternative expressions
People whose name is Nate
andPeople whose name is not Nate
, the tokensis
andis not
are members of a choice.Sequence: a sequence of a fixed number of constructs that occur in a fixed order. For example, the expression
People whose name is Nate
might be defined as a sequence whose components are the tokenPeople whose
, a choice of properties (of which one isname
), a choice of {is, is not
} and a literal.
As XCL templates, expression grammars are defined by XML data files in the CLASSPATH, which in turn can be compiled into .ser files by the XCL toolkit for greater efficiency and speed. The XCL stylesheet used by expression grammar templates provides XML elements that can be used to define grammatical concepts, including the basic construct types given above.
For example, the following XML file would serve to define the sequence mentioned above. It includes a number of details that will be explained later in this section.
<?xcl-stylesheet resource="atg/ui/expreditor/xcl/grammar.xsl"?> <sequence id="example-sequence"> <token><description>People whose</description></token> <choice> <token value="name"/> <token value="email"/> <token value="gender"/> </choice> <choice> <token value="eq"><description>is</description></token> <token value="neq"><description>is not</description></token> </choice> <literal/> </sequence>