Mapping Functions
Overview
Namespace urn:ZynkLogFunctions
Available since Zynk Workflow 2.1.8
This article will outline how to implement the mapping functions that we have made available in Zynk.
You can use the mappings area in Zynk to configure a conversion from the value in one system to another. For example, if you have a shipping method in your ecommerce system named, 'Royal Mail - 1st class', you may want to convert this to your additional charge code in Sage 200.
For information on how to configure and manage mappings in Zynk, please see here
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
- MapFrom(string mappingName, string to)
- MapFrom(string mappingName, string to, bool exactMatch)
- MapFrom(string mappingName, string to, bool exactMatch, bool mappingContainsValue)
- MapFromExists(string mappingName, string to)
- MapFromExists(string mappingName, string to, bool exactMatch)
- MapFromExists(string mappingName, string to, bool exactMatch, bool mappingContainsValue)
- MapTo(string mappingName, string from)
- MapTo(string mappingName, string from, bool exactMatch)
- MapTo(string mappingName, string from, bool exactMatch, bool mappingContainsValue)
- 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>