You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by St...@barclayscapital.com on 2010/09/23 18:15:31 UTC

Problem with XPATH filtering

Hi 
 
I am currently evaluating Camel for use on a project.  I am having a problem with xpath filtering - which always returns false even if the xpath matches the inbound document.
 
So I have the following route definition:
 
public void configure() throws Exception {

from("jms:queue:TEST.QUEUE.SRH")
	.process(new Logger())
	.filter()
		.xpath("//party[@id='compression' or @id='TriOptima']")
			.process(new Logger("after filter"))
	.choice()
		.when().xpath("//termination")
			.process(new Logger("TERMINATION"))
			.to("file:FOO")
		.when().xpath("/STPTradeML/FpML/trade")
			.process(new Logger("NEW TRADE "))
			.to("file:BAR")
		.otherwise()
			.process(new Logger("otherwise "))
			.to("file:LOGGER")
	.to("file:c://output.log");
}

Then I send in a message which matches the first xpath (tested in XML Spy).  Tracking through the code shows that this results in an answer of false.  

Are there any current known issues with xpath filtering?  Do I need to use namespaces, for example?

Any help or pointers you can provide would be welcome

Steve Hedges

_______________________________________________

This e-mail may contain information that is confidential, privileged or otherwise protected from disclosure. If you are not an intended recipient of this e-mail, do not duplicate or redistribute it by any means. Please delete it and any attachments and notify the sender that you have received it in error. Unless specifically indicated, this e-mail is not an offer to buy or sell or a solicitation to buy or sell any securities, investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Barclays. Any views or opinions presented are solely those of the author and do not necessarily represent those of Barclays. This e-mail is subject to terms available at the following link: www.barcap.com/emaildisclaimer. By messaging with Barclays you consent to the foregoing.  Barclays Capital is the investment banking division of Barclays Bank PLC, a company registered in England (number 1026167) with its registered office at 1 Churchill Place, London, E14 5HP.  This email may relate to or be sent from other members of the Barclays Group.
_______________________________________________

RE: Problem with XPATH filtering

Posted by St...@barclayscapital.com.
Claus

Thanks very much 


 
Steven Hedges
-----Original Message-----
From: Claus Ibsen [mailto:claus.ibsen@gmail.com] 
Sent: 24 September 2010 16:40
To: users@camel.apache.org
Subject: Re: Problem with XPATH filtering

Hi

You are using namespaces in your XML and therefore the XPath expression must use namespace as well.

See this unit test for example
http://svn.apache.org/viewvc?rev=1000916&view=rev



On Fri, Sep 24, 2010 at 11:14 AM,  <St...@barclayscapital.com> wrote:
> Willem
>
> Attached are sample XMLs, config and java code which replicates the problem.  Unfortunately I don't know how to read from a file (I'm very new to this) and so it still depends on JMS.
>
> I am using Camel version 2.5-SNAPSHOT.
>
> Thanks for your help
>
>
>
> Steven Hedges
>
>
> -----Original Message-----
> From: Willem Jiang [mailto:willem.jiang@gmail.com]
> Sent: 24 September 2010 02:26
> To: users@camel.apache.org
> Subject: Re: Problem with XPATH filtering
>
> Hi
>
> Which version of Camel are you using?
> Can you submit a simple test case to reproduce this error into the JIRA?
> So we can dig the issue more quickly.
>
> On 9/24/10 12:15 AM, Steve.Hedges@barclayscapital.com wrote:
>> Hi
>>
>> I am currently evaluating Camel for use on a project.  I am having a problem with xpath filtering - which always returns false even if the xpath matches the inbound document.
>>
>> So I have the following route definition:
>>
>> public void configure() throws Exception {
>>
>> from("jms:queue:TEST.QUEUE.SRH")
>>       .process(new Logger())
>>       .filter()
>>               .xpath("//party[@id='compression' or @id='TriOptima']")
>>                       .process(new Logger("after filter"))
>>       .choice()
>>               .when().xpath("//termination")
>>                       .process(new Logger("TERMINATION"))
>>                       .to("file:FOO")
>>               .when().xpath("/STPTradeML/FpML/trade")
>>                       .process(new Logger("NEW TRADE "))
>>                       .to("file:BAR")
>>               .otherwise()
>>                       .process(new Logger("otherwise "))
>>                       .to("file:LOGGER")
>>       .to("file:c://output.log");
>> }
>>
>> Then I send in a message which matches the first xpath (tested in XML Spy).  Tracking through the code shows that this results in an answer of false.
>>
>> Are there any current known issues with xpath filtering?  Do I need to use namespaces, for example?
>>
>> Any help or pointers you can provide would be welcome
>>
>> Steve Hedges
>>
>> _______________________________________________
>>
>> This e-mail may contain information that is confidential, privileged 
>> or otherwise protected from disclosure. If you are not an intended 
>> recipient of this e-mail, do not duplicate or redistribute it by any 
>> means. Please delete it and any attachments and notify the sender 
>> that you have received it in error. Unless specifically indicated, 
>> this e-mail is not an offer to buy or sell or a solicitation to buy 
>> or sell any securities, investment products or other financial 
>> product or service, an official confirmation of any transaction, or 
>> an official statement of Barclays. Any views or opinions presented 
>> are solely those of the author and do not necessarily represent those 
>> of Barclays. This e-mail is subject to terms available at the 
>> following
>> link: www.barcap.com/emaildisclaimer. By messaging with Barclays you 
>> consent to the foregoing.  Barclays Capital is the investment banking 
>> division of Barclays Bank PLC, a company registered in England 
>> (number
>> 1026167) with its registered off
> ice at 1 Churchill Place, London, E14 5HP.  This email may relate to or be sent from other members of the Barclays Group.
>> _______________________________________________
>>
>
>
> --
> Willem
> ----------------------------------
> Apache Camel, Apache CXF committer
> Open Source Integration: http://www.fusesource.com
> Blog:    http://willemjiang.blogspot.com (English)
>          http://jnn.javaeye.com (Chinese)
> Twitter: http://twitter.com/willemjiang
>



--
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

Re: Problem with XPATH filtering

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You are using namespaces in your XML and therefore the XPath
expression must use namespace as well.

See this unit test for example
http://svn.apache.org/viewvc?rev=1000916&view=rev



On Fri, Sep 24, 2010 at 11:14 AM,  <St...@barclayscapital.com> wrote:
> Willem
>
> Attached are sample XMLs, config and java code which replicates the problem.  Unfortunately I don't know how to read from a file (I'm very new to this) and so it still depends on JMS.
>
> I am using Camel version 2.5-SNAPSHOT.
>
> Thanks for your help
>
>
>
> Steven Hedges
>
>
> -----Original Message-----
> From: Willem Jiang [mailto:willem.jiang@gmail.com]
> Sent: 24 September 2010 02:26
> To: users@camel.apache.org
> Subject: Re: Problem with XPATH filtering
>
> Hi
>
> Which version of Camel are you using?
> Can you submit a simple test case to reproduce this error into the JIRA?
> So we can dig the issue more quickly.
>
> On 9/24/10 12:15 AM, Steve.Hedges@barclayscapital.com wrote:
>> Hi
>>
>> I am currently evaluating Camel for use on a project.  I am having a problem with xpath filtering - which always returns false even if the xpath matches the inbound document.
>>
>> So I have the following route definition:
>>
>> public void configure() throws Exception {
>>
>> from("jms:queue:TEST.QUEUE.SRH")
>>       .process(new Logger())
>>       .filter()
>>               .xpath("//party[@id='compression' or @id='TriOptima']")
>>                       .process(new Logger("after filter"))
>>       .choice()
>>               .when().xpath("//termination")
>>                       .process(new Logger("TERMINATION"))
>>                       .to("file:FOO")
>>               .when().xpath("/STPTradeML/FpML/trade")
>>                       .process(new Logger("NEW TRADE "))
>>                       .to("file:BAR")
>>               .otherwise()
>>                       .process(new Logger("otherwise "))
>>                       .to("file:LOGGER")
>>       .to("file:c://output.log");
>> }
>>
>> Then I send in a message which matches the first xpath (tested in XML Spy).  Tracking through the code shows that this results in an answer of false.
>>
>> Are there any current known issues with xpath filtering?  Do I need to use namespaces, for example?
>>
>> Any help or pointers you can provide would be welcome
>>
>> Steve Hedges
>>
>> _______________________________________________
>>
>> This e-mail may contain information that is confidential, privileged
>> or otherwise protected from disclosure. If you are not an intended
>> recipient of this e-mail, do not duplicate or redistribute it by any
>> means. Please delete it and any attachments and notify the sender that
>> you have received it in error. Unless specifically indicated, this
>> e-mail is not an offer to buy or sell or a solicitation to buy or sell
>> any securities, investment products or other financial product or
>> service, an official confirmation of any transaction, or an official
>> statement of Barclays. Any views or opinions presented are solely
>> those of the author and do not necessarily represent those of
>> Barclays. This e-mail is subject to terms available at the following
>> link: www.barcap.com/emaildisclaimer. By messaging with Barclays you
>> consent to the foregoing.  Barclays Capital is the investment banking
>> division of Barclays Bank PLC, a company registered in England (number
>> 1026167) with its registered off
> ice at 1 Churchill Place, London, E14 5HP.  This email may relate to or be sent from other members of the Barclays Group.
>> _______________________________________________
>>
>
>
> --
> Willem
> ----------------------------------
> Apache Camel, Apache CXF committer
> Open Source Integration: http://www.fusesource.com
> Blog:    http://willemjiang.blogspot.com (English)
>          http://jnn.javaeye.com (Chinese)
> Twitter: http://twitter.com/willemjiang
>



-- 
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

RE: Problem with XPATH filtering

Posted by St...@barclayscapital.com.
Willem 

Attached are sample XMLs, config and java code which replicates the problem.  Unfortunately I don't know how to read from a file (I'm very new to this) and so it still depends on JMS.

I am using Camel version 2.5-SNAPSHOT.

Thanks for your help


 
Steven Hedges


-----Original Message-----
From: Willem Jiang [mailto:willem.jiang@gmail.com] 
Sent: 24 September 2010 02:26
To: users@camel.apache.org
Subject: Re: Problem with XPATH filtering

Hi

Which version of Camel are you using?
Can you submit a simple test case to reproduce this error into the JIRA?
So we can dig the issue more quickly.

On 9/24/10 12:15 AM, Steve.Hedges@barclayscapital.com wrote:
> Hi
>
> I am currently evaluating Camel for use on a project.  I am having a problem with xpath filtering - which always returns false even if the xpath matches the inbound document.
>
> So I have the following route definition:
>
> public void configure() throws Exception {
>
> from("jms:queue:TEST.QUEUE.SRH")
> 	.process(new Logger())
> 	.filter()
> 		.xpath("//party[@id='compression' or @id='TriOptima']")
> 			.process(new Logger("after filter"))
> 	.choice()
> 		.when().xpath("//termination")
> 			.process(new Logger("TERMINATION"))
> 			.to("file:FOO")
> 		.when().xpath("/STPTradeML/FpML/trade")
> 			.process(new Logger("NEW TRADE "))
> 			.to("file:BAR")
> 		.otherwise()
> 			.process(new Logger("otherwise "))
> 			.to("file:LOGGER")
> 	.to("file:c://output.log");
> }
>
> Then I send in a message which matches the first xpath (tested in XML Spy).  Tracking through the code shows that this results in an answer of false.
>
> Are there any current known issues with xpath filtering?  Do I need to use namespaces, for example?
>
> Any help or pointers you can provide would be welcome
>
> Steve Hedges
>
> _______________________________________________
>
> This e-mail may contain information that is confidential, privileged 
> or otherwise protected from disclosure. If you are not an intended 
> recipient of this e-mail, do not duplicate or redistribute it by any 
> means. Please delete it and any attachments and notify the sender that 
> you have received it in error. Unless specifically indicated, this 
> e-mail is not an offer to buy or sell or a solicitation to buy or sell 
> any securities, investment products or other financial product or 
> service, an official confirmation of any transaction, or an official 
> statement of Barclays. Any views or opinions presented are solely 
> those of the author and do not necessarily represent those of 
> Barclays. This e-mail is subject to terms available at the following 
> link: www.barcap.com/emaildisclaimer. By messaging with Barclays you 
> consent to the foregoing.  Barclays Capital is the investment banking 
> division of Barclays Bank PLC, a company registered in England (number 
> 1026167) with its registered off
ice at 1 Churchill Place, London, E14 5HP.  This email may relate to or be sent from other members of the Barclays Group.
> _______________________________________________
>


--
Willem
----------------------------------
Apache Camel, Apache CXF committer
Open Source Integration: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: http://twitter.com/willemjiang

Re: Problem with XPATH filtering

Posted by Willem Jiang <wi...@gmail.com>.
Hi

Which version of Camel are you using?
Can you submit a simple test case to reproduce this error into the JIRA?
So we can dig the issue more quickly.

On 9/24/10 12:15 AM, Steve.Hedges@barclayscapital.com wrote:
> Hi
>
> I am currently evaluating Camel for use on a project.  I am having a problem with xpath filtering - which always returns false even if the xpath matches the inbound document.
>
> So I have the following route definition:
>
> public void configure() throws Exception {
>
> from("jms:queue:TEST.QUEUE.SRH")
> 	.process(new Logger())
> 	.filter()
> 		.xpath("//party[@id='compression' or @id='TriOptima']")
> 			.process(new Logger("after filter"))
> 	.choice()
> 		.when().xpath("//termination")
> 			.process(new Logger("TERMINATION"))
> 			.to("file:FOO")
> 		.when().xpath("/STPTradeML/FpML/trade")
> 			.process(new Logger("NEW TRADE "))
> 			.to("file:BAR")
> 		.otherwise()
> 			.process(new Logger("otherwise "))
> 			.to("file:LOGGER")
> 	.to("file:c://output.log");
> }
>
> Then I send in a message which matches the first xpath (tested in XML Spy).  Tracking through the code shows that this results in an answer of false.
>
> Are there any current known issues with xpath filtering?  Do I need to use namespaces, for example?
>
> Any help or pointers you can provide would be welcome
>
> Steve Hedges
>
> _______________________________________________
>
> This e-mail may contain information that is confidential, privileged or otherwise protected from disclosure. If you are not an intended recipient of this e-mail, do not duplicate or redistribute it by any means. Please delete it and any attachments and notify the sender that you have received it in error. Unless specifically indicated, this e-mail is not an offer to buy or sell or a solicitation to buy or sell any securities, investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Barclays. Any views or opinions presented are solely those of the author and do not necessarily represent those of Barclays. This e-mail is subject to terms available at the following link: www.barcap.com/emaildisclaimer. By messaging with Barclays you consent to the foregoing.  Barclays Capital is the investment banking division of Barclays Bank PLC, a company registered in England (number 1026167) with its registered off
ice at 1 Churchill Place, London, E14 5HP.  This email may relate to or be sent from other members of the Barclays Group.
> _______________________________________________
>


-- 
Willem
----------------------------------
Apache Camel, Apache CXF committer
Open Source Integration: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: http://twitter.com/willemjiang