Click to return to the XML (Extensible Markup Language) home page    
Filters and Filter Patter...     Comparisons     XSL Pattern Syntax    
Web Workshop  |  XML (Extensible Markup Language)

Boolean, Comparison, and Set Expressions


Filter patterns can contain Boolean expressions, comparison expressions, and set expressions. Shortcuts listed in the following table represent alternative symbols that are also provided in this XSL implementation. This documentation discusses these expression operators.

Operator Alternative syntax Shortcuts Description
and $and$ && Logical-and
or $or$ || Logical-or
not() $not$ Negation
= $eq$ Equality
$ieq$ * Case-insensitive equality
!= * $ne$ Not equal
$ine$ * Case-insensitive inequality
< * $lt$ Less than
$ilt$ * Case-insensitive less than
<= * $le$ Less than or equal
$ile$ * Case-insensitive less than or equal
> * $gt$ Greater than
$igt$ * Case-insensitive greater than
>= * $ge$ Greater than or equal
$ige$ * Case-insensitive greater than or equal
$all$ * Set operation; returns TRUE if the condition is true for all items in the collection
$any$ * Set operation; returns TRUE if the condition is true for any item in the collection
| Set operation; returns the union of two sets of nodes

* Extended XSL Pattern methods described in the XQL Proposal Non-MS link.

The W3C syntax for operator keywords uses white space and other separators rather than the dollar sign character ($). In the W3C syntax, a binary keyword of the form $xxx$ can be expressed as wsxxxws, where ws refers to a token terminator, which can be white space, single quote characters ('), or double quote characters ("). Unary operators such as not() use functional notation. Although the Microsoft implementation supports both syntaxes for , it is recommended that the W3C syntax be used where possible in the interests of future compatibility.

Precedence order (from highest to lowest) for comparison operators and Boolean operators is shown in the following table.

1. ( ) Grouping
2. [ ] Filters
3. ! Method invocation
4. / // Path operations
5. $any$ $all$ Set operations
6. = != $lt$ $le$ $gt$ $ge$ $eq$ $ne$ $ieq$ Comparisons
7. | Union
8. not() Boolean not
9. and Boolean and
10. or Boolean or

Boolean expressions can match all nodes of a particular value, or all nodes with nodes in particular ranges. Boolean expressions are in the form (left-side-value $op$ right-side-value), and return a Boolean result.

Operators are case sensitive.

Boolean AND and OR

The Boolean operators and and or perform logical-and and logical-or operations, respectively. The Boolean operators, in conjunction with grouping parentheses, can be used to build very sophisticated logical expressions.

Examples

Find all author elements that contain at least one degree and one award:

author[degree and award]

Find all author elements that contain at least one degree or award and at least one publication:

author[(degree or award) and publication]

Boolean NOT

The Boolean not operator negates the value of an expression within a filter pattern.

Examples

Find all author elements that contain at least one degree element and that contain no publication elements:

author[degree and not(publication)]

Find all author elements that contain publication elements but do not contain either degree elements or award elements:

author[not(degree or award) and publication]

See Also

Sample Data, XSL Pattern Examples



Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.