What is greex syntax?
Using the Greex syntax you can create advanced XML conditions or Greex rules. An advanced XML condition is used to evaluate certain conditions on the input data. The Greex syntax is an XML based. This style of condition evaluation enables you to use the input data in multiple ways, rather than just a Boolean output.
The Greex syntax provides Greex constructs that are capable of being nested using multiple IF, and ELSE blocks, and also allows to group expressions using an AND or OR operator. Each expression comprises one or more function calls. You can include functions in a nested loop, which means parameters to functions can be other function calls. These contain basic IF ELSE conditions. The following table describes various elements of an If/Else construct.
Element |
Description |
---|---|
Condition |
The Condition element provides a logical grouping of all expressions that need to be evaluated by operating on an input XML. |
Return |
Every condition defined under the If/Else construct
must return a value. A condition can return an XML element, string,
or boolean value. It returns the appropriate value for an If/Else
condition in the Return element. For example,
|
The Condition element contains various Expression elements. Each Expression element defines the expression that you want to evaluate for the specified condition. The following table describes the various elements of a condition:
Element |
Description |
---|---|
Expression |
The Expression element contains the expressions that you want to evaluate for a condition to satisfy. To make function calls in the expression, prefix the function name with "fn:". For example, define the following Expression element which makes a function call: You can also pass functions as parameters to other functions. For example, you can define the following Expression element to pass functions as parameters to other functions:
|
Group |
This is an optional element. If you want to evaluate a set of expressions together, you must group the set of expressions together. The Group element's "op" attribute indicates the operation you want to perform on the set of expressions. The valid values are: "or" and "and". You can define more than one expression in a Group element. If the Group element's op value is "and", then the condition satisfies only if ALL expressions that are part of the Group element evaluates to "true". Likewise, if the Group element's "op" attribute is "or", then the condition satisfies only if ONE of the expressions that are part of the Group element evaluates to "true". You can create any level of nested Group and Expression elements. Note: If you want to evaluate a single expression, define a single Expression element under the Condition element, without creating the Group element. |
<If>
<Condition name="isWebOrder?">
<Group op="and">
<Expression>fn:!equals(@orderType,"WEB")</Expression>
<Expression>fn:equals(address::@ZipCode, "01876")</Expression>
</Group>
</Condition>
<Return>
<Value output="<Order type="Web"
discount="5"/>"/>
</Return>
</If>
<Else>
<Return>
<Value output="<Order type="Catalog"
discount="2"/>"/>
</Return>
</Else>