To incorporate JavaScript for transformation assistance, you can utilize <xsl:script>, however its functionality is limited to Microsoft's XML objects implementation. Here is an illustrative example:
scripted.xml:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="scripted.xsl"?>
<data a="v">
ding dong
</data>
scripted.xsl:
<?xml version="1.0" encoding="ISO-8859-1"?>
<html xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:script implements-prefix="local" language="JScript"><![CDATA[
function Title()
{
return "Scripted";
}
function Body(text)
{
return "/" + text + "/";
}
]]></xsl:script>
<head>
<title><xsl:eval>Title()</xsl:eval></title>
</head>
<body>
<xsl:for-each select="/data"><xsl:eval>Body(nodeTypedValue)</xsl:eval></xsl:for-each>
</body>
</html>
The outcome in Internet Explorer (or when utilizing MSXML from COM/.NET) is:
<html>
<head>
<title>Scripted</titlte>
</head>
<body>
/ding dong/
</body>
</html>
It seems not to support the regular XSL template structures, and introducing the root node prompts MSXML to switch to some form of standards mode where it ceases to function.
I'm uncertain if there exists a similar functionality in standard XSL, but one can always hope.