0

Please help in solving this map. Here I have XML with HDR, DTL, FTR; The DTL have ITEM-BANK, ITEM-BANK, ITEM-BANK detail in pair together. I need to flatten this to output in one record.

BUSINESS RULE: 1) If ID element is empty it is then COMMENT and will be aggregated "Address of Party + Zipcode of Party + Postbus of Party" in COMMENT output XML. 2) If ID is BANK then it has bank details, and TAG element ID has ID value refer to above ITEM.

XSD POCProducts : http://pastebin.com/XNaq40vZ

POC MAP :

enter image description here

EXPECTED/WANTED OUTOUT:

<ns0:PRODUCTS xmlns:ns0="http://TEST.Schema.FlatFile.POCProducts">
  <PRODUCT ProdName="Wonder Power" ProdDesc="Wonder power  DESC">
    <ITEMS>
      <ITEMS>
        <ID>1010</ID>
        <CODE>KG</CODE>
        <UNIT>C0001</UNIT>
        <DESC>Wonder Power 10*10ml</DESC>
        <BankCode>A1</BankCode>
        <BankDesc>Bank XXXX Code</BankDesc>
      </ITEMS>
      <ITEMS>
        <ID>2020</ID>
        <CODE>KG</CODE>
        <UNIT>C0001</UNIT>
        <DESC>Wonder Supper 50*50ml</DESC>
        <BankCode>A2</BankCode>
        <BankDesc>Bank yyyyy Code</BankDesc>
      </ITEMS>
    </ITEMS>
    <VAT>5390</VAT>
    <AMT>880099</AMT>
    <Comment>Address of Party + Zipcode of Party + Postbus of Party</Comment>
  </PRODUCT>
</ns0:PRODUCTS>

CURRENT OUTPUT XML:

<ns0:PRODUCTS xmlns:ns0="http://TEST.FlatFile.POCProducts">
  <PRODUCT ProdName="Wonder Power" ProdDesc="Wonder power  DESC">
    <ITEMS>
      <ITEMS>
        <ID>1010</ID>
        <CODE>KG</CODE>
        <UNIT>C0001</UNIT>
        <DESC>Wonder Power 10*10ml</DESC>
      </ITEMS>
      <ITEMS>
        <ID>2020</ID>
        <CODE>KG</CODE>
        <UNIT>C0001</UNIT>
        <DESC>Wonder Supper 50*50ml</DESC>
      </ITEMS>
    </ITEMS>
    <VAT>5390</VAT>
    <AMT>880099</AMT>
    <Comments>Address of Party</Comments>
    <Comments>Zipcode of Party</Comments>
    <Comments>Postbus of Party</Comments>
  </PRODUCT>
</ns0:PRODUCTS>

INPUT XML:

<POC xmlns="http://TEST.Schema.FlatFile.POC">
  <HDR xmlns="">
    <ProdName>Wonder Power</ProdName>
    <ProdDesc>Wonder power DESC</ProdDesc>
    <Filler></Filler>
  </HDR>
  <DTL xmlns="">
    <ID>1010</ID>
    <CODE>KG</CODE>
    <TAG>C0001</TAG>
    <DESC>Wonder Power 10*10ml</DESC>
    <FILLER></FILLER>
  </DTL>
  <DTL xmlns="">
    <ID>BANK</ID>
    <CODE>A1</CODE>
    <TAG>1010</TAG>
    <DESC>Bank XXXX Code</DESC>
    <FILLER></FILLER>
  </DTL>
  <DTL xmlns="">
    <ID>2020</ID>
    <CODE>KG</CODE>
    <TAG>C0001</TAG>
    <DESC>Wonder Supper 50*50ml</DESC>
    <FILLER></FILLER>
  </DTL>
  <DTL xmlns="">
    <ID>BANK</ID>
    <CODE>A2</CODE>
    <TAG>2020</TAG>
    <DESC>Bank yyyyy Code</DESC>
    <FILLER></FILLER>
  </DTL>
  <DTL xmlns="">
    <ID></ID>
    <CODE></CODE>
    <TAG>Address of Party</TAG>
    <DESC></DESC>
    <FILLER></FILLER>
  </DTL>
  <DTL xmlns="">
    <ID></ID>
    <CODE></CODE>
    <TAG></TAG>
    <DESC>Zipcode of Party</DESC>
    <FILLER></FILLER>
  </DTL>
  <DTL xmlns="">
    <ID></ID>
    <CODE></CODE>
    <TAG></TAG>
    <DESC>Postbus of Party</DESC>
    <FILLER></FILLER>
  </DTL>
  <FTR xmlns="">
    <VAT>5390</VAT>
    <TOTAL>880099</TOTAL>
    <FILLER></FILLER>
  </FTR>
</POC>
SAM
  • 179
  • 1
  • 3
  • 14

1 Answers1

0

The Comment node output is not so hard:

You can simply link the ID to a Logic Equal to test if it is empty, then connect the result to a value mapping, Depend on where these comments comes from your Src, TAG or DESC or both, link that node to value mapping too. connect the value mapping output to a string concat func shall be enough.

enter image description here

Zee
  • 830
  • 1
  • 9
  • 22
  • Hi Zee, It doesn't work as it give below output "Address of Party Zipcode of Party Postbus of Party" I need one comment element with all data concatenated as given above.. – SAM Feb 12 '15 at 13:44
  • SAM: I added a screenshot. Is your mapping looks like that? – Zee Feb 13 '15 at 16:41