Caching Functions in XSLT
Overview
This article explains how to implement caching functions in your mapping files when running them in Zynk Workflow.
- Namespace urn:CachingFunctions
- Available since 2025.1.1
XSLT
Declaration
To use caching functions, you need to add the namespace declaration to your XSLT file:
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:CachingFunctions="urn:CachingFunctions"
exclude-result-prefixes="CachingFunctions">
<!-- transformation -->
</xsl:stylesheet>
Functions
Below is a list of available functions within the urn:CachingFunctions
namespace:
- RecordExists Checks the cache database for a record based on the parameters provided.
string cacheName, string key
string cacheName, string key, string connectionId
string cacheName, string key, double timeToLiveSeconds
string cacheName, string key, string connectionId, double timeToLiveSeconds
- GetValue Retrieves a value from the cache database based on the parameters provided.
string cacheName, string key
string cacheName, string key, string connectionId
string cacheName, string key, double timeToLiveSeconds
string cacheName, string key, string connectionId, double timeToLiveSeconds
- GetXml Retrieves XML data from the cache database based on the parameters provided.
string cacheName, string key
string cacheName, string key, string connectionId
string cacheName, string key, double timeToLiveSeconds
string cacheName, string key, string connectionId, double timeToLiveSeconds
- UpsertValue Creates or updates a value in the cache database based on the parameters provided.
string cacheName, string key, string value
string cacheName, string key, string value, string connectionId
- UpsertXml Creates or updates XML data in the cache database based on the parameters provided.
string cacheName, string key, XPathNavigator xml
string cacheName, string key, XPathNavigator xml, string connectionId
Example
Input XML
<?xml version="1.0" encoding="utf-8"?>
<Orders>
<Order>
<OrderId>1</OrderId>
<CustomerId>5</CustomerId>
</Order>
</Orders>
XSLT
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:CacheFunctions="urn:CacheFunctions"
exclude-result-prefixes="CacheFunctions">
<xsl:output indent="yes" />
<xsl:template match="/">
<Company>
<SalesOrders>
<xsl:for-each select="Orders/Order">
<xsl:call-template name="SalesOrder" />
</xsl:for-each>
</SalesOrders>
</Company>
</xsl:template>
<xsl:template name="SalesOrder">
<SalesOrder>
<Id><xsl:value-of select="OrderId"/></Id>
<AccountReference>
<xsl:choose>
<xsl:when test="CacheFunctions:RecordExists('Customers', CustomerId)">
<xsl:value-of select="CacheFunctions:GetValue('Customers', CustomerId)"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>WEBSALES</xsl:text>
</xsl:otherwise>
</xsl:choose>
</AccountReference>
</SalesOrder>
</xsl:template>
</xsl:stylesheet>
Output XML
<Company>
<SalesOrders>
<SalesOrder>
<Id>1</Id>
<AccountReference>ZYNK0001</AccountReference> <!-- the matching account reference from the cache db -->
</SalesOrder>
</SalesOrders>
</Company>
See Also
- Caching in Zynk Workflow This article outlines how to review and update your cache tables in the cache manager.
- Importing Complex Records to Salesforce (V2) This task implements caching functionality to perform quicker lookups in Salesforce.
- Import Cache Records This task allows you to import records into the cache database based on your XML input data and a series of task settings.