此内容没有您所选择的语言版本。

32.7. Predicates


Basic predicates

You can use xpath in the Java DSL or the XML DSL in a context where a predicate is expected—for example, as the argument to a filter() processor or as the argument to a when() clause.
For example, the following route filters incoming messages, allowing a message to pass, only if the /person/city element contains the value, London:
from("direct:tie")
    .filter().xpath("/person/city = 'London'").to("file:target/messages/uk");
The following route evaluates the XPath predicate in a when() clause:
from("direct:tie")
    .choice()
        .when(xpath("/person/city = 'London'")).to("file:target/messages/uk")
        .otherwise().to("file:target/messages/others");

XPath predicate operators

The XPath language supports the standard XPath predicate operators, as shown in Table 32.2, “Operators for the XPath Language”.
Table 32.2. Operators for the XPath Language
OperatorDescription
=Equals.
!=Not equal to.
>Greater than.
>=Greater than or equals.
<Less than.
<=Less than or equals.
orCombine two predicates with logical and.
andCombine two predicates with logical inclusive or.
not()Negate predicate argument.
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.