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 » question regarding REFERENCE, FIELDNAME and XML

Post new topic  Reply to topic
 question regarding REFERENCE, FIELDNAME and XML « View previous topic :: View next topic » 
Author Message
ernest-ter.kuile
PostPosted: Tue Oct 15, 2002 6:55 am    Post subject: question regarding REFERENCE, FIELDNAME and XML Reply with quote

Apprentice

Joined: 13 May 2002
Posts: 49
Location: KLM Holland

I have different XML messages that all have a common part that need
to be modified in a compute node.

example :

Code:
<?xml ...>
 <MESSAGE_TYPE_1_>
   <common_part>
      <timestamp>the_time</timestamp>
      <flightnumber carrier="KL">1234</flightnumber>
   </common_part>
   <different_part_1>
     ...
   </different_part_1>
 </MESSAGE_TYPE_1_>


same for MESSAGE_TYPE_2_, _3_, _4_, etc ...

how can I access
InputBody.MESSAGE_TYPE_1_.common_part.timestamp
InputBody.MESSAGE_TYPE_2_.common_part.timestamp
InputBody.MESSAGE_TYPE_3_.common_part.timestamp
InputBody.MESSAGE_TYPE_4_.common_part.timestamp

without needing to know if the message is of type MESSAGE_TYPE_1_, _2_,_ 3_, _4_.

I thought I might use REFERENCE and FIELDNAME to do this.

but if so, how ?

in the documentation, REFERENCE if often used in the context of "dynamic", however, how do I change the reference value without the system telling me that it was already declared ?

and of course, something like :
Code:
DECLARE timestamp REFERENCE TO InputBody.FIELDNAME(InputBody.(XML.Element)[1]);



does not work.


Ernest
Back to top
View user's profile Send private message Visit poster's website
lillo
PostPosted: Tue Oct 15, 2002 8:17 am    Post subject: Reply with quote

Master

Joined: 11 Sep 2001
Posts: 224

Hi,

It is easy. The reference variable should be:
Code:

DECLARE refVariable REFERENCE TO InputRoot.XML.*[LAST].common_part.timestamp;


Cheers,
_________________
Lillo
IBM Certified Specialist - WebSphere MQ
Back to top
View user's profile Send private message
ernest-ter.kuile
PostPosted: Tue Oct 15, 2002 11:32 pm    Post subject: Reply with quote

Apprentice

Joined: 13 May 2002
Posts: 49
Location: KLM Holland

Indeed easy, but not obvious.

thanks.

Ernest.
Back to top
View user's profile Send private message Visit poster's website
ernest-ter.kuile
PostPosted: Thu Oct 17, 2002 7:26 am    Post subject: Reply with quote

Apprentice

Joined: 13 May 2002
Posts: 49
Location: KLM Holland

lillo wrote:
Hi,

It is easy. The reference variable should be:
Code:

DECLARE refVariable REFERENCE TO InputRoot.XML.*[LAST].common_part.timestamp;


Well, after a second look it has a flaw: it doesn't work. At least not always.

The XML parser seems to keep the formating of the XML input interlaced in XML tree, so even though they have no influence on the XML itself, TABs and LFs are visible and can be read back in the tree.

Unfortunalty, the XML I'm sending in has a nice formating applied to it to allow for humans to read it too.

so

Code:
<?xml ...>
<MESSAGE_TYPE_1_>
   <common_part>

     ... snip snip snip ...

</MESSAGE_TYPE_1_>


will in a trace node look like this

Code:
  (0x5000018)XML             = (
    (0x6000011) = '1.0'
    (0x6000012) = 'UTF-8'
  )
  (0x6000002)                = '<cr><lf>'
  (0x1000000)MESSAGE_TYPE_1_ = (
    (0x2000000)                         = '<cr><lf><tab>'
    (0x1000000)common_part           = (
    (0x2000000)                         = '<cr><lf><tab>'

     ... snip snip snip ...
  )
  (0x6000002)                = '<cr><lf>'


note : I added the <cr><lf>, in the log file they are the actual characters.

Guess what you will see when using InputRoot.XML.*[LAST] ?

Right ! it will point to an unamed entry in the XML tree containing the last <cr><lf>

So, what does work is this much longer version

Code:
DECLARE cnt INTEGER;
SET cnt = CARDINALITY(InputRoot.XML.*[]);

WHILE FIELDNAME(InputRoot.XML.*[cnt]) = '' DO
   SET cnt = cnt - 1;
END WHILE;

DECLARE in_Message REFERENCE TO InputRoot.XML.*[cnt];


Looks awfull, doesn't it ? there has to be beter way.

Ernest.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » question regarding REFERENCE, FIELDNAME and XML
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.