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 » Perform a TRIM in an entire XML tree

Post new topic  Reply to topic
 Perform a TRIM in an entire XML tree « View previous topic :: View next topic » 
Author Message
Galichet
PostPosted: Wed Jan 22, 2003 4:10 am    Post subject: Perform a TRIM in an entire XML tree Reply with quote

Acolyte

Joined: 26 Jun 2001
Posts: 69
Location: Paris - France

Hi all,

I would liketo perform a TRIM on each tag value and each attribute in an XML tree.
For Example, the following XML message :
<MESSAGE>
<FIELD1 ATT1=" AA" ATT2="123 ">
<F1>SMITH </F1>
<F2>GEORGE </F2>
</FIELD1>
</MESSAGE>

Should be translated to :
<MESSAGE>
<FIELD1 ATT1="AA" ATT2="123">
<F1>SMITH</F1>
<F2>GEORGE</F2>
</FIELD1>
</MESSAGE>

I would like to have a generic process, I can have a lot of different structures.

Anyone have an idea ?

Thanks a lot


Eric
Back to top
View user's profile Send private message Send e-mail
lillo
PostPosted: Wed Jan 22, 2003 6:27 am    Post subject: Reply with quote

Master

Joined: 11 Sep 2001
Posts: 224

Use the following ESQL code:
Code:
SET OutputRoot = InputRoot;
-- Enter SQL below this line.  SQL above this line might be regenerated, causing any modifications to be lost.
DECLARE refRoot REFERENCE TO OutputRoot.XML.*[1];
DECLARE xref REFERENCE TO OutputRoot.XML.*[1];
DECLARE refAttr REFERENCE TO OutputRoot.XML.*[1];
DECLARE done INTEGER;
DECLARE i INTEGER;
SET done=0;

WHILE (LASTMOVE(xref) AND done=0) DO
   -- Trim the element
   SET xref = TRIM(xref);
   -- Trim the attribute
   MOVE refAttr TO xref;
   MOVE refAttr FIRSTCHILD TYPE 0x03000000;
   WHILE LASTMOVE(refAttr) DO
      SET refAttr = TRIM(refAttr);
      MOVE refAttr NEXTSIBLING REPEAT TYPE;
   END WHILE;

   MOVE xref FIRSTCHILD;
   IF NOT LASTMOVE(xref) THEN
      MOVE xref NEXTSIBLING;
      WHILE ( NOT LASTMOVE(xref) and (done=0)) do
         MOVE xref PARENT;
            If samefield (xref,refRoot) THEN
               SET done = 1;
            end if;
            MOVE xref NEXTSIBLING;
         END WHILE; 
   END IF;
END WHILE;

_________________
Lillo
IBM Certified Specialist - WebSphere MQ
Back to top
View user's profile Send private message
Galichet
PostPosted: Wed Jan 22, 2003 7:05 am    Post subject: Reply with quote

Acolyte

Joined: 26 Jun 2001
Posts: 69
Location: Paris - France

Thanks for your quick response Lillo

I've copied the ESQL in my compute node box but I've a syntax problem :

The Control center is not happy with the 2 following lines :
MOVE refAttr FIRSTCHILD TYPE 0x03000000;
MOVE refAttr NEXTSIBLING REPEAT TYPE;

I've checked the documentation but without finding anything (at least about REPEAT keyword...


Eric
Back to top
View user's profile Send private message Send e-mail
lillo
PostPosted: Wed Jan 22, 2003 7:28 am    Post subject: Reply with quote

Master

Joined: 11 Sep 2001
Posts: 224

The code is for WMQI2.1 CSD2 or above.

Cheers,
_________________
Lillo
IBM Certified Specialist - WebSphere MQ
Back to top
View user's profile Send private message
Galichet
PostPosted: Wed Jan 22, 2003 7:58 am    Post subject: Reply with quote

Acolyte

Joined: 26 Jun 2001
Posts: 69
Location: Paris - France

Ok thank you very much

I'm going to upgrade my wmqi.


Eric
Back to top
View user's profile Send private message Send e-mail
Galichet
PostPosted: Thu Jan 23, 2003 11:58 pm    Post subject: Reply with quote

Acolyte

Joined: 26 Jun 2001
Posts: 69
Location: Paris - France

Hi,

I've successfully tested this in my flow, that's great

But I've seen that if the input XML message contains a header like :
<?xml version="1.0" encoding="UTF-8"?>
The flow doesn't work

I've tried to remove this header just before, but without success ... Is it possible to do it for all input XML message ? (is there is a header, then remove it, if not continue)

Thanks for your help

Eric
Back to top
View user's profile Send private message Send e-mail
lillo
PostPosted: Fri Jan 24, 2003 2:53 am    Post subject: Reply with quote

Master

Joined: 11 Sep 2001
Posts: 224

Replace the first line with this code. I just change *[1] for *[LAST]
Code:

DECLARE refRoot REFERENCE TO OutputRoot.XML.*[LAST];
DECLARE xref REFERENCE TO OutputRoot.XML.*[LAST];
DECLARE refAttr REFERENCE TO OutputRoot.XML.*[LAST];


It won´t remove the XML declaration. But it will work.

Cheers
_________________
Lillo
IBM Certified Specialist - WebSphere MQ
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 » Perform a TRIM in an entire XML tree
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.