|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
WMQI - Split string by delimiters |
« View previous topic :: View next topic » |
Author |
Message
|
emoynihan |
Posted: Thu Nov 20, 2003 3:02 am Post subject: WMQI - Split string by delimiters |
|
|
Newbie
Joined: 20 Nov 2003 Posts: 3
|
Hi there!
I have an XML element which contains any number of numeric fields each delimited by a comma.
I'm trying to unpack this string and create a new bunch of XML elements for each number, discarding the comma delimiters in the process.
(So, for example, '123,678,351' results in the creation of 3 fields containing Field 1 = 123 Field 2 = 678 and Field 3 = 351).
However I cannot find any command to do this, as you can in most scripting languages....
Any suggestion?
Thanks!!  |
|
Back to top |
|
 |
zpat |
Posted: Thu Nov 20, 2003 3:56 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
I am not a WMQI message flow developer, but could you not do something like use Reset Content Descriptor to re-parse it as a delimited data type?
Delimited data is one of the supported formats in WMQI 2.1 and above. |
|
Back to top |
|
 |
kingsley |
Posted: Thu Nov 20, 2003 6:01 am Post subject: |
|
|
Disciple
Joined: 30 Sep 2001 Posts: 175 Location: Hursley
|
You need to use ESQL.
Otherwise, extract the string and send it through another message flow, which uses Tagged Delimited format which converts to XML.
Then combine the flow to the mainflow. this is a big round way method unless you have off the shelf flow to handle this. |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Nov 20, 2003 6:10 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You can use the Substring and Position ESQL functions to extract each of your elements.
But you are correct, there is no "split" or "strtok" or other such "convert a string into a list of strings, separated at a specified delimiter" function built in.
At least not in 2.1 or earlier. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Missam |
Posted: Thu Nov 20, 2003 11:27 am Post subject: |
|
|
Chevalier
Joined: 16 Oct 2003 Posts: 424
|
Hi
You can do this by writing loop
Here is the example i'm giving,you can modify this according your needs.
Declare value Character;
Declare Num Integer;
SET value = InputRoot.XML.Number;
Declare pos Integer;
Declare SubVal Character;
Set SubVal = value;
SET pos = Position(',' IN SubVal);
While (pos > 0) DO
Set Num = Substring(SubVal from 1 for (pos-1));
Create LastChild Of OutputRoot.XML.Number DOMAIN 'XML'NAME 'Field';
Set OutputRoot.XML.Number."Field"[LAST] = Num;
Set SubVal = Substring(SubVal From (pos+1));
Set pos = Position(',' IN SubVal);
END WHILE;
Create LastChild Of OutputRoot.XML.Number DOMAIN 'XML'NAME 'Field';
Set OutputRoot.XML.Number."Field"[LAST] = CAST(SubVal AS Integer);
Thanx
Sam |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|