Hi

I don't think current camel spring configuration support the xpath with the name space.

You can take a look at Java DSL one from here[1]

[1]https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNestedNamespaceTest.java

Willem

On 3/17/11 12:35 AM, Tom Howe wrote:
Hi, first post here!

We have an instance of apache-activemq running which includes camel.

We are sending some messages to a queue called 'in' that look like this:

<?xml version="1.0" encoding="utf-8"?>
<mp:command xmlns:mp="http://www.blah/blah";  name="submit">
  <body>...</body>
</mp:command>

and

<?xml version="1.0" encoding="utf-8"?>
<mp:event xmlns:mp="http://www.blah/blah";  name="status">
  <body>...</body>
</mp:event>

We need to route the messages based on their root element name and content
of @name
so the above messages need to go to the endpoints called commands.submit and
events.status.

I created the following route to test the @name based matching:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<route autoStartup="true" inheritErrorHandler="true" id="generalin"
xmlns:ns2="http://camel.apache.org/schema/web"; xmlns="
http://camel.apache.org/schema/spring";>
     <from uri="activemq:in"/>
     <choice inheritErrorHandler="true" id="choice1">
         <when inheritErrorHandler="true">
             <xpath>//*[contains(@name,"submit")]</xpath>
             <to uri="activemq:commands.submit" inheritErrorHandler="true"
id="to2"/>
         </when>
         <otherwise inheritErrorHandler="true">
             <to uri="activemq:lostandfound" inheritErrorHandler="true"
id="to4"/>
         </otherwise>
     </choice>
</route>

This route works fine. It routes any messages where name contains 'submit'
to the right endpoint.

I then tried to modify the route so that it matched<mp:command>. I tried
changing the xpath to

<xpath>//command[contains(@name,"submit")]</xpath>
<xpath>//mp:command[contains(@name,"submit")]</xpath>

and neither worked. Also the message did not get routed to anywhere -ie it
didnt go to lostandfound.

I also tried adding xmlns:mp="http://www.blah/blah";  to the<route>  part of
the route definition but it was removed when I saved the route.

Any advice appreciated.

Thanks, Tom



--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
         http://jnn.javaeye.com (Chinese)
Twitter: willemjiang

Reply via email to