|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
IIB9 - Graphical Map Question |
« View previous topic :: View next topic » |
Author |
Message
|
bdaoust |
Posted: Thu Sep 24, 2015 12:26 pm Post subject: IIB9 - Graphical Map Question |
|
|
Centurion
Joined: 23 Sep 2010 Posts: 130
|
I have an XML that has a node with Premium By Age. This contains premiums that change over the course of one's age.
Code: |
<TotalPXByAge>
<Age>18</Age>
<PXAmount>100.00</PXAmount>
<Age>19</Age>
<PXAmount>75.00</PXAmount>
etc all the way up to age 65
</TotalPXByAge> |
I have a requirement to transform this to CSV.
I created an CSV message model with the required fields names
TotalPXAge18
TotalPXAge19
Then in a graphic map, I do a For Each onto each CSV field name and then do an if clause - so if age is 18 then move PXAmount to TotalPXAge18. I do this for all ages, so there are many For Each's.
While this works, it seems very messy to be and a maintenance nightmare. Is there a better way in a graphical map?
I know I can probably do this much cleaner in ESQL (CARDINALITY and a counter), however if there is a better cleaner way in a graphical map, I'd be curious to try something I haven't done before.
Thanks |
|
Back to top |
|
 |
joebuckeye |
Posted: Fri Sep 25, 2015 4:22 am Post subject: Re: IIB9 - Graphical Map Question |
|
|
 Partisan
Joined: 24 Aug 2007 Posts: 365 Location: Columbus, OH
|
bdaoust wrote: |
I know I can probably do this much cleaner in ESQL (CARDINALITY and a counter) |
While I know nothing about the graphical mapper (we gave up on those when moving from v5 to v6) your "cleaner" solution is not good.
Use references (and a FOR loop) in place of arrays. Much better. |
|
Back to top |
|
 |
Vitor |
Posted: Fri Sep 25, 2015 4:47 am Post subject: Re: IIB9 - Graphical Map Question |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
joebuckeye wrote: |
While I know nothing about the graphical mapper (we gave up on those when moving from v5 to v6) |
but I urge you not to give up on the graphical mapper. I know where you're coming from, I felt the pain of the graphical mapper in those early days, but it's spent a lot of time in rehab, it's cleaned up it's act and now has a whole new outlook. Most specifically, the new (post v7) version produces a sleek, efficient compiled object not ESQL so ratty my cat could do better.
(It's worth pointing out my cat writes surprisingly good code, and is tutoring me on Java coding)
Seriously, give the new GDM a spin. I was skeptical but was impressed. Walk the Road To Hursley and see. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
timber |
Posted: Fri Sep 25, 2015 10:01 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Almost certainly possible with a single line of XPath. But the next person to maintain it might not thank you for choosing that route, if they're not an XPath expert.
Similarly, it might be possible using a single ESQL SELECT statement. Same comment about maintenance applies.
Using CARDINALITY and a counter is not the answer. Whenever you need to loop over an array in ESQL, use a FOR loop or (if the FOR is not flexible enough) a REFERENCE.
I would investigate whether it's possible to do the job with a single FOR loop. For each input record, build the output field name dynamically from the input age and use the {} syntax in the SET statement. Or better, use an explicit CREATE statement instead of creating the field implicitly via a SET statement. |
|
Back to top |
|
 |
martinb |
Posted: Mon Sep 28, 2015 3:41 am Post subject: |
|
|
Master
Joined: 09 Nov 2006 Posts: 210 Location: UK
|
Hi,
Rather than having a nested "If" transform inside the nested mapping of each of your "For each" transforms, you could have set the condition the "Filter" property of the "For each". The filter expression is applied to each iteration to control whether the nested mapping is entered or not.
As Timber says, alternatively you could have used "Custom Xpath" transform with an XPath predicate expression to select the required input instance(s).
You could probably even go as far as using a "Custom Java" transform that built the appropriate dynamically named output element.
Each allowing you to trade elegance / compactness against required developer skills... |
|
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
|
|
|
|