I’m new to xslt and I’m trying to use some custom C# code in XSLT3.
While searching I’ve seen it was done that way in XSLT1 :
<xsl:variable name="CurrentDateTime"
select="userCSharp:DateCurrentDateTime()" />
...
</xsl:template>
<msxsl:script language="C#" implements-prefix="userCSharp">
<![CDATA[
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>
This is a sample code, mine would be using a custom dll.
but it doesn’t seem to work that way in XSLT3 and most topics I found are about using xslt3 within .Net, not the other way around.
https://www.w3.org/TR/xslt-30/#extension-functions
https://www.saxonica.com/html/documentation12/extensibility/extension-functions-CS/ext-fns-N.html
But I can’t understand how it’s supposed to be done.
Would anyone have a simple example?