Mapping Functions
Overview
This article explains how to implement mapping functions in your XSLT mapping files when running them in Zynk Workflow.
Zynk supports two types of mappings:
-
Global Mappings
- How to: Configure "global" mappings from the "Mappings" button on the main toolbar
- Namespace:
urn:MappingFunctions - Available since: Zynk Workflow 2.1.8
-
Workflow Mappings
- How to: Configure "workflow" mappings from the Properties tab in the workflow editor
- Namespace:
urn:WorkflowMappingFunctions - Available since: Zynk Workflow 2025.4.3
Mappings allow you to convert values between systems—for example, converting the shipping method 'Royal Mail - 1st class' from your e-commerce system to a corresponding additional charge code in Sage 200.
For details on how to create and manage mappings in Zynk, please see here.
Declaration
You can make use of the file functions by including the following declaration in your XSLT document:
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:MappingFunctions="urn:MappingFunctions"
exclude-result-prefixes="MappingFunctions">
<!-- transformation -->
</xsl:stylesheet>
Functions
Below is a list of available functions within the urn:MappingFunctions and urn:WorkflowMappingFunctions namespace:
MapFrom
Maps one value to another using the specified mapping table. It searches the 'To' column of the mapping table, and if a match is found, it returns the corresponding value in the 'From' column. If no match is found, the value that was provided as input will be returned. By default, it will look for an exact match, but if you set the exactMatch parameter to false, it will look for a mapping entry that contains the value specified. However, if mappingContainsValue is also set to false, it will look for a mapping entry where the value specified is contained in the mapping.
Overloads
MapFrom(string mappingName, string to)MapFrom(string mappingName, string to, bool exactMatch)MapFrom(string mappingName, string to, bool exactMatch, bool mappingContainsValue)
MapFromExists
Checks if a value exists in the specified mapping table. It searches the 'To' column of the mapping table, and if a match is found, it returns true. If no match is found, it returns false. By default, it will look for an exact match, but if you set the exactMatch parameter to false, it will look for a mapping entry that contains the value specified. However, if mappingContainsValue is also set to false, it will look for a mapping entry where the value specified is contained in the mapping.
Overloads
MapFromExists(string mappingName, string to)MapFromExists(string mappingName, string to, bool exactMatch)MapFromExists(string mappingName, string to, bool exactMatch, bool mappingContainsValue)
MapTo
Maps one value to another using the specified mapping table. It searches the 'From' column of the mapping table, and if a match is found, it returns the corresponding value in the 'To' column. If no match is found, the value that was provided as input will be returned. By default, it will look for an exact match, but if you set the exactMatch parameter to false, it will look for a mapping entry that contains the value specified. However, if mappingContainsValue is also set to false, it will look for a mapping entry where the value specified is contained in the mapping.
Overloads
MapTo(string mappingName, string from)MapTo(string mappingName, string from, bool exactMatch)MapTo(string mappingName, string from, bool exactMatch, bool mappingContainsValue)
MapToExists
Checks if a value exists in the specified mapping table. It searches the 'From' column of the mapping table, and if a match is found, it returns true. If no match is found, it returns false. By default, it will look for an exact match, but if you set the exactMatch parameter to false, it will look for a mapping entry that contains the value specified. However, if mappingContainsValue is also set to false, it will look for a mapping entry where the value specified is contained in the mapping.
Overloads
MapToExists(string mappingName, string from)MapToExists(string mappingName, string from, bool exactMatch)MapToExists(string mappingName, string from, bool exactMatch, bool mappingContainsValue)
Example
Input
<?xml version="1.0" encoding="utf-8"?>
<SalesOrders>
<SalesOrder>
<SalesOrderNumber>1000000001</SalesOrderNumber>
<ServiceType>Royal Mail 1st Class</ServiceType>
</SalesOrder>
<SalesOrder>
<SalesOrderNumber>1000000002</SalesOrderNumber>
<ServiceType>DHL Express</ServiceType>
</SalesOrder>
<SalesOrder>
<SalesOrderNumber>1000000003</SalesOrderNumber>
<ServiceType>Royal Mail Standard</ServiceType>
</SalesOrder>
</SalesOrders>
XSLT
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:MappingFunctions="urn:MappingFunctions"
exclude-result-prefixes="MappingFunctions">
<xsl:output indent="yes"/>
<xsl:template match="/">
<Company>
<SalesOrders>
<xsl:for-each select="SalesOrders/SalesOrder">
<SalesOrder>
<xsl:copy-of select="SalesOrderNumber"/>
<Carriage>
<Sku><xsl:value-of select="MappingFunctions:MapTo('Peoplevox Service Type to Sage 200 Additional Charge Code', ServiceType)"/></Sku>
</Carriage>
</SalesOrder>
</xsl:for-each>
</SalesOrders>
</Company>
</xsl:template>
</xsl:stylesheet>
Output
<?xml version="1.0" encoding="utf-8"?>
<Company>
<SalesOrders>
<SalesOrder>
<SalesOrderNumber>1000000001</SalesOrderNumber>
<Carriage>
<Sku>Royal Mail 1st Class</Sku>
</Carriage>
</SalesOrder>
<SalesOrder>
<SalesOrderNumber>1000000002</SalesOrderNumber>
<Carriage>
<Sku>DHL Express</Sku>
</Carriage>
</SalesOrder>
<SalesOrder>
<SalesOrderNumber>1000000003</SalesOrderNumber>
<Carriage>
<Sku>Royal Mail Standard</Sku>
</Carriage>
</SalesOrder>
</SalesOrders>
</Company>