ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » String Tokenizer Function in ESQL

Post new topic  Reply to topic
 String Tokenizer Function in ESQL « View previous topic :: View next topic » 
Author Message
DanielSonFocus
PostPosted: Wed Jun 08, 2005 6:07 pm    Post subject: String Tokenizer Function in ESQL Reply with quote

Apprentice

Joined: 05 Jun 2005
Posts: 35
Location: Louisville, Kentucky

Given this from InputRoot:
<xml>: 1: 2: 3: 4: 5: 6: 7:<xml>

i'd like to create this in my OutputRoot:
<xml>
<a>1</a>
<b>2</b>
<c>3</c>
<d>4</d>
<e>5</e>
<f>6</f>
<g>7</g>
</xml>

i'd like some String Tokenizing function similar to java.lang.StringTokenizer.. anyone know where i can find this?
Back to top
View user's profile Send private message
martinrydman
PostPosted: Wed Jun 08, 2005 10:52 pm    Post subject: Reply with quote

Centurion

Joined: 30 Jan 2004
Posts: 139
Location: Gothenburg, Sweden

No, but I've put together a Split function which is rough but does the job. Looks like this:

Code:

/*
========================================================================================
PROCEDURE Split
========================================================================================
Splits S on Delim into an array in Env (Environment.Split.Array[])
Removes Environment.Split before refilling it
*/
CREATE PROCEDURE Split (IN S CHARACTER, IN Env REFERENCE, IN Delim CHARACTER)
BEGIN
   DECLARE P INTEGER;
   DECLARE Idx INTEGER 1;

   SET Env.Split = NULL;
   
   REPEAT
      SET P = POSITION(Delim IN S);
      IF P = 0 THEN
         SET Env.Split.Array[Idx] = S;
      ELSE
         SET Env.Split.Array[Idx] = LEFT(S, P - 1);
         SET S = SUBSTRING(S FROM P + LENGTH(Delim));
         SET Idx = Idx + 1;
      END IF;
   UNTIL P = 0
      
   END REPEAT;   

END;


In your case, it should work. Only thing to note is that you have both a leading and trailing ':'.

Also, note that Env is passed as a parameter. This is because Split resides in separate routine library. If you put Split into your COMPUTE MODULE, you won't need to pass Environment, since it would then be within scope.

/Martin
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Jun 09, 2005 3:24 am    Post subject: Re: String Tokenizer Function in ESQL Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

DanielSonFocus wrote:
<xml>: 1: 2: 3: 4: 5: 6: 7:<xml>


I don't think that's valid XML.

You could certainly model it in MRM, though, then you wouldn't need to play around with position and substring.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
DanielSonFocus
PostPosted: Thu Jun 09, 2005 1:01 pm    Post subject: Reply with quote

Apprentice

Joined: 05 Jun 2005
Posts: 35
Location: Louisville, Kentucky

wow thanks for the input Martin... function works great!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » String Tokenizer Function in ESQL
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.