Configuring the mapping
Combining nested loops into a simple loop
Convert an XML structure with nested loops into a flat CSV structure by combining nested loops.
Before you begin
About this task
In this example, the input XML file contains information about a purchase order. Each Address element contains an Items element, which contains at least one Item element. The goal of the transformation is to have a CSV file with a row for each Item. Each row should also contain the relevant shipping information.
<PurchaseOrderShipping PurchaseOrderNumber="99503" OrderDate="2011-03-15T12:10:03+05:30">
                  <ShipDate>2011-04-30T23:50:00+05:30</ShipDate>
                  <Address>
                  <Name>Deandre King</Name>
                  <Street>4894  Winding Way</Street>
                  <City>Southfield</City>
                  <State>MI</State>
                  <Zip>48075</Zip>
                  <Country>USA</Country>
                  <DeliveryNotes>Please leave packages in shed by driveway.</DeliveryNotes>
                  <Items>
                  <Item PartNumber="872-AA">
                  <ProductName>Lawnmower</ProductName>
                  <Quantity>1</Quantity>
                  <USPrice>148.95</USPrice>
                  <Comment>Confirm this is electric</Comment>
                  </Item>
                  <Item PartNumber="926-AA">
                  <ProductName>Baby Monitor</ProductName>
                  <Quantity>2</Quantity>
                  <USPrice>39.98</USPrice>
                  </Item>
                  </Items>
                  </Address>
                  <Address>
                  <Name>Burl Clark</Name>
                  <Street>3807 Pointe Lane</Street>
                  <City>Fort Lauderdale</City>
                  <State>FL</State>
                  <Zip>33308</Zip>
                  <Country>USA</Country>
                  <Items>
                  <Item PartNumber="356-KX">
                  <ProductName>Gas canister</ProductName>
                  <Quantity>1</Quantity>
                  <USPrice>123.02</USPrice>
                  </Item>
                  </Items>
                  </Address>
                  </PurchaseOrderShipping>ItemsShipping
                  item (0:*)
                  PurchaseOrderNumber
                  ShipTo
                  ShipDate
                  PartNumber
                  ProductName
                  Quantity
                  USPriceProcedure
Results
PurchaseOrderNumber,ShipTo,ShipDate,PartNumber,ProductName,Quantity,USPrice
               99503,Deandre King 4894  Winding Way Southfield MI 48075 USA,2011-04-30T23:50:00+05:30,872-AA,Lawnmower,1,148.95
               99503,Deandre King 4894  Winding Way Southfield MI 48075 USA,2011-04-30T23:50:00+05:30,926-AA,Baby Monitor,2,39.98
               99503,Burl Clark 3807 Pointe Lane Fort Lauderdale FL 33308 USA,2011-04-30T23:50:00+05:30,356-KX,Gas canister,1,123.02Aggregating nested loops into a simple loop
Convert an XML structure with nested loops into a flat CSV structure by aggregating nested loops.
Before you begin
About this task
This example uses the same input structure as in Combining nested loops into a simple loop. The goal of the transformation is to have a CSV file with a row for each Address element containing information about the delivery and the products.
AddressesShipping
                  Address (0:*)
                  Name
                  Street
                  City
                  State
                  Zip
                  Country
                  DeliveryNotes
                  PartNumber_1
                  ProductName_1
                  PartNumber_2
                  ProductName_2
                  PartNumber_3
                  ProductName_3Procedure
Results
Name,Street,City,State,Zip,Country,DeliveryNotes,PartNumber_1,ProductName_1,PartNumber_2,ProductName_2,PartNumber_3,ProductName_3
               Deandre King,4894  Winding Way,Southfield,MI,48075,USA,Please leave packages in shed by driveway.,872-AA,Lawnmower,926-AA,Baby Monitor,,
               Burl Clark,3807 Pointe Lane,Fort Lauderdale,FL,33308,USA,,356-KX,Gas canister,,,, 
                   
                   
                   
                  