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 » Dynamic parsing question

Post new topic  Reply to topic Goto page Previous  1, 2, 3  Next
 Dynamic parsing question « View previous topic :: View next topic » 
Author Message
mqjeff
PostPosted: Tue Jun 11, 2013 5:59 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

schroederms wrote:
I appreciate everyone's help, I've got it doing what I need to have it do. Completely namespace independent (multiple namespace possible from a third party company), which I then loop through whatever the tag names are under REQUEST.APP, removing the name space, and building a message to feed into SAP.

Thanks Again!

Set Environment.MyloopStart = Cardinality(InputRoot.XMLNSC.(XMLNSC.Element)*:*.*:REQUEST.*:APP.*:*[]);
--Pull all data under REQUEST.APP and prepare for SAP feed.
While i <= Environment.MyloopStart Do
Set Environment.APP.[i] NAME = Fieldname(InputRoot.XMLNSC.(XMLNSC.Element)*:*.*:REQUEST.*:APP.*:*[i]);
Set Environment.APP.[i] = InputRoot.XMLNSC.(XMLNSC.Element)*:*.*:REQUEST.*:APP.*:*[i];
set i = i +1;
End While;

Set OutputRoot.XMLNSC.(XMLNSC.XmlDeclaration)*.(XMLNSC.Attribute)Version=InputRoot.XMLNSC.(XMLNSC.XmlDeclaration)*.(XMLNSC.Attribute)Version;
Set OutputRoot.XMLNSC.(XMLNSC.XmlDeclaration)*.(XMLNSC.Attribute)Encoding=InputRoot.XMLNSC.(XMLNSC.XmlDeclaration)*.(XMLNSC.Attribute)Encoding;
--
--
Set OutputRoot.XMLNSC.REQUEST.APP = Environment.APP;


That's great except it's entirely and absolutely the wrong way to write a Loop over message trees in ESQL.

NEVER USE CARDINALITY. NEVER USE [<value>] for an incrementing value.

NEVER.

ALWAYS use Reference variables. Particularly in v8, the FOR loop is awesome.

Using [<value>] means you have to start at [1] each time, and count up to <value>, and then when you get to <value+1> you have to start at 1 and count up to <value+1>.

DO NOT USE THIS CONSTRUCT IN LOOPS. EVER.
Back to top
View user's profile Send private message
schroederms
PostPosted: Tue Jun 11, 2013 6:21 am    Post subject: Reply with quote

Disciple

Joined: 21 Jul 2003
Posts: 169
Location: IA

So were are never to use Cardinality to determine a size? I understand the expense at running it over and over again, but that is why I ran it once and stored off the value. We've been doing that, and taught that way since version 2.

I'm willing to learn, do you have an example that covers the proper way of doing this then using the methods you spoke of?

They (IBM) still uses Cardinality in CopyMessageHeaders.

thanks.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Jun 11, 2013 6:29 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

schroederms wrote:
So were are never to use Cardinality to determine a size? I understand the expense at running it over and over again, but that is why I ran it once and stored off the value. We've been doing that, and taught that way since version 2.

I'm willing to learn, do you have an example that covers the proper way of doing this then using the methods you spoke of?

They (IBM) still uses Cardinality in CopyMessageHeaders.

thanks.


It's fine to use cardinality to determine a size. It's terrible to then use that as a limit for a loop counter.

CopyMessageHeaders is written with the knowledge that there will only ever be a comparatively small number of children. And is also included as a shortcut, not as an example of best practice.

Code:

create lastchild of Environment DOMAIN('XMLNSC') Name 'APP';
FOR myRef AS InputRoot.XMLNSC.(XMLNSC.Element)*:*.*:REQUEST.*:APP.*:*[] DO
     CREATE Lastchild of Environment.APP from myRef;
END FOR;

Set OutputRoot.XMLNSC.REQUEST.APP = Environment.APP;
Back to top
View user's profile Send private message
schroederms
PostPosted: Tue Jun 11, 2013 6:30 am    Post subject: Reply with quote

Disciple

Joined: 21 Jul 2003
Posts: 169
Location: IA

thank you.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Jun 11, 2013 6:34 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

schroederms wrote:
thank you.

that's off-the-cuff, might not be 100% correct in function. But should pass syntax validation...
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue Jun 11, 2013 7:10 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

You don't need to build up the output message in the Environment tree - you can create it directly under OutputRoot.XMLNSC.
Code:
FOR inputRef AS InputRoot.XMLNSC.(XMLNSC.Element)*:*.*:REQUEST.*:APP.*:*[] DO
     CREATE lastchild of OutputRoot.XMLNSC.REQUEST.APP from inputRef;
END FOR;

You may need one extra line to set the namespace to the empty string.

For bonus points, you can make the copying of the XML declaration a lot simpler too:
Code:
CREATE lastchild of OutputRoot.XMLNSC from InputRoot.XMLNSC.(XMLNSC.XmlDeclaration)*;


Same comment as mqjeff - this is untested code, so don't expect it to work
Back to top
View user's profile Send private message
schroederms
PostPosted: Tue Jun 11, 2013 7:49 am    Post subject: Reply with quote

Disciple

Joined: 21 Jul 2003
Posts: 169
Location: IA

Kimbert, yours does not bring the tags under APP across, mqJeff's does. mqJeffs does also bring the names space across though as well.
Back to top
View user's profile Send private message
schroederms
PostPosted: Tue Jun 11, 2013 8:00 am    Post subject: Reply with quote

Disciple

Joined: 21 Jul 2003
Posts: 169
Location: IA

Correction..... Both work, bringing name space across.
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue Jun 11, 2013 8:01 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Phew - I was starting to think that I was going mad for a moment.
Back to top
View user's profile Send private message
schroederms
PostPosted: Tue Jun 11, 2013 8:06 am    Post subject: Reply with quote

Disciple

Joined: 21 Jul 2003
Posts: 169
Location: IA

what is the most efficient way of nulling out NS then?
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Jun 11, 2013 8:14 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

kimbert wrote:
Phew - I was starting to think that I was going mad for a moment.

I'm not sure this counts as sufficient proof either way.
Back to top
View user's profile Send private message
McueMart
PostPosted: Tue Jun 11, 2013 8:17 am    Post subject: Reply with quote

Chevalier

Joined: 29 Nov 2011
Posts: 490
Location: UK...somewhere

IBM provides a sample which does namespace modification and includes what you need:

http://publib.boulder.ibm.com/infocenter/wmbhelp/v8r0m0/index.jsp?topic=%2Fcom.ibm.etools.mft.samples.XMLNSCnamespace.doc%2Fdoc%2Foverview.htm
Back to top
View user's profile Send private message
goffinf
PostPosted: Tue Jun 11, 2013 8:18 am    Post subject: Reply with quote

Chevalier

Joined: 05 Nov 2005
Posts: 401

schroederms wrote:
I appreciate everyone's help, I've got it doing what I need to have it do. Completely namespace independent (multiple namespace possible from a third party company) ....


What's the point of having a message exchange specification that requires namespace association (presumably to help ensure the correct data domain semantics) if, on receipt you are processing all messages as namespace agnostic. Whilst I recognise the issues in processing messages from more than one namespace (and those which use multiple namespace within each message), it is hardly an unusual problem (think versioning). it seems an odd design choice to solve it by assuming all information items with the same name are semantically equivalent. If you cam be certain that is always the case, why design the messages with namespace associations in the first place ?

Fraser.
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue Jun 11, 2013 8:35 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

I was assuming that you only wanted the namespace removed from the top-level tag.

If you are removing the namespaces everywhere then I agree with goffinf - you should be asking questions about where this requirement is coming from.
Back to top
View user's profile Send private message
schroederms
PostPosted: Tue Jun 11, 2013 9:58 am    Post subject: Reply with quote

Disciple

Joined: 21 Jul 2003
Posts: 169
Location: IA

The namespace is coming from a third party, the SAP interface (once here) cannot except them, it is not a SAP webs service, this is whey they need to be removed.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page Previous  1, 2, 3  Next Page 2 of 3

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Dynamic parsing question
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.