Recently we migrated our software dev. to use CLR 2.0. One part of the migration was to rework the usage of XslTransform class to the new XslCompiledTransform class. Reading the "Migrating From the XslTransform class" MSDN paper, it was not much work, just minutes. But then I got this strange exception:
Cannot transform XML using stylesheet 'transform.xslt.'
Exception: Extension function parameters or return values which have Clr type 'ConcatString' are not supported.
This really took me a half day to track it down! First, I did the usual things like reading more carefully the MSDN docs (my wrong direction: security issues), google'd for it and found at least one topic about. This was the right direction to solve it, but I tried various other things to get around - inclusive a complete redesign of the transformation code not using any stylesheet scripts. At last I was more confused (introduced other errors) than as I started, so I reverted the most unrelated changes. After reading the more interesting post "Introducing XslCompiledTransform" and IM'ed with a OS project coworker it gets more clear to me what happens: the System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltResult(XmlQueryType xmlType, Object value) visible in the call stack try to make my <msxsl:script language="JScript" ...> functions to return strong types - but: only the top level functions called from XSL element! Here is the non-working stylesheet code sample:
<msxsl:script language="JScript" implements-prefix="local"><![CDATA[
function fmtDate(val, fmtmask)
{
var s = "" + val;
...
return formatDate(new Date(s.substring(0,4),s.substring(4,6)-1,s.substring(6,8)), fmtmask);
}
function formatDate(varDate, bstrFormat)
{
...
return "" + formattedDate;
}
]]></msxsl:script>
And this is the working one:
<msxsl:script language="JScript" implements-prefix="local"><![CDATA[
function fmtDate(val, fmtmask)
{
var s = "" + val;
...
return "" + formatDate(new Date(s.substring(0,4),s.substring(4,6)-1,s.substring(6,8)), fmtmask);
}
function formatDate(varDate, bstrFormat)
{
...
return "" + formattedDate;
}
]]></msxsl:script>
You notice the small but important difference? Now the stylesheet compiler consider my return value correctly as a string. Whoa...