Questo contenuto non è disponibile nella lingua selezionata.

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");
Copy to Clipboard Toggle word wrap
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");
Copy to Clipboard Toggle word wrap

XPath predicate operators

The XPath language supports the standard XPath predicate operators, as shown in Table 32.2, “Operators for the XPath Language”.
Expand
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.
Torna in cima
Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2025 Red Hat