String Functions in XSLT
Overview
This article explains how to implement string functions in your mapping files when running them in Zynk Workflow. These functions allow you to perform a range of additional string operations from within an XSLT.
- Namespace:
urn:StringFunctions - Available since:
2026.6.3
Declaration
To use string 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:StringFunctions="urn:StringFunctions"
exclude-result-prefixes="StringFunctions">
<!-- transformation -->
</xsl:stylesheet>
Functions
Below is a list of available functions within the urn:StringFunctions namespace:
EndsWith
Checks if the end of the input string matches the value string.
Overloads
EndsWith(string input, string value)
RegexMatch
Checks whether the specified regular expression finds a match in the specified input string.
Overloads
RegexMatch(string input, string pattern)
RegexReplace
Within the specified input string, replaces all strings that match the specified regular expression with the specified replacement string.
Overloads
RegexReplace(string input, string pattern, string replacement)
Replace
Returns the input string, but with all occurrences of the specified oldValue string replaced with the newValue string.
Overloads
Replace(string input, string oldValue, string newValue)
ToLower
Converts the specified string to lower case.
Overloads
ToLower(string input)
ToUpper
Converts the specified string to upper case.
Overloads
ToUpper(string input)
Example
Input XML
<?xml version="1.0" encoding="utf-8"?>
<Customers>
<Customer>
<Id>1</Id>
<Name>Zynk Software Limited</Name>
<Email>[email protected]</Email>
<TaxCode>T1</TaxCode>
</Customer>
<Customer>
<Id>2</Id>
<Name>John Smith</Name>
<Email>[email protected]</Email>
<TaxCode>T1</TaxCode>
</Customer>
</Customers>
XSLT
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:StringFunctions="urn:StringFunctions"
exclude-result-prefixes="StringFunctions">
<xsl:output indent="yes" />
<xsl:template match="/">
<Company>
<Customers>
<xsl:for-each select="Customers/Customer">
<xsl:call-template name="Customer" />
</xsl:for-each>
</Customers>
</Company>
</xsl:template>
<xsl:template name="Customer">
<Customer>
<Id><xsl:value-of select="Id" /></Id>
<NameUpper><xsl:value-of select="StringFunctions:ToUpper(Name)" /></NameUpper>
<NameLower><xsl:value-of select="StringFunctions:ToLower(Name)" /></NameLower>
<IsCompany><xsl:value-of select="StringFunctions:RegexMatch(Name, '(?i)(\W|^)(limited|ltd|company|inc|plc)(\W|$)')" /></IsCompany>
<EmailDomain><xsl:value-of select="StringFunctions:RegexReplace(Email, '[\w.-]+@', '')" /></EmailDomain>
<IsGmail><xsl:value-of select="StringFunctions:EndsWith(Email, '@gmail.com')" /></IsGmail>
<TaxCode><xsl:value-of select="StringFunctions:Replace(TaxCode, 'T', '')" /></TaxCode>
</Customer>
</xsl:template>
</xsl:stylesheet>
Output XML
<Company>
<Customers>
<Customer>
<Id>1</Id>
<NameUpper>ZYNK SOFTWARE LIMITED</NameUpper>
<NameLower>zynk software limited</NameLower>
<IsCompany>true</IsCompany>
<EmailDomain>zynk.com</EmailDomain>
<IsGmail>false</IsGmail>
<TaxCode>1</TaxCode>
</Customer>
<Customer>
<Id>2</Id>
<NameUpper>JOHN SMITH</NameUpper>
<NameLower>john smith</NameLower>
<IsCompany>false</IsCompany>
<EmailDomain>gmail.com</EmailDomain>
<IsGmail>true</IsGmail>
<TaxCode>1</TaxCode>
</Customer>
</Customers>
</Company>