Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

You can use XPath expressions directly using smart completion in your IDE as follows

...

Variables

Variable

Type

Description

this

Exchange

the Exchange object

in

Message

the exchange.in message

out

Message

the exchange.out message

...

If you prefer to configure your routes in your Spring XML file then you can use JXPath expressions as follows

...

Examples

Here is a simple example using a JXPath expression as a predicate in a Message Filter

...

...

JXPath injection

You can use Bean Integration to invoke a method on a bean and use various languages such as JXPath to extract a value from the message and bind it to a method parameter.

For example

...

...

Loading script from external resource

...

You can externalize the script and have Camel load it from a resource such as "classpath:", "file:", or "http:".
This is done using the following syntax: "resource:scheme:location", eg to refer to a file on the classpath you can do:

...

...

Dependencies

To use JXpath in your camel routes you need to add the a dependency on camel-jxpath which implements the JXpath language.

If you use maven you could just add the following to your pom.xml, substituting the version number for the latest & greatest release (see the download page for the latest versions).

...

...

Otherwise, you'll also need Commons JXPath.