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 » Sorted Mapping

Post new topic  Reply to topic
 Sorted Mapping « View previous topic :: View next topic » 
Author Message
sridhsri
PostPosted: Tue Aug 05, 2008 12:01 pm    Post subject: Sorted Mapping Reply with quote

Master

Joined: 19 Jun 2008
Posts: 297

I have incoming data in the following format:

Parent
Child5
Child3
Child1
Child2
Child4

Each elements occurs once. I need to map this to:

ComplexElement
Element1
Element2
Element3
Element4
Element5

Where Child1 maps to Element1 and so on. Since Child5/Element5 occurs first, this becomes the first child of the ComplexElement - which violates the MRM.

1) What is the best way to map this - preferably in a mapping node? {ps: I have already tried a few options but I'm not convinced if what I have is the best approach. I obviously do not want to loop too many times}

2) Shouldn't there be an easier way in Mapping Editor/ESQL to preserve the output order ?
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue Aug 05, 2008 1:24 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

If your output format is CWF, then you can set the compostion of your output message definition to 'UnorderedSet'. If you do that, the MRM parser will re-order the fields for you.
I don't know whether the same trick works for non-tagged TDS.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Aug 05, 2008 2:15 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

The order of the fields in the output tree from the mapping node should be determined by the top-to-bottom order of the map statements... in the same way that they are determined by the top-to-bottom order of SET statements in ESQL...

Unless you tell the Map node to build the map for you, using Map By Name or etc.

So you should be able to tell the map to map Element1 to Child1 and then map Element2 to Child2, and etc. etc. etc.
Back to top
View user's profile Send private message
sridhsri
PostPosted: Wed Aug 06, 2008 5:00 am    Post subject: Reply with quote

Master

Joined: 19 Jun 2008
Posts: 297

Sorry - I made a mistake with my earlier post.

It must be read as Child[1..n] mapped to and Element1, Element2....Elementn.

The order in which Child[n] appears cannot be determined. But the order of Elementn is always the same and must be maintained.

It is my understanding that in un-ordered set, the elements must all appear but in any order. So, I am guessing it wont help here.

I definitely want to avoid looping Child[1..n] more than once. I was thinking of initializing all the target elements with a default value before entering the loop. Then simple 'if' statements in the 'for' loop should do the trick.
Back to top
View user's profile Send private message
sridhsri
PostPosted: Wed Aug 06, 2008 5:19 am    Post subject: Reply with quote

Master

Joined: 19 Jun 2008
Posts: 297

p.s: The mapping is based on the value of Child[n]
Back to top
View user's profile Send private message
elvis_gn
PostPosted: Wed Aug 06, 2008 10:58 am    Post subject: Reply with quote

Padawan

Joined: 08 Oct 2004
Posts: 1905
Location: Dubai

Hi sridhsri,

sridhsri wrote:
I definitely want to avoid looping Child[1..n] more than once. I was thinking of initializing all the target elements with a default value before entering the loop. Then simple 'if' statements in the 'for' loop should do the trick.
That would be too many IFs.

Can you paste a sample of your input please, EXACTLY how it's going to come...your Child'ren are confusing

Regards.
Back to top
View user's profile Send private message Send e-mail
kimbert
PostPosted: Wed Aug 06, 2008 11:02 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Please also post a sample of your required output, and the physical format that you are using ( if not obvious ).
Back to top
View user's profile Send private message
sridhsri
PostPosted: Wed Aug 06, 2008 11:27 am    Post subject: Reply with quote

Master

Joined: 19 Jun 2008
Posts: 297

My incoming data is XML. The outgoing data is TDS (TLOG). The XML Schema contains a wildcard element. This wildcard element comes in as 'n' "CustomData" XML Elements. Each of these elements map to a TLOG element. They are mapped based on the content of the XML element's attribute name. The XML elements can appear in in order. The outgoing TDS complex type has a composition and validation set to Sequnce and Closed. While I can paste a sample of XML, I don't think I can paste the TLOG data.
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed Aug 06, 2008 1:49 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

I may well be able to help, but I still do not understand the requirement. You seem to be saying two things which contradict one another.
Quote:
p.s: The mapping is based on the value of Child[n]
and
Quote:
They are mapped based on the content of the XML element's attribute name

So what is the mapping based on? Please give an example of the input XML, and what the output tree should look like.
Back to top
View user's profile Send private message
sridhsri
PostPosted: Thu Aug 07, 2008 5:03 am    Post subject: Reply with quote

Master

Joined: 19 Jun 2008
Posts: 297

Here is a sample of the incoming XML

<LineItem>
.
.
. <!-- contains other xml tags not required for mapping -->
<CustomerData Name="abc">123</CustomData>
<CustomerData Name="efg">234</CustomData>
<CustomerData Name="qwe">345</CustomData>
<CustomerData Name="asd">456</CustomData>
</LineItem>

The target message is TDS TLOG. In TLOG, the complex type is modeled as
Transaction
Element1 (must map to 345 if Name = qwe)
Element2 (must map to 456 if Name = asd)
Element3 (must map to 234 if Name = efg)
Element1 (must map to 123 if Name = abc)

Transaction has been modeled with Composition and Validation as Sequence and Closed.

In the XSD, LineItem has been modeled such that the last element is a wildcard element. This wildcard element contains "CustomData" tags. The order in which the CustomData tags appear is not predictable. I'd like to map this without having to loop through the incoming XML too many times.
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Aug 07, 2008 6:57 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Good - now I understand. You can use the ESQL SELECT statement, like this:
Code:
SET OutputRoot.MRM.Element1 =
    FIELDVALUE(SELECT CD FROM InputRoot.XMLNSC.LineItem.CustomerData[] AS CD WHERE CD.Name = 'qwe' );


If you want to use the mapping node, you may be able to find a way of calling an ESQL procedure from the map.

Warning : above code is not tested, and probably contains errors.
Back to top
View user's profile Send private message
sridhsri
PostPosted: Thu Aug 07, 2008 7:03 am    Post subject: Reply with quote

Master

Joined: 19 Jun 2008
Posts: 297

Thank you for your help Tim!

I guess using an ESQL Select is faster than looping through the elements.
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Aug 07, 2008 10:30 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

You could do the mapping in a single SELECT statement:
http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/topic/com.ibm.etools.mft.doc/ak05790_.htm
You would need to create a ROW variable containing the mapping from qwe -> Element1 etc, and the WHERE clause would need to contain a nested SELECT. Tricky, but quite elegant.
Back to top
View user's profile Send private message
sridhsri
PostPosted: Thu Aug 07, 2008 12:59 pm    Post subject: Reply with quote

Master

Joined: 19 Jun 2008
Posts: 297

That's great idea! It would work if all my code were in ESQL.

But I think it wont work for me now. I have a mandate to use the mapping node as far as possible. In the mapping editor, when mapping a complex type, I have found that one cannot specify an esql method there. I think ESQL/Java Methods can only be specified for simple elements.
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 » Sorted Mapping
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.