camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: XPathBuilder Does not work when a Namespace is present in XML message
Date Sun, 14 Mar 2010 13:54:40 GMT
On Sun, Mar 14, 2010 at 12:41 PM, ssenth <seshanmugham@eur.ko.com> wrote:
>
> Claus,
> I saw that. the issue my input xml comes with no prefix, For which I tried
> to add the below code
> xpathBuilder.getNamespaceContext().add(null,
> "http://www.basis.ko.com/XMLSchemas/EventMessage/2.0")
>
> But the problem is not resolved. Is there a way to make the route namespace
> aware to false?
>

Check up with XPath in the JDK as its basically that what is used.
And maybe check some of the unit tests in Camel.
And as always we love contributions for both the code and wiki documentation.


And besides XML + namespaces + XPATH is not only my list of technology
stack which is so fun to mess with that I want to do that in my spare
time :)



>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> You have to pass in Namespaces to the XPathBuilder.
>>
>> See the section Namespaces on its wiki page
>> http://camel.apache.org/xpath
>>
>>
>>
>> On Sun, Mar 14, 2010 at 12:23 PM, ssenth <seshanmugham@eur.ko.com> wrote:
>>>
>>> Hello,
>>> I am new CAMEL user facing diffculty in getting my XPAT matched to my
>>> input
>>> XML.
>>> Below is the pice of code whith I uses to find if the Exchange has the
>>> matching Xpath
>>>
>>> private boolean isBusinessObjectMatches(final Exchange exchange)
>>> {
>>>        final String expression =
>>> "/EventMessage/MessageHeader/BusinessObjectName='Adjustment'";
>>>             final XPathBuilder xpathBuilder =
>>> XPathBuilder.xpath(expression);
>>>        return xpathBuilder.matches(exchange))
>>> }
>>>
>>> Here is my input message which is present in the Exchange, for this the
>>> xpathBuilder.matches(exchange))always returns false.
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <EventMessage xmlns="http://www.basis.ko.com/XMLSchemas/EventMessage/2.0"
>>> xmlns:docu="http://www.basis.ko.com/XML/2002/SchemaDocumentation"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xsi:schemaLocation="http://www.basis.ko.com/XMLSchemas/EventMessage/2.0
>>> C:\DOCUME~1\N13112\MYDOCU~1\workspace\EVENTD~1\Mappings\BasisSchemas\Modified\EventMessage_Adjustment.xsd">
>>>        <MessageHeader>
>>>                <EventMessageID>AdjustmentUpdated</EventMessageID>
>>>                <BusinessObjectName>Adjustment</BusinessObjectName>
>>>                <Action>update adjustment</Action>
>>>        </MessageHeader>
>>> <EventMessage>
>>>
>>> But for when I remove the name space from my input XML the
>>> xpathBuilder.matches(exchange)) work fine example
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <EventMessage>
>>>        <MessageHeader>
>>>                <EventMessageID>AdjustmentUpdated</EventMessageID>
>>>                <BusinessObjectName>Adjustment</BusinessObjectName>
>>>                <Action>update adjustment</Action>
>>>        </MessageHeader>
>>> <EventMessage>
>>>
>>> Can any one please let me know why this is happening and how to
>>> xpathBuilder.matches(exchange))  to work with the namespace in the input
>>> message?
>>> --
>>> View this message in context:
>>> http://old.nabble.com/XPathBuilder-Does-not-work-when-a-Namespace-is-present-in-XML-message-tp27894300p27894300.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
> --
> View this message in context: http://old.nabble.com/XPathBuilder-Does-not-work-when-a-Namespace-is-present-in-XML-message-tp27894300p27894385.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message