Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/mendix/docs into dev…
Browse files Browse the repository at this point in the history
…elopment
  • Loading branch information
katarzyna-koltun-mx committed Feb 1, 2024
2 parents 31ef726 + 203b787 commit 2cd3337
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 45 deletions.
2 changes: 1 addition & 1 deletion content/en/docs/catalog/consume/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ Common tasks for users who want to consume data sources from the Catalog include
* Using the [Integration Pane](/refguide/integration-pane/)
* Understanding how sources are related in the [Landscape](/data-hub/data-hub-landscape/)

For an overview on consuming data sources, see [Consume Registered Assets](/catalog/consume/).
For an overview on consuming data sources, see [Consume Registered Assets](/catalog/consume/consume-registered-assets/).
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,25 @@ tags: ["excel", "excel importer", "marketplace", "sheet"]

## 1 Introduction

Every now and then a client asks you to import some data. It doesn’t look like a lot of effort at first glance, so you add it as a task and plan to pick it up at the end of the day.

Looking at the sheet later, you realize that there are more than hundred columns that need to be imported into the application. This means manual labor, a lot of it. As every column represents an attribute, creating 100+ new attributes in an import entity would take ages if you did it manually.

The trick is to use XML-to-domain mapping.

We will use XML-to-domain mapping to create a new import entity from an Excel sheet quickly in a semi-automated way.
Use XML-to-domain mapping to create a new import entity from an Excel sheet in a quick, semi-automated way.

This how-to teaches you how to do the following:

* Quickly import a large Excel file with a lot of columns
* Import a large Excel file with a lot of columns

## 2 Prerequisites

Before starting this how-to, make sure you have completed the following prerequisite:

* Have an app with the [MxModel Reflection](/appstore/modules/model-reflection/) and [Excel Importer](/appstore/modules/excel-importer/) modules installed and configured from the Mendix Marketplace
* Have an app with the [MxModel Reflection](/appstore/modules/model-reflection/) and [Excel Importer](/appstore/modules/excel-importer/) modules installed and configured from the Mendix Marketplace.

## 3 Modifying Your Excel Sheet

The Excel sheet you receive in this scenario contains almost every country in the world, and for every country, some data is stored. This data has to be imported into your application.
The Excel sheet you receive in this scenario contains almost every country in the world, as well as some supporting data. This data has to be imported into your application.

You can find the Excel sheet here: [Countries](/attachments/howto/integration/importing-excel-documents/import-a-large-excel-file/Countries.xlsx).

You are going to make an XSD schema from the headers in the Excel sheet so that you can import this later into the model.
You are going to make an XSD schema from the headers in the Excel sheet so you can import the data into the model.

To modify your Excel sheet, follow these steps:

Expand All @@ -41,7 +35,7 @@ To modify your Excel sheet, follow these steps:

Your headers should be listed vertically and your sheet should look like this: [Countries Transposed](/attachments/howto/integration/importing-excel-documents/import-a-large-excel-file/CountriesTransposed.xlsx).

We are now ready to add some tags around the column.
You are now ready to add some tags around the column.

3. Add one column to the left.
4. Place the following string in cell **A1**:
Expand All @@ -50,7 +44,7 @@ To modify your Excel sheet, follow these steps:
<xs:element type="xs:string" name="
```
5. Drag it down all the way to the last country.
5. Drag the string all the way down to the last country.
{{< figure src="/attachments/howto/integration/importing-excel-documents/import-a-large-excel-file/19398889.png" >}}
Expand All @@ -64,24 +58,22 @@ To modify your Excel sheet, follow these steps:
{{< figure src="/attachments/howto/integration/importing-excel-documents/import-a-large-excel-file/19398890.png" >}}
Now you have to get the three different columns into one column. This is necessary because later on, you want to copy the whole column into an XSD file.
Now, group the three different columns into one column. This is necessary to copy the whole column into an XSD file.
8. Select cell **D1** and type in the following into the formula box:
8. Select cell **D1** and type in the following into the formula box:
```text {linenos=false}
=(A1&B1&C1)
```
9. Drag the cells down like you’ve done with column **A1** and **C1**. Now your column **D** should have the columns **A**, **B**, and **C** combined into one, and your sheet should look like this: [Countries with Tags and Column D](/attachments/howto/integration/importing-excel-documents/import-a-large-excel-file/CountriesWithTagsAndColumnD.xlsx).
9. Drag the cells down like you’ve done with column **A1** and **C1**. Now, column **D** should have columns **A**, **B**, and **C** combined into one, and your sheet should look like this: [Countries with Tags and Column D](/attachments/howto/integration/importing-excel-documents/import-a-large-excel-file/CountriesWithTagsAndColumnD.xlsx).
## 4 Preparing Your XSD File
We have used some of the basic functionalities of Excel to help us out creating the first part of our XSD structure. For a proper XSD file, we still need to have a header and a footer. This is where your favorite text editor comes in (for example, Brackets).
You have used some of Excel's basic functionalities to create the first part of the XSD structure. For a proper XSD file, it needs a header and a footer. To prepare your XSD file, follow these steps:
To prepare your XSD file, follow these steps:
1. Open a new file and call it *CountriesImport.xsd*.
2. Place this text as the header of your XSD file:
1. Open a new file and name it *CountriesImport.xsd*.
2. Place the following text as the header of your XSD file:
```xsd
<?xml version="1.0"?>
Expand All @@ -92,9 +84,10 @@ To prepare your XSD file, follow these steps:
```
3. Go back to your sheet, copy the content from column **D**, and paste it underneath the header.
{{% alert type="info" %}}Sometimes the content copied from Excel contains extra double quotes. To eliminate these, paste the Excel content into Word, and then copy it from Word and paste it into the XSD file.{{%/alert%}}
4. Now it’s time to place the footer, which will complete the XSD file. Place this text as for footer:
{{% alert type="info" %}} Sometimes the content copied from Excel contains extra double quotes. To eliminate these, paste the Excel content into Word, and then copy it from Word and paste it into the XSD file. {{%/alert%}}
4. Place the following text as the footer:
```xsd
</xs:sequence>
Expand All @@ -105,25 +98,25 @@ To prepare your XSD file, follow these steps:
Your file should look like this: [Country Import](/attachments/howto/integration/importing-excel-documents/import-a-large-excel-file/CountryImport.xsd).
5. Don’t forget to save it!
5. Click **Save**.
## 5 Importing into Your Application Project
The XSD file is ready to be imported into. To import it, follow these steps:
The XSD file is ready to be imported into your app. To import it, follow these steps:
1. Open your app and create a new XSD schema:
{{< figure src="/attachments/howto/integration/importing-excel-documents/import-a-large-excel-file/19398893.png" >}}
{{< figure src="/attachments/howto/integration/importing-excel-documents/import-a-large-excel-file/create.png" >}}
2. With the new XSD schema created, it’s time to create the XML-to-domain mapping that will perform the trick for you and make your life a bit easier.
2. With the new XSD schema, create the XML-to-domain mapping. Do this by right-clicking the module > **Add other** > **Import mapping**.
{{< figure src="/attachments/howto/integration/importing-excel-documents/import-a-large-excel-file/19398895.png" >}}
{{< figure src="/attachments/howto/integration/importing-excel-documents/import-a-large-excel-file/19398896.png" >}}
3. Be sure to check all the attributes! After clicking **OK**, you should see a mapping entity with all your countries.
3. Check all the attributes listed. After clicking **OK**, you see a mapping entity with all your countries.
4. You will now generate a real entity from it that you can use as an import table for your Excel sheet. Click **Map automatically**:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Mapping documents are used to define how Mendix objects can be converted to and

## 2 Import Mappings {#import-mappings}

Import mappings are used to define how incoming XML or JSON is converted into Mendix objects, according to a specific XML schema or JSON structure. This is needed to be able to interpret data received from other systems. In Mendix there are three basic scenarios for creating Mendix objects from XML or JSON:
Import mappings are used to define how incoming XML or JSON is converted into Mendix objects, according to a specific XML schema or JSON structure. This is needed to be able to interpret data received from other systems. In Mendix, there are three basic scenarios for creating Mendix objects from XML or JSON:

* Receiving XML from a web service (defined in an [imported web service](/refguide/consumed-web-service/)) in a [call web service](/refguide/call-web-service-action/) activity.
* Receiving XML or JSON from a call action [call REST service](/refguide/call-rest-action/).
Expand All @@ -26,7 +26,7 @@ For more details, see [Import Mappings](/refguide/import-mappings/).

## 3 Export Mappings

Export mappings are used to define how Mendix objects can be converted to XML according to a specific XML schema. This is needed to be able to send data to other systems in a format the other system can process. In Mendix there are two basic scenarios for converting Mendix objects to XML:
Export mappings are used to define how Mendix objects can be converted to XML according to a specific XML schema. This is needed to be able to send data to other systems in a format the other system can process. In Mendix, there are two basic scenarios for converting Mendix objects to XML:

* Sending XML to a web service (defined in an [imported web service](/refguide/consumed-web-service/)) in a [call web service](/refguide/call-web-service-action/) activity.
* Exporting XML directly in an [export with mapping](/refguide/export-mapping-action/) action.
Expand All @@ -41,14 +41,14 @@ For more details, see [Export Mappings](/refguide/export-mappings/).

## 4 Creating a New Mapping Document

To specify an import or export mapping, the user needs to do a number of things:
To specify an import or export mapping, the user must:

1. Create a new **Import Mapping** or **Export Mapping** document.
2. Click **Select elements...** to select an XML schema, imported web service document, or JSON structure document as the source schema for this mapping. See **Figure 1**.
2. Click **Select elements...** to select an XML schema, imported web service document, or JSON structure document as the source schema for this mapping.

If the schema is large, a subset of elements can be selected so you don't have to map all of them. This is explained in more detail in the [Select Elements](/refguide/select--elements/) section.

3. Click **OK**. A structure is created with placeholders for entities on the left, and the selected XSD elements on the right side.
3. Click **OK**. A structure is created with placeholders for entities on the left, and the selected XSD elements on the right.

It is possible to include a parameter entity in mapping documents. Mapping documents with a parameter entity need to be invoked (in a [call web service](/refguide/call-web-service-action/) or [export with mapping](/refguide/export-mapping-action/) activity) by passing a parameter of the configured type. Mapping documents without a parameter entity can be invoked without passing a parameter. For import mappings, a parameter entity can be included by dragging one onto the placeholder in the created structure using the Connector tool. Export mappings always need to have a parameter entity (the object that is being exported) and the mapped root element is used for this. In both cases, the parameter entity is depicted as a yellow arrow parameter symbol.

Expand All @@ -59,7 +59,7 @@ To specify an import or export mapping, the user needs to do a number of things:
* From a custom microflow
* By entity specializations in the case of choice or inheritance XML elements

5. Finally the user needs to configure how entity attributes should be transformed into the XML or JSON structure.
5. Configure how entity attributes should be transformed into the XML or JSON structure.

## 5 Convenience Functions

Expand All @@ -75,27 +75,27 @@ Mapping documents rely heavily on two windows. If they are not visible in Studio

## 7 User Interactions

* Dragging entities. Drag an entity from the Connector Window and drop it on an entity placeholder (dashed box) to relate it to an XML element.
* Double clicking on a mapping element (on either the entity side or the XML side). Opens a dialog that allows you to specify details for the individual mapping. If the element is not yet related to an entity, a dialog appears that lets you select the entity first.
* Right mouse click, "Select Entity". Change the entity that is coupled to an XML element.
* Right mouse click, "Go to Entity". Open the Domain Model that contains the entity and jumps to the entity.
* Right mouse click, "Collapse All". Hides all the children of the mapping element, so you can keep overview in large mappings.
* Right mouse click, "Expand All". Expands all children of the mapping element; all underlying elements become visible.
* Left mouse click "-" icon (below mapping element). Makes underlying elements invisible.
* Left mouse, click "+" icon (below mapping element). Makes underlying elements visible again.
* Dragging entities. Drag an entity from the Connector window and drop it on an entity placeholder (dashed box) to relate it to an XML element.
* Double-clicking on a mapping element (on either the entity side or the XML side). Opens a dialog that allows you to specify details for the individual mapping. If the element is not yet related to an entity, a dialog appears that lets you select the entity first.
* Right-click > **Select entity**. Change the entity that is coupled to an XML element.
* Right-click > **Go to entity**. Open the domain model that contains the entity and jumps to the entity.
* Right-click > **Collapse All**. Hides all the children of the mapping element so you can keep overview in large mappings.
* Right-click > **Expand All**. Expands all children of the mapping element; all underlying elements become visible.
* Left-click > "-" icon (below mapping element). Makes underlying elements invisible.
* Left-click > "+" icon (below mapping element). Makes underlying elements visible.

## 8 Properties

| Property | Description |
| --- | --- |
| Name | The name of the mapping. |
| Documentation | Here you can specify extra information to explain what this mapping does. |
| Documentation | You can add information to explain what the mapping does here. |
| Web Service Operation Properties | This category is only filled in if the mapping is for a web service call and not for an XML Schema. |
| Web Service | The name of the imported web service that this mapping is for. |
| Service name | The actual name of the service, as it is defined in the WSDL of the imported service. |
| Operation name | The name of the specific operation in the service that this mapping is meant for. |
| Request part | Only applicable for Export Mappings. The name of the header or body parameter that this mapping is for. If the mapping is for all body parameters, the value is "Body". |
| Request part | Only applicable for Export Mappings. The name of the header or body parameter that this mapping is for. If the mapping is for all body parameters, the value is **Body**. |
| XML Schema Properties | This category is only filled in if the mapping is for an XML schema and not for a web service call. |
| XML Schema | The name of the XML Schema that this mapping is for. |
| Start at | Determines which part of the XML structure this mapping defines. |
| Send empty values | Only applicable for export mappings. If a mapping element is optional and nillable, you need to select whether or not to send the empty values. The default is do not send the empty values. |
| Send empty values | Only applicable for export mappings. If a mapping element is optional and nillable, you need to select whether or not to send the empty values. The default is **Do not send the empty values**. |

0 comments on commit 2cd3337

Please sign in to comment.