FAQ
Hi,

I am using Camel's Spring DSL, to write a simple application, that takes
xml, and splits it based on the xpath. It should be pretty straightforward;
there is only one extra step that I have, which is declaring a namespace.
The problem is that although xpath recognizes the element that I'm looking
for, it returns a null for the value.
Here's a sample xml, to give you a general idea of what I'm doing. (Notice
that it has an associated namespace)

<foo:foo>

<foo:bar>
<foo:id idScheme="12345">1</foo:id>
</foo:bar>

<foo:bar>
<foo:id idScheme="45678">2</foo:id>
</foo:bar>

</foo:foo>

Here's my route:
<route>
<from uri="direct:start">
<split>
<xpath>/foo:foo/foo:bar/</xpath>
<to uri="mock:result"/>
</split>
</route>

As I mentioned before, I declare the namespace, in the bean context of
spring.
<beans...............................
xmlns:foo="some URL"
xmlns:bar="some URL"
>
And I get the expected number of results from xpath, but null values. Any
idea where I'm going wrong? Any help would be greatly appreciated! Thanks!



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Splitter-with-Xpath-recognizes-namespace-but-returns-null-tp4682976p4682976.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Search Discussions

  • Jean-Baptiste Onofré at Aug 9, 2011 at 6:42 pm
    Hi,

    could you try with a different xpath:

    //bar

    AFAIR, xpath can ignore the namespace.

    Regards
    JB
    On 08/09/2011 07:57 PM, klua wrote:
    Hi,

    I am using Camel's Spring DSL, to write a simple application, that takes
    xml, and splits it based on the xpath. It should be pretty straightforward;
    there is only one extra step that I have, which is declaring a namespace.
    The problem is that although xpath recognizes the element that I'm looking
    for, it returns a null for the value.
    Here's a sample xml, to give you a general idea of what I'm doing. (Notice
    that it has an associated namespace)

    <foo:foo>

    <foo:bar>
    <foo:id idScheme="12345">1</foo:id>
    </foo:bar>

    <foo:bar>
    <foo:id idScheme="45678">2</foo:id>
    </foo:bar>

    </foo:foo>

    Here's my route:
    <route>
    <from uri="direct:start">
    <split>
    <xpath>/foo:foo/foo:bar/</xpath>
    <to uri="mock:result"/>
    </split>
    </route>

    As I mentioned before, I declare the namespace, in the bean context of
    spring.
    <beans...............................
    xmlns:foo="some URL"
    xmlns:bar="some URL"
    And I get the expected number of results from xpath, but null values. Any
    idea where I'm going wrong? Any help would be greatly appreciated! Thanks!



    --
    View this message in context: http://camel.465427.n5.nabble.com/Camel-Splitter-with-Xpath-recognizes-namespace-but-returns-null-tp4682976p4682976.html
    Sent from the Camel - Users mailing list archive at Nabble.com.
    --
    Jean-Baptiste Onofré
    jbonofre@apache.org
    http://blog.nanthrax.net
    Talend - http://www.talend.com
  • Christian Müller at Aug 12, 2011 at 9:54 pm
    Did you had already a look on [1]? May one of the other possibilities works
    for you:
    - declaring the namespace on the camel context element (instead of the beans
    element)
    - specifying the xPath result type

    [1] http://camel.apache.org/xpath.html

    Best,
    Christian

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupusers @
categoriescamel
postedAug 9, '11 at 5:59p
activeAug 12, '11 at 9:54p
posts3
users3
websitecamel.apache.org

People

Translate

site design / logo © 2022 Grokbase