Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Where we use the xpath function concat to prefix the order name with foo-. In this case we have to specify that we want a String as result type so the concat function works.

Using XPath on Headers

Available as of Camel 2.11

Some users may have XML stored in a header. To apply an XPath to a header's value you can do this by defining the 'headerName' attribute.

In Blueprint DSL :

Code Block
langxml

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
           xmlns:foo="http://example.com/person"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="
             http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">

  <camelContext id="xpathHeaderNameTest" xmlns="http://camel.apache.org/schema/blueprint">
    <route>
      <from uri="direct:in"/>
      <choice>
        <when>
          <xpath headerName="invoiceDetails">/invoice/@orderType = 'premium'</xpath>
          <to uri="mock:premium"/>
        </when>
        <when>
          <xpath headerName="invoiceDetails">/invoice/@orderType = 'standard'</xpath>
          <to uri="mock:standard"/>
        </when>
        <otherwise>
          <to uri="mock:unknown"/>
        </otherwise>
      </choice>
    </route>
  </camelContext>

</blueprint>

Examples

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

...