Caching Functions in XSLT
Overview
This article explains how to implement caching functions in your mapping files when running them in Zynk Workflow. These functions allow you to retrieve and enter data directly in Zynk's Cache from within an XSLT.
- Namespace:
urn:CacheFunctions - Available since:
2025.1.1
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:CacheFunctions="urn:CacheFunctions"
exclude-result-prefixes="CacheFunctions">
<!-- transformation -->
</xsl:stylesheet>
Functions
Below is a list of available functions within the urn:CacheFunctions namespace:
RecordExists
Checks the cache database for a record based on the parameters provided.
Overloads
RecordExists(string cacheName, string key)RecordExists(string cacheName, string key, string connectionId)RecordExists(string cacheName, string key, double timeToLiveSeconds)RecordExists(string cacheName, string key, string connectionId, double timeToLiveSeconds)
GetValue
Retrieves a value from the cache database based on the parameters provided.
Overloads
GetValue(string cacheName, string key)GetValue(string cacheName, string key, string connectionId)GetValue(string cacheName, string key, double timeToLiveSeconds)GetValue(string cacheName, string key, string connectionId, double timeToLiveSeconds)
GetXml
Retrieves XML data from the cache database based on the parameters provided.
Overloads
GetXml(string cacheName, string key)GetXml(string cacheName, string key, string connectionId)GetXml(string cacheName, string key, double timeToLiveSeconds)GetXml(string cacheName, string key, string connectionId, double timeToLiveSeconds)
UpsertValue
Creates or updates a value in the cache database based on the parameters provided.
Overloads
UpsertValue(string cacheName, string key, string value)UpsertValue(string cacheName, string key, string value, string connectionId)
UpsertXml
Creates or updates XML data in the cache database based on the parameters provided.
Overloads
UpsertXml(string cacheName, string key, XPathNavigator xml)UpsertXml(string cacheName, string key, XPathNavigator xml, string connectionId)
Example
Input XML
<?xml version="1.0" encoding="utf-8"?>
<Orders>
<Order>
<OrderId>1</OrderId>
<CustomerId>123</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>ZYNK001</AccountReference>
<xsl:choose>
<xsl:when test="CacheFunctions:RecordExists('Customers', CustomerId)">
<CompanyName><xsl:value-of select="CacheFunctions:GetValue('Customers', CustomerId)"/></CompanyName>
</xsl:when>
</xsl:choose>
</SalesOrder>
</xsl:template>
</xsl:stylesheet>
Output XML
<Company>
<SalesOrders>
<SalesOrder>
<Id>1</Id>
<AccountReference>ZYNK001</AccountReference>
<CompanyName>John Doe</CompanyName> <!-- 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 into 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.