Author |
Message
|
jeeth_m |
Posted: Mon Aug 18, 2008 7:11 am Post subject: delimited fields in xml tag |
|
|
Voyager
Joined: 21 Jan 2002 Posts: 93
|
Hi,
I have are requirement to parse comma delimited fields within an xml tag.
Input xml tag is going to be:
<Body>
<ModifiedFields>EmpName,EmpID,EmpAddress</ModifiedFields>
</Body>
I have to parse this tag and come up with an output based on occurence of
comma delimited values:
<Body>
<Field>EmpName</Field>
<Field>EmpID</Field>
<Field>EmpAddress</Field>
</Body>
Is there any ESQL funtion which can be used to acheive this?
Regards,
Jeeth |
|
Back to top |
|
 |
jeeth_m |
Posted: Mon Aug 18, 2008 9:03 am Post subject: |
|
|
Voyager
Joined: 21 Jan 2002 Posts: 93
|
I did some coding to achieve the same.
DECLARE Source CHAR InputRoot.XML.Body.ModifiedFields;
DECLARE DelimiterPos INT 1;
DECLARE Delimiter CHAR ',';
DECLARE COUNT INT 1;
WHILE(DelimiterPos <> 0)
DO
SET DelimiterPos = POSITION(Delimiter IN Source);
IF (DelimiterPos = 0) THEN
SET OutputRoot.XML.Body.Result[COUNT] = Source;
ELSE
SET OutputRoot.XML.Body.Result[COUNT] = SUBSTRING(Source FROM 1 FOR DelimiterPos - 1 );
SET WorkingSource = SUBSTRING(Source FROM DelimiterPos + 1);
END IF;
SET COUNT = COUNT + 1;
END WHILE;
RETURN TRUE;
END; |
|
Back to top |
|
 |
vaibhav_vy |
Posted: Mon Aug 18, 2008 9:10 pm Post subject: |
|
|
Apprentice
Joined: 04 Aug 2008 Posts: 28
|
|
Back to top |
|
 |
vaibhav_vy |
Posted: Mon Aug 18, 2008 9:16 pm Post subject: |
|
|
Apprentice
Joined: 04 Aug 2008 Posts: 28
|
AFAIK, there is no such ESQL function that will parse the delimited field & return subfields.
(Something like we have StringTokenizer in Java.) |
|
Back to top |
|
 |
kimbert |
Posted: Thu Aug 21, 2008 3:26 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
It would be a lot easier if the message used a repeating tag instead of a delimited list. I realise that you probably cannot do anything about the input format.
If you only have 3 delimited fields then use ESQL to split the fields.
If the format gets complex, you should create a message set and parse the string using CREATE...PARSE. |
|
Back to top |
|
 |
dkeister |
Posted: Thu Aug 21, 2008 7:26 am Post subject: |
|
|
Disciple
Joined: 25 Mar 2002 Posts: 184 Location: Purchase, New York
|
Why not extract the 'payload' from <ModifiedFields> in one node and using Reset Content Descriptor have it parsed with a message set that defines the comma deleted fields?
<ModifiedFields>EmpName,EmpID,EmpAddress</ModifiedFields> _________________ Dean Keister |
|
Back to top |
|
 |
jeeth_m |
Posted: Wed Aug 27, 2008 7:14 am Post subject: |
|
|
Voyager
Joined: 21 Jan 2002 Posts: 93
|
Hi,
Quote: |
If you only have 3 delimited fields then use ESQL to split the fields. |
There could be a maximum of 10 fields.
.
Quote: |
create a message set and parse the string using CREATE...PARSE. |
I dont know how it works.. but will try
Quote: |
using Reset Content Descriptor have it parsed with a message set that |
RCD is always expensive. atleast that is what i was told. Please correct me if i am wrong |
|
Back to top |
|
 |
dkeister |
Posted: Wed Aug 27, 2008 11:56 am Post subject: |
|
|
Disciple
Joined: 25 Mar 2002 Posts: 184 Location: Purchase, New York
|
Creating another MRM message set for comma delimited is pretty straight forward.
Can't comment on the performance implications of RCD but I would imagine the size of the file being parsed would be the major variable. Hopefully some smart person will enlighten us. _________________ Dean Keister |
|
Back to top |
|
 |
|