Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.이 콘텐츠는 선택한 언어로 제공되지 않습니다.
19.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");
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");
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 19.2, “Operators for the XPath Language”.
Operator | Description |
---|---|
= | Equals. |
!= | Not equal to. |
> | Greater than. |
>= | Greater than or equals. |
< | Less than. |
<= | Less than or equals. |
or | Combine two predicates with logical and. |
and | Combine two predicates with logical inclusive or. |
not() | Negate predicate argument. |