Log Functions
Overview
Namespace urn:ZynkLogFunctions
Available since Zynk Workflow 2023.6.2
This article will outline how to implement the logging functions that we have made available in Zynk. When you call one of these functions, a message will be written to the log database, and subsequently, the user interface.
You can make use of the log 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:Log="urn:ZynkLogFunctions"
exclude-result-prefixes="Log">
<!-- transformation -->
</xsl:stylesheet>
Functions
- Info(string message)
- Debug(string message)
- Warning(string message)
- Error(string message)
Example
Input
<?xml version="1.0" encoding="utf-8"?>
<Company>
<Products>
<Product>
<Sku>CALC0001</Sku>
<Name>Basic Calculator</Name>
<Description />
</Product>
<Product>
<Sku>CALC0002</Sku>
<Name>Pocket Calculator</Name>
<Description>You can take this fantastic, pocket sized calculator anywhere with you!</Description>
</Product>
</Products>
</Company>
XSLT
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:Log="urn:ZynkLogFunctions"
exclude-result-prefixes="msxsl Log">
<xsl:output indent="yes"/>
<xsl:template match="/">
<products>
<xsl:for-each select="Company/Products/Product">
<xsl:choose>
<xsl:when test="string-length(Description) = 0">
<xsl:variable name="SingleQuote">'</xsl:variable>
<xsl:variable name="Message" select="concat('The product with SKU, ', $SingleQuote, Sku, $SingleQuote, ', does not have a description.')"/>
<xsl:variable name="Error" select="Log:Error($Message)"/>
<xsl:comment><xsl:value-of select="$Message"/></xsl:comment>
</xsl:when>
<xsl:otherwise>
<product>
<sku><xsl:value-of select="Sku"/></sku>
<title><xsl:value-of select="Name"/></title>
</product>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</products>
</xsl:template>
</xsl:stylesheet>
Output
<?xml version="1.0" encoding="utf-8"?>
<products>
<!--The product with SKU, 'CALC0001', does not have a description.-->
<product>
<sku>CALC0002</sku>
<title>Pocket Calculator</title>
</product>
</products>