Design XMLports

Completed

Designing an XMLport is creating the structure of the external file, whether it is an XML document or a text file. This design process primarily involves setting various properties in the XMLport objects, such as XMLport properties and node properties.

An XML document is a well-structured hierarchy of nodes that simultaneously contain the data and describe the nature of the data in the document.

To create an XMLport to import data from an XML document, specify all XML nodes (specify node names) and indicate the type of each, whether it represents an element or an attribute. Map these nodes to corresponding data structures (tables or fields) in the Business Central database or to variables. When an XMLport object is called to handle an incoming XML document, it reads the incoming data stream (for example, a file) and performs the processing and database actions.

To create an XMLport to export data to an XML document, build the node structure of the XML document and map the data.

When an XMLport object is called to export data, it reads the required data from the database or variables, adds the necessary XML nodes to form the XML document, and writes the document to a data stream (such as a file).

For incoming documents of these types, use AL code to perform the necessary database manipulation to achieve the result that you want.

Data model

The data model maps the data between the external document and the tables and fields in the database. The data model consists of nodes that typically represent tables and fields.

Nodes of the Table type specify the tables from which or into which data will be exported or imported, including any necessary relationship between tables. Nodes of the Field type specify which fields from the parent table will be included in the import or export.

When an XMLport is used to export data, each table node in the XMLport is iterated for all records in the underlying table. Sorting order, keys, and table views can be set to achieve specific ordering of exported data or to filter the resulting sets according to predefined criteria.

When an XMLport is used to import data, records that are read from the external stream are inserted into the table that corresponds to the table node in the XMLport.

You can examine the records before inserting them, specify whether records are inserted automatically, and decide whether records already in the database are overwritten or updated when a record with the same primary key is read from the external file. You can also decide to completely skip records from import.

External file

The layout of the external file is defined by setting properties, including setting the XMLport properties and XMLport node properties.

External files that are handled through XMLports can be in XML or plain text format. In both cases, the definition of the nodes in XMLport Designer must match the structure of the external file that is being exported or imported.

When an XMLport is used to export data, the XMLport definition describes how the fields and records will be mapped to the structure of the external file and will result in the external file containing the exact structure as defined in the XMLport. An XMLport cannot export more fields or information than specified in the XMLport definition.

When an XMLport is used to import data, the XMLport definition describes the minimum number of fields, and depending on the format of the XMLport and structure of the file, the external file might contain more fields than defined by the XMLport definition.