The examples in this manual are based on the XML document in
the
appendix. With only a few exceptions
all operators have both a C-style form and a Text-style form. For instance, GREATER THAN OR EQUAL can be
represented either as
>= or
_GTE_ . The Text-style
operators must always be upper case.
| : (colon) |
context separator: expression to the right of colon is evaluated in the context of the left-hand expression |
| , (comma) |
(1) separates a list of parallell elements, each of which is a descendent of the same
context-element.
(2) separates list of sub-expressions in a condition:
[@model=Accord,@make=Honda]
List processing stops at first expression that evaluates to FALSE |
| @ (at-sign) |
attribute prefix: used within conditions to distinguish attribute
names from element names.
@middle_init evaluates to middle_init ,
which is an attribute of the first_name element. |
| "" (double quotes) |
must be used to enclose strings of more than a single word;
this means that the query expression must be enclosed
in single quotes:
'dealer:name[["Winnipeg Motors"]]' |
| [ ] (brackets) |
brackets enclose a condition; if the condition evaluates to TRUE
the evaluation process moves on to the next expression; if FALSE
the evaulation process stops and moves on to the next context expression, if any. |
| [[ ]] (double brackets) |
double brackets enclose a condition but if the condition evaluates to TRUE
the data stipulated in the condition is extracted and returned; otherwise, it behaves exactly
as single brackets. |
|
|
|
The following operators all have both a C-Style form and a Text form.
In simple expressions they can be used interchangeably. But in complex
expressions, which bind together more than one expression,
the C-style operator must always be used in all sub-expressions.
A simple expression consists of one relation:
A > B ,
Complex expressions consist of two or more relations:
A > B _OR_ C != D _OR_ F = G |
| >= _GTE_ |
GREATER THAN OR EQUAL |
| < = _LTE_ |
LESS THAN OR EQUAL |
| < _LT_ |
LESS THAN |
| > _GT_ |
GREATER THAN |
| = _EQ_ |
EQUAL
Note: only a single, not a double, equal sign is used for this relation:
vehicle[@year=2005] |
| != _NE |
NOT EQUAL |
| && _AND_ |
The text format must be used to bind together the major terms of the AND-ed expression,
and the C-style forms must be used in the minor terms:
@year>=2004 _AND_ @model=Accord _AND_ @make=Honda
Enhanced functionality for both _AND_ and _OR_
was implemented with release 1.0.2 and is detailed below. |
| _OR_ |
The OR operator does not have a C-style equivalent. Like
The AND operator,OR-ed sub-expressions must use the C-Style operators.
Enhanced functionality for both _AND_ and _OR_
was implemented with release 1.0.2 and is detailed below. |
| << _INCL_ |
INCLUSION. The INCLUSION operator indicates that the left term includes the right term:
owner:name[CDATA _INCL_ winnipeg]
vehicle[@model << Accord]
The INCLUSION operator uses Perl regular expressions and makes case-insensitive
comparisons, even when case-sensitivity is in effect. It also ignores duplicate
runs of internal white-space. |
| =>_ARROW_ |
The ARROW operator
binds together an element and one or more expressions.
The expressions are evaluated only as they apply to this element.
This element, moreover, must be a descendent of
the element outside the condition brackets, i.e. the
context-element.
If the condition evaluates to TRUE, and double brackets are used, the context-element and all its
descendents are returned:
dealer[[zip => "R3N 2B2"]]
If eXcavator locates a dealer whose Zip Code
is R3N 2B2, it will return owner and descendents.
Any valid query expression, including comma-separated lists, may go to the right
of the ARROW, with one exception: the ARROW operator does not support the
unqualfied CDATA keyword:
vehicle[mileage=>CDATA]:dealer[[CDATA]]
Instead, the following expression will get the desired result: 1
vehicle[mileage=>CDATA != ""]:dealer[[CDATA]] |
| / |
The FORWARD SLASH
is used in conjunction with the ARROW operator
to narrow down the search to a particular descendent element:
vehicle[dealer/address/city=>CDATA = Winnipeg] |
|
|
|
Non_Operators |
| CDATA |
CDATA is a keyword
that represents any character data that occurs in an element. It works by simple
substitution of an element's character data for the CDATA keyword.
CDATA works with strings and numbers alike:
vehicle[[mileage => CDATA < 15000]]
dealer:address[[CDATA _INCL_ "R3N 2B2"]] 2 |
| element_name: |
This construct tests for the existence of an element.
An element name followed by a colon returns a true value if it exists in the current context.
Otherwise it returns FALSE. If it is the left-most element, i.e. the first element
in the chain, then its context is implicitly the root element. |
| element[@attribute] |
A condition which consists solely of the attribute name tests for the existence
of the attribute in the current context and returns TRUE if it exists,
FALSE if it doesn't. |
| element[string] |
This construct is a shortcut for equality: vehicle:color[green]
is the same as vehicle:color[CDATA = green]. |
Version 1.0.2
Beginning with version 1.0.2, the above query would be handled as follows:
first_name[[CDATA << Douglas _AND_ first_name @middle_init=J]]
The only difference from the original attempt is that the expression to the right of the
_AND_
is now prefaced by the name of the element:
'first_name @middle_init=J' .
The basic syntax is this:
|
| |
[[initial-expression _AND_ target-element relational-expression _AND_ ...]]
|
|
|
The
initial-expression remains syntactically unchanged from previous versions of
eXcavator ,
except that the shortcut for equality cannot be used.
2
All expressions to the right of
_AND_ use the new syntax,
where
target-element can be either the
context-element
or one of its descendents. The
context-element is the element to the left of the
brackets:
context-element[[ initial-expression _AND_ . . .]]
The
target-element does not have to be a first-generation child of the
context-element , only a descendent.
In our example, the initial-expression is
'CDATA < < Douglas' This is followed
by the target element, i.e. the element which contains the data, which is
first_name, and then by
the relational expression, namely
'@middle_init=J' .
This new syntax holds whether we are testing for attributes or for the character data contained by an element:
vehicle[[@year>= 2003 _AND_ color = green ]]
The first test is for the
year attribute of
vehicle ;
the second test is for the character data of the
color element, which is a descendent of the
context-element ,
naemly
vehicle . Note that the relational is
'= green' . While
'= green' is obviously the right hand side of a relational expression, it can be understood as
a shortcut for a complete relational expression:
'CDATA = green' .
Forward Slash Syntax
The
target-element does not accept the
forward slash
syntax:
vehicle[[name/address/city =>CDATA <<Winnipeg _AND_ street <<Oak]]
|
|
vehicle[[name/address/city =>CDATA <<Winnipeg _AND_ name/address/street <<Oak]]
|
Both of these queries are viewed as being the same. In the second example, when
eXcavator sees
'name/address/street', it
ignores
'name/address/' and
looks only at
'street'. In both cases the context for
street
is
name/address. This is a change from versions prior to
1.0.6,
where in both cases the context for the
street would have been
vehicle.