Question

I'm working on a project that involves XSLT. And would like to use a C# script in my XSLT. Just like in the following link. XSLT 1.0 Get Current DateTime

Although I ran into this KB article http://support.microsoft.com/kb/316775 saying that this causes memory leaks when loading the stylesheet multiple times.

The KB article doesn't say which .NET versions are affected. Can anyone advise whether this is fixed in .NET 2.0 or higher ?

My target environment have .NET 2.0 and 3.5, although the code that does the XSLT transform is compiled to .NET 2.0.

Note: I don't have control over the code that run the transformation. I can only write the XSLT

Was it helpful?

Solution

This isn't a bug -- in the first place.

More importantly, this is absolutely avoidable.

The solution is: not to have inline scripts but to use an extension objects that contains the wanted extension functions.

More information how to write extension functions as part of an extension object -- for XslCompiledTransform can be found here:

http://msdn.microsoft.com/en-us/library/tf741884

and a full code example here:

http://msdn.microsoft.com/en-us/library/system.xml.xsl.xsltargumentlist.addextensionobject

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top