Search code examples
biztalkbiztalk-mapperbiztalk-2020

How to use XSLT2.0 in BizTalk?


I'm trying to using XSLT 2.0 in BizTalk 2020. But I'm getting this below error.

'current-dateTime()' is an unknown XSLT function.

How to get rid of this? Do I need Saxon Engine to use 2.0?

enter image description here


Solution

  • Yes, you have to use the Saxon Engine if you want to use a later version of XSLT.

    See What’s new in BizTalk Server 2020: XSLT 3.0 Support (Sandro Periara's blog)

    BizTalk’s default XSL transform engine implementation is based on .Net Framework XSLT Transformations. This support is limited to XSLT 1.0.

    Starting with BizTalk Server 2020, users can choose Saxon:registered: 9 (Saxon 9 HE) as the XSLT transform engine. But most importantly, it will be possible to plug-in your own custom XSLT transform engine.

    If you want to use XLST 1.0 to get the date, then just use the same method that is created when you use the out of the box Date and Time functoid in the BizTalk mapper.

    <xsl:variable name="var:v2" select="userCSharp:DateCurrentDateTime()" /> 
    
    <msxsl:script language="C#" implements-prefix="userCSharp">
    <![CDATA[ public string RemoveSpaces(string stringWithSpaces)
    public string DateCurrentDateTime()
    {
        DateTime dt = DateTime.Now;
        string curdate = dt.ToString("yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
        string curtime = dt.ToString("T", System.Globalization.CultureInfo.InvariantCulture);
        string retval = curdate + "T" + curtime;
        return retval;
    }
    ]]> 
    </msxsl:script>