| Author | Message | 
		
		  | angka | 
			  
				|  Posted: Mon Apr 28, 2008 2:20 am    Post subject: Content Based Routing |   |  | 
		
		  | Chevalier
 
 
 Joined: 20 Sep 2005Posts: 406
 
 
 | 
			  
				| Hi all, 
 I would like to route messages base on content. Incoming messages are in xml format. I will briefly describe what is needed.
 e.g.
 <Message>
 <a>test1</a>
 <b>
 <c>test2</c>
 <d>test3</d>
 </b>
 </Message>
 
 above is just one example of the message. The content based routing could be any of the tag which is kept in the database. the message flow will access the database to find out for one particular message, which tag it is comparing the value. e.g. tag <c> must be 'test2'. so when i retrieved from the database, how to i find tag <c> and get its value? I intend to use FIELDNAME function but how to i loop thru the whole xml message and get the value?
 
 Thank you.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Gaya3 | 
			  
				|  Posted: Mon Apr 28, 2008 2:26 am    Post subject: Re: Content Based Routing |   |  | 
		
		  |  Jedi
 
 
 Joined: 12 Sep 2006Posts: 2493
 Location: Boston, US
 
 | 
			  
				| 
   
	| angka wrote: |  
	| I intend to use FIELDNAME function but how to i loop thru the whole xml message and get the value?
 
 Use LASTMOVE option to do so,
 
 
 |  
 Regards
 gayathri
 _________________
 Regards
 Gayathri
 -----------------------------------------------
 Do Something Before you Die
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | angka | 
			  
				|  Posted: Mon Apr 28, 2008 3:55 am    Post subject: |   |  | 
		
		  | Chevalier
 
 
 Joined: 20 Sep 2005Posts: 406
 
 
 | 
			  
				| Hi, 
 When i access DB, i will get value like 'InputRoot.XML.Message.b.c' which is string. how to I loop thru the message to get the value for 'InputRoot.XML.Message.b.c'?
 
 Using LASTMOVE how can it help?
 
 Thanks
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | AkankshA | 
			  
				|  Posted: Mon Apr 28, 2008 3:59 am    Post subject: |   |  | 
		
		  |  Grand Master
 
 
 Joined: 12 Jan 2006Posts: 1494
 Location: Singapore
 
 | 
			  
				| guess we understood you wrongly... 
 
 pls explain the reqt a lil more elaborately.. as i m a lil confused there
 _________________
 Cheers
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | AkankshA | 
			  
				|  Posted: Mon Apr 28, 2008 4:07 am    Post subject: |   |  | 
		
		  |  Grand Master
 
 
 Joined: 12 Jan 2006Posts: 1494
 Location: Singapore
 
 | 
			  
				| if i have understood clearly 
 u get the path to traverse from DB and need 2 get the value of that in i/p msg
 
 if yes then u can
 
 get the string from db
 using substring remove 'InputRoot.XML.Message or rather get the remaining part
 
 after that u might want to read about significance of  {} in traversing tree..
 
 
 kindly ignore if this is not in accordance with your need
 _________________
 Cheers
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Vitor | 
			  
				|  Posted: Mon Apr 28, 2008 4:08 am    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 11 Nov 2005Posts: 26093
 Location: Texas, USA
 
 | 
			  
				| 
   
	| angka wrote: |  
	| When i access DB, i will get value like 'InputRoot.XML.Message.b.c' which is string. how to I loop thru the message to get the value for 'InputRoot.XML.Message.b.c'? 
 Using LASTMOVE how can it help?
 
 |  
 You have 2 choices:
 
 If you have a full path to the desired field (either as above or "Message.b.c" which you can make a full path) then you can obtain it directly
 
 or
 
 if all you have is "c" then make a loop using LASTMOVE to terminiate it, and walk through the message until the field name matches.
 _________________
 Honesty is the best policy.
 Insanity is the best defence.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | angka | 
			  
				|  Posted: Mon Apr 28, 2008 4:46 am    Post subject: |   |  | 
		
		  | Chevalier
 
 
 Joined: 20 Sep 2005Posts: 406
 
 
 | 
			  
				| Hi AkankshA, 
 Ya I will get the tag e.g 'c' and its value 'Test2' from DataBase and if the message fit this criteria, i will route to the recipient.
 What you mean by '{} in traversing tree'? Cant find anything.
 
 Hi Victor,
 How do I obtain directly?? it is in string format becos i retrieved from DB.
 E.g.
 
 DECLARE A AS CHAR;
 SET A = 'InputRoot.XML.Message.b.c';
 How do i get the value for this 'InputRoot.XML.Message.b.c'?
 
 As for you second choice, you mean i use FIELDNAME to compare through all the tag??
 
 Thanks both..
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Vitor | 
			  
				|  Posted: Mon Apr 28, 2008 5:08 am    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 11 Nov 2005Posts: 26093
 Location: Texas, USA
 
 | 
			  
				| 
   
	| angka wrote: |  
	| How do I obtain directly?? it is in string format becos i retrieved from DB. |  
 Look up the EVAL function (not statement) in the ESQL reference. This is possibly the simplist way, but is not especially efficient
 
 
 
   
	| angka wrote: |  
	| As for you second choice, you mean i use FIELDNAME to compare through all the tag?? |  
 If all you know is the tag name. This method's going to cost a bit of CPU as well.
 _________________
 Honesty is the best policy.
 Insanity is the best defence.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | jefflowrey | 
			  
				|  Posted: Mon Apr 28, 2008 5:24 am    Post subject: |   |  | 
		
		  | Grand Poobah
 
 
 Joined: 16 Oct 2002Posts: 19981
 
 
 | 
			  
				| You may want to consider storing an XPath expression in the database, instead of a field name. 
 Then you can evaluate that, instead of writing your own complicated logic to build and parse an expression.
 _________________
 I am *not* the model of the modern major general.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | angka | 
			  
				|  Posted: Mon Apr 28, 2008 7:31 am    Post subject: |   |  | 
		
		  | Chevalier
 
 
 Joined: 20 Sep 2005Posts: 406
 
 
 | 
			  
				| Hi, 
 Does MQ MB support  XPath expression? And I will look into EVAL function.
 
 Thanks
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Vitor | 
			  
				|  Posted: Mon Apr 28, 2008 12:54 pm    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 11 Nov 2005Posts: 26093
 Location: Texas, USA
 
 | 
			  
				| 
   
	| angka wrote: |  
	| Does MQ MB support  XPath expression? |  
 v6.1 certainly does
 _________________
 Honesty is the best policy.
 Insanity is the best defence.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | jefflowrey | 
			  
				|  Posted: Mon Apr 28, 2008 12:59 pm    Post subject: |   |  | 
		
		  | Grand Poobah
 
 
 Joined: 16 Oct 2002Posts: 19981
 
 
 | 
			  
				| 
   
	| Vitor wrote: |  
	| 
   
	| angka wrote: |  
	| Does MQ MB support  XPath expression? |  
 v6.1 certainly does
 |  
 Introduced in v6.0, actually.
 
 Very handy.
 _________________
 I am *not* the model of the modern major general.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Vitor | 
			  
				|  Posted: Mon Apr 28, 2008 1:05 pm    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 11 Nov 2005Posts: 26093
 Location: Texas, USA
 
 | 
			  
				| 
   
	| jefflowrey wrote: |  
	| Introduced in v6.0, actually. |  
 I thought that, but didn't want to spread my possibly deluded view
 _________________
 Honesty is the best policy.
 Insanity is the best defence.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Bill.Matthews | 
			  
				|  Posted: Tue Apr 29, 2008 5:24 am    Post subject: |   |  | 
		
		  |  Master
 
 
 Joined: 23 Sep 2003Posts: 232
 Location: IBM (Retired)
 
 | 
			  
				| 
   
	| jefflowrey wrote: |  
	| 
   
	| Vitor wrote: |  
	| 
   
	| angka wrote: |  
	| Does MQ MB support  XPath expression? |  
 v6.1 certainly does
 |  
 Introduced in v6.0, actually.
 
 Very handy.
 |  
 Runtime evaluation of XPath expressions in 6.0 us only for Java..  In 6.1, that capability is also used by some of the new nodes ...
 
 It is not provided for ESQL.
 _________________
 Bill Matthews
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | jefflowrey | 
			  
				|  Posted: Tue Apr 29, 2008 5:26 am    Post subject: |   |  | 
		
		  | Grand Poobah
 
 
 Joined: 16 Oct 2002Posts: 19981
 
 
 | 
			  
				| 
   
	| Bill.Matthews wrote: |  
	| It is not provided for ESQL. |  
 It's not hard to write a Java procedure to call from ESQL...
  _________________
 I am *not* the model of the modern major general.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  |  |