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_0< FONT>GLCode>
<ValueDate>ValueDate_0< FONT>ValueDate>
<Currency>Currency_0< FONT>Currency>
<Amount>Amount_0< FONT>Amount>
<Reference>Reference_0< FONT>Reference>
<Description>Description_0< FONT>Description>
<InfoName>ALLOCINV< FONT>InfoName>
<InfoValue>ANALYSIS1< FONT>InfoValue>
< FONT>Info>
- <InfoName>MATTERNO< FONT>InfoName>
<InfoValue>ANALYSIS2< FONT>InfoValue>
< FONT>Info>
<InfoName>PROJECTCODE< FONT>InfoName>
<InfoValue>ANALYSIS3< FONT>InfoValue>
< FONT>Info>-
< FONT>ControlInfo>
< FONT>ns2:Line>
< FONT>Lines>
This had to be mapped to output file like following
<Lines>
<AccountCode>GLCode_0< SPAN>AccountCode>
<AnalysisCode1>ANALYSIS1(InfoValue of InfoName ALLOCINV)< SPAN>AnalysisCode1>
<AnalysisCode2>ANALYSIS2(InfoValue of InfoName MATTERNO)< SPAN>AnalysisCode2>
<AnalysisCode3>ANALYSIS3(InfoValue of InfoName PROJECTCODE)< SPAN>AnalysisCode3>
<CurrencyCode>Currency_0< SPAN>CurrencyCode>
<DebitCredit>Sign_0< SPAN>DebitCredit>
<Description>Description_0< SPAN>Description>
<TransactionAmount>Amount_0< SPAN>TransactionAmount>
<TransactionDate>ValueDate_0< SPAN>TransactionDate>
<TransactionReference>Reference_0< SPAN>TransactionReference>
< SPAN>Line>
< SPAN>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
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