|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Functionality of Mapping Node in WBIMB |
« View previous topic :: View next topic » |
Author |
Message
|
javaforvivek |
Posted: Tue Aug 03, 2004 8:28 am Post subject: Functionality of Mapping Node in WBIMB |
|
|
 Master
Joined: 14 Jun 2002 Posts: 282 Location: Pune,India
|
Hi, I have a following message definitions:
Input Message:
<File> -> Root Element
<Entry > -> Multiple Occurrences
<Tag1> ->Single occurrence
<Tag2> -> Multiple occurrences
</Entry>
</File>
Output Message:
<Documents>
<Document> -> Multiple occurrences
<Header> -> Single occurrence (Contains value of corresponding Tag1 from Input Message || 'some Text')
<Detail> -> Multiple occurrences (Contains value of corresponding Tag2 from Input Message || 'TH')
<Document>
Now when I use mapping node to map values from input message tags to respective output message tags,
I get like this:
In source, I select input message definition
Code: |
File(File)
Entry[]
Tag1
Tag2[]
Entry[All]
Tag1
Tag2[]
Tag2[1]
Entry[1]
Tag1
Tag2[]
Tag2[All]
Tag2[1]
In Target I select output message definition
Documents(Documents)
Document[]
Header
Detail[]
Document[All]
Header
Detail[]
Detail[1]
Document[1]
Header
Detail[]
Detail[All]
Detail[1] |
I refered to the documentation, but it's all confusing..
Can anybody tell me exactly which Input Element to map with Output Element?
For e.g.,
Input Source: Output Target:
<File> <Documents>
<Entry> <Document>
<Tag1> A </Tag1> <Header>A some text</Header>
<Tag2>AAA</Tag2> <Detail>AAATH</Detail>
<Tag2>BBB</Tag2> <Detail>BBBTH</Detail>
</Entry> </Document>
<Entry> <Document>
<Tag1>X</Tag1> <Header>X some Text</Header>
<Tag2>XXX</Tag2> <Detail>XXXTH</Detail>
<Tag2>YYY</Tag2> <Detail>YYYTH</Detail>
</Entry> <Document>
</File> </Documents>
I hope this is not impossible in WBIMB Mapping node,
and I know that I can do it using Compute Node... _________________ Vivek
------------------------------------------------------
...when you have eliminated the impossible, whatever remains, however improbable, must be the truth. |
|
Back to top |
|
 |
javaforvivek |
Posted: Tue Aug 03, 2004 8:33 am Post subject: |
|
|
 Master
Joined: 14 Jun 2002 Posts: 282 Location: Pune,India
|
Sorry, the expected Input and Output are not printed correctly.. so here is the correction:
Input Source:
<File>
<Entry>
<Tag1> A </Tag1>
<Tag2>AAA</Tag2>
<Tag2>BBB</Tag2>
</Entry>
<Entry>
<Tag1>X</Tag1>
<Tag2>XXX</Tag2>
<Tag2>YYY</Tag2>
</Entry>
</File>
Output Target:
<Documents>
<Document>
<Header>A some text</Header>
<Detail>AAATH</Detail>
<Detail>BBBTH</Detail>
</Document>
<Document>
<Header>X some Text</Header>
<Detail>XXXTH</Detail>
<Detail>YYYTH</Detail>
<Document>
</Documents> _________________ Vivek
------------------------------------------------------
...when you have eliminated the impossible, whatever remains, however improbable, must be the truth. |
|
Back to top |
|
 |
wooda |
Posted: Wed Aug 04, 2004 1:57 am Post subject: |
|
|
 Master
Joined: 21 Nov 2003 Posts: 265 Location: UK
|
Hi,
When you have repeating fields the mapping node presents you with options.
Code: |
Entry[]
Tag1
Tag2[]
Entry[All]
Tag1
Tag2[]
Tag2[1]
Entry[1]
Tag1
Tag2[]
Tag2[All]
Tag2[1] |
So selecting :
Entry[]->Tag1 is like writing InputRoot.MRM.Entry.Tag1 in ESQL.
Entry[All]->Tag1 is like writing InputRoot.MRM.Entry[*].Tag1 in ESQL.
Entry[1]->Tag2[1] is like writing InputRoot.MRM.Entry[1].Tag2[1] in ESQL.
etc. etc.
So in your case if the were a fixed number of fields you could start by selecting
Entry[1]->Tag1 and map to Document[1]->Header
Then
Entry[1]->Tag2[1] and map to Document[1]->Detail[1]
And
Entry[1]->Tag2[2] and map to Document[1]->Detail[2]
Then
Entry[2]->Tag1 and map to Document[2]->Header
etc. etc.
However if you had an unknown number of Entry/Document repeats this would be no good. So the following would be needed.
Entry[All]->Tag1 and map to Document[All]->Header
Then
Entry[All]->Tag2[1] and map to Document[All]->Detail[1]
etc. etc.
However if you also has an unknown number of repeats of the Tag2/Detail elements, then I don't know what you would do in mapping since I don't think you can have Entry[All]->Tag2[All]
Q. In your model can Entry/Document repeat an unknown number of times?
Q. Also in your model can Tag2/Detailrepeat an unknwon number of times within a single Entry/Document?
Of course you could do it in ESQL easily. By iterating through each repeat. |
|
Back to top |
|
 |
javaforvivek |
Posted: Wed Aug 04, 2004 5:35 am Post subject: |
|
|
 Master
Joined: 14 Jun 2002 Posts: 282 Location: Pune,India
|
Hi,
I guess you are write..
Answer is 'Yes' to both of your questions, and so I think I can't use
mapping Node.
Quote: |
I hope this is not impossible in WBIMB Mapping node,
and I know that I can do it using Compute Node (s)...
|
My hopes are in vain, and I have to use Compute Nodes...!!!!!
Can any other nodes be used in this case?[/code] _________________ Vivek
------------------------------------------------------
...when you have eliminated the impossible, whatever remains, however improbable, must be the truth. |
|
Back to top |
|
 |
wooda |
Posted: Wed Aug 04, 2004 8:58 am Post subject: |
|
|
 Master
Joined: 21 Nov 2003 Posts: 265 Location: UK
|
Hi,
It seems you can do it with a mapping node. Hurrah.
Map Entry[All] to Document[All]
This will give you a dialog which asks if you want to re-use a mapping or create a new one.
Create a new one by entering a name in the dialog.
This will create a new mapping between an Entry and a Document.
Here you can map the individual elements from one to another.
So map
Tag1 to Header
and
Tag2[All] to Detail[All]
And this works.
I tried it on fixpack 3.
Regards,
-Alex |
|
Back to top |
|
 |
javaforvivek |
Posted: Thu Aug 05, 2004 1:45 am Post subject: |
|
|
 Master
Joined: 14 Jun 2002 Posts: 282 Location: Pune,India
|
Hi Alex,
It really worked for me.. thanks for the help. In fact my real-time message is very big and more complex than the example given. But this is a good starting point to kick off some R&D in my project.
So that we can save lots of looping using counter and cardinality conditions.
Just one more question.. Can we also use Input Message -> Database -> Output Message Mapping.
For e.g., I have a Message like this:
<File>
<Entry> -- Can occur 1 or more times
<Tag1>IND</Tag1> --Can occur one time
---lots of other tags---
</Tag1>
<Tag2> --Can occur one or more times
-------------lots of ther tags-----------
</Tag2>
</Entry>
</File>
The country codes are mapped to Company codes in SQLServer Database table like this:
Table CompanyMap
CountryCode ----- CompanyCode
IND ----- 5000
UK ----- 5010
USA ----- 5020
RUS ----- 5030
AUS ----- 5040
Now I want to get an output message as:
<Documents>
<Document> -- Can occur 1 or more times
<Header>5000</Header> --Can occur one time
---lots of other tags---
</Header>
<Detail> --Can occur one or more times
-------------lots of ther tags-----------
</Detail>
</Document>
</Documents>
How to do this using mapping node.
I tried this by the way you have suggested, but it didn't worked.
I set DataSource property for My Mapping Node.
Then as you said:
Quote: |
So map
Tag1 to Header
|
In addition to this, I wrote some ESQL code in my mapping dialog as follows:
Code: |
THE (select ITEM d.Company_Code from Database.CompanyCodeLookup AS d, s_Entry where d.Country_Code = s_Entry.Tag1)
|
So my Compose Mapping dialog shows something like this:
Mapping Tag1 --> Header
Value of Target Field t_Document.Header
and then my code in the textbox.
What's wrong with this? _________________ Vivek
------------------------------------------------------
...when you have eliminated the impossible, whatever remains, however improbable, must be the truth. |
|
Back to top |
|
 |
wooda |
Posted: Thu Aug 05, 2004 2:14 am Post subject: |
|
|
 Master
Joined: 21 Nov 2003 Posts: 265 Location: UK
|
Hi Vivek,
Should be possible.
Check you have defined you data source in the mapping node properties.
Check you have added the database table to the source side of the mapping file where this mapping is taking place.
You were using the following select:
Code: |
THE (select ITEM d.Company_Code from Database.CompanyCodeLookup AS d, s_Entry where d.Country_Code = s_Entry.Tag1) |
I would try this instead:
Code: |
THE (select ITEM d.Company_Code from Database.CompanyCodeLookup AS d where d.Country_Code = s_Entry.Tag1) |
Cheers,
- Alex |
|
Back to top |
|
 |
javaforvivek |
Posted: Thu Aug 05, 2004 2:53 am Post subject: |
|
|
 Master
Joined: 14 Jun 2002 Posts: 282 Location: Pune,India
|
Alex,
Thanks once again for the guidence. I wonder, if we can go on repeating these mappings till n'th leve (as I mentioned earlier, my <Tag1> contains lots of other elements inside it).
Thanks very much. This Q&A thread here is very very useful for me..!!
Thanks to everybody.. _________________ Vivek
------------------------------------------------------
...when you have eliminated the impossible, whatever remains, however improbable, must be the truth. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|