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

Syntax

Examples

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

  <tr><td>[[images/boolean_expr.png]]</td><td>xpath("//a/b/c") = "foo" and xpath("count") = 12</td></tr>

  <tr><td>[[images/boolean_expr.png]]<td>not xpath("//a/b/c") > 5</td></tr>

  <tr><td>[[images/predicate.png]]</td>   <td>(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
  <tr><td>[[images/comparison_function.png]]</td><td>
  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
xpath("//a/b/c") = "foo" or xpath("count") = 12
xpath("//root/first-level-child/another-level"). Note: The string value can be any valid XPath 1.0 valueSupported java object: Map and any object. JavaBean convention is assumed. 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()

xpath("//a/b/c/f") = "134.12" xpath("path") < 12
"a string" true false null xpath("//a/path/to/a/property")
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("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("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 (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"))
xpath("path") in (1, 2, 23.0, 4) xpath("path") in ("ab", "b", "h", "0")
xpath("path") is null
xpath("//a/b/c") =~ "0-9+"
exists xpath("//a/b/c") xpath("//a/b/c") exists
// a comment /* another comment */0>
Clone this wiki locally