32.7. predicates


基本 predicates

您可以在 Java DSL 中,或者在 predicate 期望的上下文中使用 xpath,作为 filter() 处理器的参数,或作为 when() 子句的参数。

例如,以下路由过滤传入的消息,允许一条信息传递,仅当 /person/city 元素包含值 伦敦 时:

from("direct:tie")
    .filter().xpath("/person/city = 'London'").to("file:target/messages/uk");
Copy to Clipboard Toggle word wrap

以下路由评估 when() 子句中的 XPath predicate:

from("direct:tie")
    .choice()
        .when(xpath("/person/city = 'London'")).to("file:target/messages/uk")
        .otherwise().to("file:target/messages/others");
Copy to Clipboard Toggle word wrap

XPath predicate operator

XPath 语言支持标准 XPath predicate 运算符,如 表 32.2 “XPath 语言的 Operator” 所示。

Expand
表 32.2. XPath 语言的 Operator
Operator描述

=

等于。

!=

不等于.

>

大于.

>=

大于或等于。

<

小于.

小于或等于。

将两个 predicates 与逻辑 组合。

或者

将两个 predicates 与逻辑 inclusive 组合。

not()

negate predicate 参数.

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat