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 » check for existence of CDATA Field

Post new topic  Reply to topic
 check for existence of CDATA Field « View previous topic :: View next topic » 
Author Message
j1
PostPosted: Thu Dec 06, 2012 2:12 pm    Post subject: check for existence of CDATA Field Reply with quote

Centurion

Joined: 23 Jun 2003
Posts: 139

Hi,

I want ot check for existence of a CDATA field in an incoming message. So far, Ive tried assigning the field at that position to a character variable and checking for it being null but that dosent seem to work. any pointers? The code I have tried so far is :

Code:

SET TEMPCHARVAR = CAST(ASBITSTREAM(InputRoot.XMLNSC.(XMLNSC.CDataField)Some_Field)  AS CHAR CCSID InputRoot.Properties.CodedCharSetId);
      
      IF ((TEMPCHARVAR <> '') AND  (TEMPCHARVAR <> NULL)) THEN  ......


but TEMPCHARVAR dosent seem to get assigned any value even when there is a CDATA tag at that location?
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Dec 06, 2012 3:04 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

You're making this *way* too complicated. I could tell you the answer, but you wouldn't learn much from that. Try it this way:
- create four input XML messages. One with 'Some_Field' tag completely missing. Another with it present but with no content at all. Another with the tag present and containing an empty CDATA section. And one more, this time with a CDATA section that has some text content.
- Insert a Trace node into your flow.
- Put all 4 messages through the flow and compare the results in the trace node output.

When you have done that, the answers should be obvious. If not, then I strongly recommend that you do some reading in the ESQL reference section of the info center. In particular, search for 'path reference'.

Hint: ASBITSTREAM and CAST are not needed. The info center will explain why not.
Back to top
View user's profile Send private message
j1
PostPosted: Fri Dec 07, 2012 2:12 pm    Post subject: Reply with quote

Centurion

Joined: 23 Jun 2003
Posts: 139

setting up the trace node tells me that CDATA is just well...character data and should be directly assignable to a CHAR variable. However, I already tried :

Code:
SET TEMPCHARVAR = InputRoot.XMLNSC.(XMLNSC.CDataField)Some_Field


but for some strange reason nothing seems to get assigned to the char variable and it stays null... just a note here, Some_Field is not my top level element, even though the above sample code snippet makes it seems so.
Back to top
View user's profile Send private message
kimbert
PostPosted: Fri Dec 07, 2012 2:57 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
setting up the trace node tells me that CDATA is just well...character data and should be directly assignable to a CHAR variable.
Good - that's a very significant piece of knowledge. As is the related knowledge that Trace nodes can be very useful.

There is one other debugging technique that you need to be aware of. Without user trace, it is sometimes very hard to understand why a message flow is not working. So your next step should be to take a user trace and carefully read through the output. You will probably find the problem immediately.

I have posted this advice many times, and if you search this forum for 'user trace' you will find the exact command syntax that you need.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Fri Dec 07, 2012 10:57 pm    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

To add to Kimbert's excellent advice

Using both Trace Nodes and UserTrace you have a history so that not only can you see where something is wrong, but often you can look back and see the reason why which could be in a totally different node in the flow.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
j1
PostPosted: Mon Dec 10, 2012 2:54 pm    Post subject: Reply with quote

Centurion

Joined: 23 Jun 2003
Posts: 139

I did do that and looks like its boiling down to XML tree traversing issues :

Quote:

2012-12-10 16:26:45.211968 14 UserTrace BIP2539I: Node 'TEST_FLOW.Compute': Evaluating expression ''XMLNSC.CDataField'' at ('.TEST_FLOW_Compute.CopyEntire
Message', '25.52'). This resolved to ''XMLNSC.CDataField''. The result was ''50331649''.
2012-12-10 16:26:45.211996 14 UserTrace BIP2543I: Node 'TEST_FLOW.Compute': ('.TEST_FLOW_Compute.CopyEntireMessage', '25.22') : Failed to navigate to path
element number '4' because it does not exist.
2012-12-10 16:26:45.212012 14 UserTrace BIP2539I: Node 'Test_FLOW.Compute': Evaluating expression ''XMLNSC.CDataField'' at ('.TEST_FLOW_Compute.CopyEntire
Message', '25.52'). This resolved to ''XMLNSC.CDataField''. The result was ''50331649''.
2012-12-10 16:26:45.212020 14 UserTrace BIP2539I: Node 'TEST_FLOW.Compute': Evaluating expression ''InputRoot.XMLNSC.Envelope.(XMLNSC.CDataField)Some_Field''
at ('.TEST_FLOW_Compute.CopyEntireMessage', '25.22'). This resolved to ''InputRoot.XMLNSC.Envelope.(50331649)Some_Field''. The result was ''NULL''.


This is using the code

Code:

SET TEMPCHARVAR = InputRoot.XMLNSC.Envelope.(XMLNSC.CDataField)Some_Field


What might I be doing wrong?
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Dec 10, 2012 3:26 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

It's hard to say what is wrong - we can only see half of the required information. You have told us what the ESQL looks like, but you have not told us what the message tree looks like. Please post the Trace node output ( it should be in the user trace if you have redirected the Trace nodes to write into user trace ).
Back to top
View user's profile Send private message
j1
PostPosted: Tue Dec 11, 2012 4:14 pm    Post subject: Reply with quote

Centurion

Joined: 23 Jun 2003
Posts: 139

Below is a representative extract from the trace node ouput to file. Could it be that my actual XML CDATA needs to start in the same line after the CDATA tag ...
Quote:

(0x01000000:Folder):XMLNSC = ( ['xmlnsc' : 0x1770ec40]
(0x01000400:NamespaceDecl):XmlDeclaration = (
(0x03000100:Attribute):Version = '1.0' (CHARACTER)
(0x03000100:Attribute):Encoding = 'UTF-8' (CHARACTER)
)
(0x01000000:Folder ):Envelope = (
.
.
.
)
(0x01000000:Folder):Some_Field = (
(0x02000001:CDataValue ):CDATA = '
<XML Data in CDATA>
.
.

The input XML itself is of the format:
Quote:

<Envelope>
...
...
<Some_Field><![CDATA[
xml data here....
]]>
</Some_Field>
</Envelope>
Back to top
View user's profile Send private message
kash3338
PostPosted: Tue Dec 11, 2012 10:49 pm    Post subject: Reply with quote

Shaman

Joined: 08 Feb 2009
Posts: 709
Location: Chennai, India

j1 wrote:
This is using the code

Code:

SET TEMPCHARVAR = InputRoot.XMLNSC.Envelope.(XMLNSC.CDataField)Some_Field


What might I be doing wrong?


Can you try using a FIELDVALUE to get the CHAR data>? Not sure if this is the solution, you can try tough.
Back to top
View user's profile Send private message Send e-mail
kimbert
PostPosted: Wed Dec 12, 2012 2:21 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

I know what is happening - the Trace node output shows it nicely . The CDATA section is not the only text content of the <Some_Field> tag. The text content of <Some_Field> begins and/or ends with some white space. This means that the XMLNSC parser cannot represent <Some_Field> using a single NameValue node in the message tree. It must create a Name node with name 'Some_Field' and then create
- a text node containing the leading white space, with type XMLNSC.PCDataValue
- a text node containing the CData value, with type XMLNSC.CDataValue
- a text node containing the trailing white space, with type XMLNSC.PCDataValue

So your ESQL path reference 'InputRoot.XMLNSC.Envelope.(XMLNSC.CDataField)Some_Field ' does not match any part of the message tree. You need to write one of
a) InputRoot.XMLNSC.Envelope.Some_Field;
b) InputRoot.XMLNSC.Envelope.Some_Field.(XMLNSC.CDataValue);

a) is better, because it will not fail if/when the sending application removes the leading/trailing white space ( causing XMLNSC to create the tree that your current ESQL is expecting ).
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 » check for existence of CDATA Field
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.