Skip to content

XPathFilter Syntax

g9yuayon edited this page Dec 9, 2013 · 3 revisions

XPathFilter works with XPaths. Each message object is treated as a graph, and path in the graph is queried with XPath. See JXPath to see what XPath capability is supported.

Filter

Example

xpath("//a/b/c") = "foo" or xpath("count") = 12

boolean_expr

Example

xpath("//a/b/c") = "foo" and xpath("count") = 12

boolean_factor

Example

not xpath("//a/b/c") > 5

predicate

Examples

(xpath("//a/b/c") = 5 or xpath("//a/b/c") < 0) and xpath("root") = "foo"

xpath("root") != "value"

xpath("path") between (1, 2)

xpath("path") in ("a", "b", "c")

xpath("path") is null

xpath("path") =~ "?.*"

xpath("path") exists

true

false

comparison_function

Examples

xpath("path") = "foo"

xpath("path") !?= 5

xpath("path") > 5

xpath("path") >= time-millis("yyyy-MM-dd", "1997-08-29")

xpath("path") < time-string("yyyy-MM-dd'T'HH:mm:ss:SSS", "yyyy-MM-dd'T'HH:mm:ss:SSS", "2012-08-22T10:14:44:856")

xpath("path") <= 53.2

path_function

Example

xpath("//root/first-level-child/another-level").

Note:

  • The string value can be any valid XPath 1.0 value

  • Supported java object: Map and any JavaBean-like object. For example, the following call is corresponding to "//foo/bar/foobar", where the variable myEvent is the event that this XPath will be applied to.

  • myEvent.getFoo().getBar().getFooBar()

value_function

####Examples xpath("//a/b/c/f") = "134.12"

xpath("path") < 12

equality_value_function

Example

"a string"

true

false

null

xpath("//a/path/to/a/property")

comparable_value_function

Examples

23

2.718281828459045

6.23e23

time-millis("yyyy-MM-dd'T'HH:mm:ss:SSS", "2012-08-22T10:14:44:856")

time-string("yyyy-MM-dd'T'HH:mm:ss:SSS", "yyyy-MM-dd'T'HH:mm:ss:SSS", "2012-08-22T10:14:44:856")

time_millis_function

Example

time-millis("yyyy-MM-dd'T'HH:mm:ss:SSS", "2012-08-22T10:14:44:856")

That is, this method assume an input time value is in milliseconds Signature: time-string(String valueTimeFormat, String timeValue), where

  • *valueTimeFormat:*the time format string for the given filter value (the next parameter)
  • *timeValue:*The time value used to filter an event.

time_string_function

Example

time-string("yyyy-MM-dd'T'HH:mm:ss:SSS", "yyyy-MM-dd'T'HH:mm:ss:SSS", "2012-08-22T10:14:44:856")

That is, this method assume an input time value is a time string

  • Signature: time-string(String inputTimeFormat, String valueTimeFormat, String timeValue), where
    • inputTimeFormat: the time format string for a potential event.
    • valueTimeFormat: the time format string for the given filter value (the next parameter)
    • timeValue: The time value used to filter an event.

between_prediction

####Example between (6, 10)

xpath("//a/b/ef") between (time-millis("yyyy-MM-dd'T'HH:mm:ss:SSS", "2012-08-22T10:14:44:856"), time-millis("yyyy-MM-dd'T'HH:mm:ss:SSS", "2012-08-22T16:14:44:856"))

xpath("//a/b/ef") between (time-string("yyyy-MM-dd'T'HH:mm:ss:SSS", "yyyy-MM-dd'T'HH:mm:ss:SSS", "2012-08-22T10:14:44:856"), time-string("yyyy-MM-dd'T'HH:mm:ss:SSS", "yyyy-MM-dd'T'HH:mm:ss:SSS", "2012-08-23T10:14:44:856"))

in_predicate

####Example xpath("path") in (1, 2, 23.0, 4)

xpath("path") in ("ab", "b", "h", "0")

null_predicate

Example

xpath("path") is null

regex_predicate

Example

xpath("//a/b/c") =~ "0-9+"

exists_predicate

Example

exists xpath("//a/b/c")

xpath("//a/b/c") exists

COMMENT

####Example // a comment

/* another comment */

Clone this wiki locally