Author |
Message
|
bartimaeus |
Posted: Tue Sep 15, 2009 8:38 am Post subject: Mapping Node question |
|
|
Newbie
Joined: 30 Aug 2009 Posts: 5
|
I am just starting out with message broker flows/ maps and have a question which may sound very basic to the experts here. But, please try to respond if possible.
I have an element returned by a service which is to be mapped using a broker's mapping node. The destination is expecting precisely 50 such elements one after the other. That is, if the service returns only 5 elements of that type, I need to map these 5 elements and return 45 "nulls" (ie, <element>null</element>)along with this.
I have applied a for loop over this element returned from the service. So, all the 5 occurrences are getting mapped. However, I am not able to figure out how to map the 45 "nulls" for the absent values. The for structure expects a source path as value and is not allowing something like "50 - msgmap:occurrence($src)".
Please help me with this problem. |
|
Back to top |
|
 |
hopsala |
Posted: Tue Sep 15, 2009 12:50 pm Post subject: |
|
|
 Guardian
Joined: 24 Sep 2004 Posts: 960
|
I'm not sure this can be done using the mapping node. You can always use ESQL or Java Compute - should be pretty straightforward. |
|
Back to top |
|
 |
bartimaeus |
Posted: Tue Sep 15, 2009 10:40 pm Post subject: |
|
|
Newbie
Joined: 30 Aug 2009 Posts: 5
|
Thanks for suggestion! I was aware this. But, I am under the restriction of using the mapping node only. If it is proved that this cannot be done in the mapping node at all, then perhaps we would have a look at the ESQL/ Java options. |
|
Back to top |
|
 |
Luke |
Posted: Wed Sep 16, 2009 12:14 am Post subject: Re: Mapping Node question |
|
|
Centurion
Joined: 10 Nov 2008 Posts: 128 Location: UK
|
I'm afraid I can't add anything to hopsala's suggestions. But, I can't help reading this:
bartimaeus wrote: |
The destination is expecting precisely 50 such elements one after the other. That is, if the service returns only 5 elements of that type, I need to map these 5 elements and return 45 "nulls" (ie, <element>null</element>)along with this.
|
and thinking ... urggghhhhh. Please don't take that personally, I'm sure there are good reasons for doing it, or the decision is out of your hands?
It just seems strange to me to use XML, but then restrict the format of the message to such an extent. Additional processing, longer messages ... etc |
|
Back to top |
|
 |
hopsala |
Posted: Wed Sep 16, 2009 1:49 am Post subject: Re: Mapping Node question |
|
|
 Guardian
Joined: 24 Sep 2004 Posts: 960
|
Luke - this is actually not that uncommon a requirement. Some legacy (and even non-legacy) systems require a fixed message length or a fixed occurence number. I myself had to program such flows a number of times in the past.
Oh, and I don't think bartimaeus is talking about XML.
bartimaeus - You'll have a hard time proving that something is impossible. The only way is to read the literature cover to cover. Note however that if no one here knows how to do it, there's a decent chance that it can't be done.
As for me, when I had to do this I used ESQL or Java. I remember trying to do it in a mapping node with little success, but I admit that I didn't try too hard.
Good luck! |
|
Back to top |
|
 |
Luke |
Posted: Wed Sep 16, 2009 2:05 am Post subject: Re: Mapping Node question |
|
|
Centurion
Joined: 10 Nov 2008 Posts: 128 Location: UK
|
hopsala wrote: |
Oh, and I don't think bartimaeus is talking about XML. |
Ah, OK, if that's the case then please disregard my comments. I've done plenty of transformation to fixed format messages too, usually using the MRM (CWF). I guess I've made an assumption based on the way the question was described ... |
|
Back to top |
|
 |
bartimaeus |
Posted: Wed Sep 16, 2009 3:25 am Post subject: |
|
|
Newbie
Joined: 30 Aug 2009 Posts: 5
|
Thanks for the prompt replies guys!
hopsala nailed it right! The destination is indeed a legacy system which can only process messages having elements with fixed occurrences. And, since the client was insisting on using mapping node, I have created a Java compute node which precedes the mapping node and creates dummy elements for the missing values.
I agree this is a very crude and inefficient approach, but had to go with this to enable the client to start some testing. I will continue to read the "literature cover to cover" and post back if I find some success. |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Sep 16, 2009 5:19 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
You should be able to create a fixed for loop in the mapping node that will run for 1 to 50.
Then you can map the input or a fixed empty value, depending on if the input exists or not. |
|
Back to top |
|
 |
bartimaeus |
Posted: Wed Sep 16, 2009 5:31 am Post subject: |
|
|
Newbie
Joined: 30 Aug 2009 Posts: 5
|
Can you post the syntax for such a loop in the mapping node? I tried adding constant value in the for loop and it was not compiling. |
|
Back to top |
|
 |
|