You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: en/docs/integration-guides/usecases/datamapper/read-csv-file-and-transform-to-xml-file.md
+22-19Lines changed: 22 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# Read a CSV File and Transform It to an XML File
1
+
# Read a CSV File and Transform It to XML File
2
2
3
3
## Overview
4
4
This is a low-code walkthrough that uses the Ballerina Integrator Data Mapper and file APIs to build an end-to-end pipeline — without writing code by hand. You will:
@@ -8,6 +8,13 @@ This is a low-code walkthrough that uses the Ballerina Integrator Data Mapper an
8
8
3. Add a row number as a child `<index>` element. Use the mapper’s row position function and set it to 0-based.
9
9
4. Write the result to a new XML file in an `output/` folder.
10
10
11
+
### Why this use case
12
+
13
+
- Converts flat CSV order data into XML that downstream, XML-centric systems can validate and consume.
14
+
- Demonstrates record indexing as an element (`<index>`) for traceability back to the original row.
15
+
- Scales easily from a single file to batch folders or listener-based near-real-time ingestion.
16
+
17
+
11
18
### Input CSV Example
12
19
13
20
```csv
@@ -45,12 +52,6 @@ S003,P-2003,1,89.50
45
52
</Orders>
46
53
```
47
54
48
-
### Why this use case
49
-
50
-
- Converts flat CSV order data into XML that downstream, XML-centric systems can validate and consume.
51
-
- Demonstrates record indexing as an element (`<index>`) for traceability back to the original row.
52
-
- Scales easily from a single file to batch folders or listener-based near-real-time ingestion.
53
-
54
55
## Prerequisites
55
56
56
57
Before you begin, make sure you have the following:
@@ -65,16 +66,18 @@ WSO2 Integrator: BI extension provides a low-code graphical environment to visua
65
66
1. Launch VS Code and click the WSO2 Integrator: BI icon on the left sidebar.
66
67
You’ll be taken to the welcome page that introduces the integration workspace.
67
68
68
-
2. Under the **Get Started Quickly** section, you’ll see three main options:
69
-
- Create New Integration – start a new integration project from scratch using the graphical designer.
70
-
- Import External Integration – bring in existing integrations from other platforms (e.g., MuleSoft, TIBCO).
71
-
- Explore Pre-Built Samples – open existing templates or tutorials.
69
+
2. Under the **Get Started Quickly** section, you’ll see three main options:
70
+
71
+
- Create New Integration – start a new integration project from scratch using the graphical designer.
72
+
- Import External Integration – bring in existing integrations from other platforms (e.g., MuleSoft, TIBCO).
73
+
- Explore Pre-Built Samples – open existing templates or tutorials.
72
74
73
-
3. Click **Create New Integration**.
75
+
3. Click **Create New Integration**.
74
76
This opens the integration creation wizard, where you can:
75
-
- Define the integration name and location.
76
-
- Choose to start with a blank project or from a sample template.
77
-
- Initialize the workspace structure with folders for input/output mappings, resources, and configuration.
77
+
78
+
- Define the integration name and location.
79
+
- Choose to start with a blank project or from a sample template.
80
+
- Initialize the workspace structure with folders for input/output mappings, resources, and configuration.
78
81
79
82
4. Once the project is created, you’ll enter the graphical integration designer view.
80
83
From here, you can start adding connectors, data mappings, and logic components to build your flow visually.
@@ -118,7 +121,7 @@ These parameters make your integration portable and environment-agnostic — you
## Step 3: Create a structure to represent each CSV row
124
+
## Step 3: Create a structure to represent each csv row
122
125
123
126
In this step, you’ll define a structure (called a *Type* in Ballerina) that describes what one row in your CSV file looks like.
124
127
Think of it as creating a template so the Data Mapper can recognize each column by name and map them correctly to the XML later.
@@ -146,7 +149,7 @@ When the system reads the CSV file, it will treat every line (after the header)
146
149
<ahref="{{base_path}}/assets/usecases/datamapping/csv-to-xml-simple-mapping/img/csv_to_xml3.gif"><imgsrc="{{base_path}}/assets/usecases/datamapping/csv-to-xml-simple-mapping/img/csv_to_xml3.gif"alt="Create a type to represent CSV structure"width="70%"></a>
147
150
148
151
---
149
-
## Step 4: Generate XML types from a sample payload
152
+
## Step 4: Generate xml types from a sample payload
150
153
151
154
In this step, you’ll create the XML output structure automatically by pasting a sample XML.
152
155
The Integrator’s Type Creator reads this example and builds the corresponding type definitions for you.
@@ -197,7 +200,7 @@ The generated structure will appear as:
197
200
└─ price: decimal
198
201
```
199
202
200
-
You now have a record type that defines the exact structure of your output XML file.
203
+
You now have an record type that defines the exact structure of your output xml file.
201
204
This type will act as the target structure in the Data Mapper, allowing each `CSV` record to be mapped directly into a `<Row>` element under `<Orders>`.
202
205
203
206
<ahref="{{base_path}}/assets/usecases/datamapping/csv-to-xml-simple-mapping/img/csv_to_xml4.gif"><imgsrc="{{base_path}}/assets/usecases/datamapping/csv-to-xml-simple-mapping/img/csv_to_xml4.gif"alt="Create a type to represent XML structure"width="70%"></a>
@@ -226,7 +229,7 @@ This automation serves as the starting point of the data-transformation pipeline
226
229
227
230
A page titled **Automation – An automation that can be invoked periodically or manually** appears.
228
231
Click the blue **Create** button to add a new Automation flow.
229
-
You may optionally expand **Advanced Configurations** to adjust scheduling or trigger settings, but for this tutorial, we keep the defaults.
232
+
You may optionally expand *Optional Configurations* to adjust scheduling or trigger settings, but for this tutorial we keep defaults.
230
233
231
234
The tool shows a brief **“Creating…”** indicator, and then a new canvas opens.
0 commit comments