XML Provider
The XML Provider lets you import and export data wrapped in XML.
The XML structure is an approximation of the database structure, and is used for both export and import jobs.
The outer <tables> node contains a <config> section with custom field definitions and other settings, followed by your <tables> and their <item>s and <column>s.
If the attribute “isNull” is set to true, the input will be treated as a Null value. Otherwise, an empty node will be treated as an empty string.
Here is an example of the XML structure generated by the XML Provider:
Used as a source
When used as a source provider, the following settings are available for the XML Provider (Figure 2.1).
You must:
- Select a source folder or source file (source folder will be ignored in favor of source file if both are selected). You can choose to automatically delete the source file after it’s been imported. If folder is used one file = 1 table.
- Optionally, select an XSL file which transforms the XML in the input file into the format required by the XML provider
- Select a source decimal separator – choose between comma (,), dot (.), using the system culture (of the IIS), or detect automatically (based on last non-numeric character in numbers)
Used as a destination
When used as a destination provider, the following settings are available for the XML Provider (Figure 3.1).
You can:
- Optionally select an XSL file for transforming the XML format exported from Dynamicweb into another format
- Specify a name for the destination file which will be generated
- Select a destination folder to create the file in
- Optionally select a destination encoding – default is UTF8 – and a number format culture (None = IIS culture, other options are from your Ecommerce languages)
Additionally, you can:
- Check include timestamp in filename to, well, include a timestamp in the filename of generated XML files
- Check Skip troublesome rows to skip rows with characters not allowed in XML (the activity fails if not)
- Check Export Product Field definitions to apply the structural definition of product fields to a node, located at the top of the output XML
Which tables and columns?
When the XML provider is used as a source, the tables/columns depend on the input file that you provide.
When the XML provider is used as a destination, the tables/columns to be generated are defined during mapping.
The config-node
Adding a <config>-node at the top of your XML file lets you do two things:
- Override provider settings at runtime
- Create custom fields (during import)
Overriding provider settings at runtime
Using the <config>-node, you can override the source and destination provider settings at runtime, as in Figure 6.1). The field names must match property names in the providers. This is case sensitive.
Creating custom fields on import
To create custom fields during import, you simply add a custom field section to the <config>-node:
The possible typeIds for product fields and order fields are:
TypeID |
Field type |
1 |
Text (255) |
2 |
Long text |
3 |
Check box |
4 |
Date |
5 |
Date/Time |
6 |
Integer |
7 |
Decimal |
8 |
Link |
9 |
File |
10 |
Text (100) |
11 |
Text (50) |
12 |
Text (20) |
13 |
Text (5) |
14 |
Editor |
15 |
List box |
Custom OrderLine fields and user fields can be created in a similar manner:
The possible typeIds for user fields are:
TypeID |
Field type |
0 |
Text |
1 |
Long text |
2 |
Rich editor |
3 |
Number |
4 |
Date |
5 |
DateTime |
6 |
File |
7 |
PageLink |
8 |
Boolean |
9 |
Dropdown |
10 |
Radio button group |
Appendix A: Using XSL to transform your XML
If you need to import data from an XML file with a schema that does not match the format required by the XML Provider, or if you need the data you export to be formatted in a way consisted with another standard, you will have to create XSL files which transform the XML into the correct form. You can read more about XSL at w3: https://www.w3.org/Style/XSL/
During both source and destination provider setup, you can select an XSL file to transform your input/output XML.
Consider this example product data in a non-Dynamicweb XML format:
The above data – three products, one in two languages – makes it necessary to create four rows for the product table, as each language version is a separate row in Dynamicweb.
In order to achieve this, we loop through the items, and for each item we loop through the translations, adding a row for each one. The XSL needed to achieve this is shown below:
The result of this transformation is: