Blog Stats
  • Posts - 15
  • Articles - 0
  • Comments - 2
  • Trackbacks - 6

 

Complex Mapping problem with Loop functoid

Recently I came across an interesting mapping problem; part of my input file looked like this

<Lines>

- <ns2:Line xmlns:ns2="http://GeneralLedger.Schemas.GJFLines_Xml">

  <GLCode>GLCode_0GLCode>
  <ValueDate>ValueDate_0ValueDate>
  <Currency>Currency_0Currency>
  <Amount>Amount_0Amount>
  <Sign>Sign_0Sign>
  <Reference>Reference_0Reference>
  <Description>Description_0Description>
- <ControlInfo>
- <Info>
  <InfoName>ALLOCINVInfoName>
  <InfoValue>ANALYSIS1InfoValue>
  Info>
-  <InfoName>MATTERNOInfoName>
  <InfoValue>ANALYSIS2InfoValue>
  Info>
- <Info>
  <InfoName>PROJECTCODEInfoName>
  <InfoValue>ANALYSIS3InfoValue>
  Info>-
  ControlInfo>
  ns2:Line>
  Lines>
 
This had to be mapped to output file like following
 
<Lines>
- <Line>
  <AccountCode>GLCode_0AccountCode>
  <AnalysisCode1>ANALYSIS1(InfoValue of InfoName ALLOCINV)AnalysisCode1>
  <AnalysisCode2>ANALYSIS2(InfoValue of InfoName MATTERNO)AnalysisCode2>
  <AnalysisCode3>ANALYSIS3(InfoValue of InfoName PROJECTCODE)AnalysisCode3>  
  <CurrencyCode>Currency_0CurrencyCode>
  <DebitCredit>Sign_0DebitCredit>
  <Description>Description_0Description>
  <TransactionAmount>Amount_0TransactionAmount>
  <TransactionDate>ValueDate_0TransactionDate>
  <TransactionReference>Reference_0TransactionReference>
  Line>
  Lines>
 
The problem here source schema has untyped information e.g ALLOCINV...
which should go in which is typed information; apparently we couldn't do this without writing custom code in c# or xslt;
But after toying around with functoids I managed to do that
The map looks like this
 
(Fig showing the map; if you can't see this a better picture in Gallery on my blog)
Points to go:
 
1. I used logical functoid EQUAL with the normal Link  ; both linking to same node in output schema
so what this does is; it checks for required value e.g ALLOCINV ; if it gets match then copies to output node
in this case
 
2. The one more problem in this was; I had a node in source schema which had no match in output schema ;
but I needed to loop ; I used LOOP functoid and mapped its input to output node
so it loops over each “Line” till it finds match as metioned in point 1
 
This approach eliminates requirement of reading the XML file and parsing it manually
I found this a complex problem as there was no ready made solution available for it :)
 
Cheers
 
Vishy
 

Feedback

No comments posted yet.


Post a comment





 

 

 

Copyright © Vishal H