Skip to content

Truth Functions in XSLT

Overview

This article explains how to implement truth functions in your mapping files when running them in Zynk Workflow. These functions allow you to retrieve data directly from Zynk's Truth Table from within an XSLT.

  • Namespace: urn:TruthFunctions
  • Available since: 2026.5.2

Declaration

To use truth 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:TruthFunctions="urn:TruthFunctions"
    exclude-result-prefixes="TruthFunctions">

    <!-- transformation -->

</xsl:stylesheet>

Functions

Below is a list of available functions within the urn:TruthFunctions namespace:

InternalIdExists

Checks if the combination of internal ID and type specified exists in the truth table. If a collection is specified, it will also be considered when searching the truth table. A workflow ID can be specified if you want to search truth records that belong to a different workflow than the one the XSLT is running in.

Overloads

  • InternalIdExists(string internalId, string type)
  • InternalIdExists(string internalId, string type, string collection)
  • InternalIdExists(string internalId, string type, string collection, string workflowId)

ExternalIdExists

Checks if the combination of external ID and type specified exists in the truth table. If a collection is specified, it will also be considered when searching the truth table. A workflow ID can be specified if you want to search truth records that belong to a different workflow than the one the XSLT is running in.

Overloads

  • ExternalIdExists(string externalId, string type)
  • ExternalIdExists(string externalId, string type, string collection)
  • ExternalIdExists(string externalId, string type, string collection, string workflowId)

GetInternalId

Retrieves an internal ID from the truth table based on a combination of external ID and type. If a collection is specified, it will also be considered when searching the truth table. A workflow ID can be specified if you want to search truth records that belong to a different workflow than the one the XSLT is running in.

Overloads

  • GetInternalId(string externalId, string type)
  • GetInternalId(string externalId, string type, string collection)
  • GetInternalId(string externalId, string type, string collection, string workflowId)

GetExternalId

Retrieves an external ID from the truth table based on a combination of internal ID and type. If a collection is specified, it will also be considered when searching the truth table. A workflow ID can be specified if you want to search truth records that belong to a different workflow than the one the XSLT is running in.

Overloads

  • GetExternalId(string internalId, string type)
  • GetExternalId(string internalId, string type, string collection)
  • GetExternalId(string internalId, string type, string collection, string workflowId)

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:TruthFunctions="urn:TruthFunctions"
    exclude-result-prefixes="TruthFunctions">

    <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>
            <xsl:if test="TruthFunctions:ExternalIdExists(OrderId, 'Zynk.Connect.Objects.SalesOrder')">
                <SalesOrderNumber><xsl:value-of select="TruthFunctions:GetInternalId(OrderId, 'Zynk.Connect.Objects.SalesOrder')"/></SalesOrderNumber>
            </xsl:if>            
        </SalesOrder>
    </xsl:template>    
</xsl:stylesheet>

Output XML

<Company>
    <SalesOrders>
        <SalesOrder>
            <SalesOrderNumber>0000002058</SalesOrderNumber> <!-- the matching internal ID from the truth table -->
        </SalesOrder>
    </SalesOrders>
</Company>

See Also

  • Truth Table - This article provides information about the truth table.