Skip to content

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.

XSLT

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

  • MapFrom
  • string mappingName, string to
  • string mappingName, string to, bool exactMatch
  • MapFromExists
  • string mappingName, string to
  • string mappingName, string to, bool exactMatch
  • string mappingName, string to, bool exactMatch, bool mappingContainsValue
  • MapTo
  • string mappingName, string from
  • string mappingName, string from, bool exactMatch
  • string mappingName, string from, bool exactMatch, bool mappingContainsValue
  • MapToExists
  • string mappingName, string from
  • string mappingName, string from, bool exactMatch
  • 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>