Camel
  1. Camel
  2. CAMEL-3697

XPath expression should accept an expression to more easily allow dynamic XPath text to be defined in the DSL

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.6.0
    • Fix Version/s: 3.0.0, Future
    • Component/s: camel-core
    • Labels:
      None

      Description

      See
      http://stackoverflow.com/questions/5067634/xpath-from-string

      In the ExpressionClause the xpath builder is only accepting a String as they XPath text. We should provide a method which accepts a Camel Expression as well.

      So you can do

        .when().xpath(simple("/foo:${header.variable}")).to("mock:y")
      
      1. CAMEL-3697.txt
        10 kB
        Claus Ibsen

        Issue Links

          Activity

          Hide
          Claus Ibsen added a comment -

          Ah we got that already as you can use function in the xpath expression:

          .when().xpath("/foo:function:header('variable')").to("mock:y")
          
          Show
          Claus Ibsen added a comment - Ah we got that already as you can use function in the xpath expression: .when().xpath( "/foo:function:header('variable')" ).to( "mock:y" )
          Hide
          Claus Ibsen added a comment -

          Okay it requires a bit work to support additional expressions in the existing languages. But I got this prototype up and running in Java DSL

                          from("direct:start").
                                  filter().xpath(simple("/person[@name='${header.name}']")).
                                  to("mock:result");
          

          Notice how we use the simple language to construct the xpath expressions string. For that you can use any of the languages, for example Groovy, etc.

          Show
          Claus Ibsen added a comment - Okay it requires a bit work to support additional expressions in the existing languages. But I got this prototype up and running in Java DSL from( "direct:start" ). filter().xpath(simple( "/person[@name='${header.name}']" )). to( "mock:result" ); Notice how we use the simple language to construct the xpath expressions string. For that you can use any of the languages, for example Groovy, etc.
          Hide
          Claus Ibsen added a comment -

          Work in progress

          Show
          Claus Ibsen added a comment - Work in progress
          Hide
          Claus Ibsen added a comment -

          This is an API change in the DSL, so lets wait for Camel 3.0.

          Show
          Claus Ibsen added a comment - This is an API change in the DSL, so lets wait for Camel 3.0.

            People

            • Assignee:
              Unassigned
              Reporter:
              Claus Ibsen
            • Votes:
              3 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:

                Development