I'm using a system which consists of many complex XSL transforms which each work on large XML files. A proprietary program compiles the XSLT on each of the XML files, before passing the XML files to our databases.
The XSL transforms almost always involve C# functions within <msxsl> tags, many which are repeated between several files with the code copied manually. I'm trying to implement a system where a general repository of functions are stored in one file, and then loaded into the XSLT file before being read by the <msxsl> tags.
My problem is that I have been unable to find a way to have the code within <msxsl> loaded from an external file. Here's an example of what I mean:
The transform with the function hard-coded:
...
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:cs="urn:my-scripts-csharp">
...
<msxsl:script language="C#" implements-prefix="cs">
<![CDATA[
public string emphasise(string input) {
return input+"!";
}
]]>
</msxsl:script>
...
Whilst I'd like the function loaded externally:
...
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:cs="urn:my-scripts-csharp">
...
<msxsl:script language="C#" implements-prefix="cs">
<--- file loaded here --->
</msxsl:script>
...
Where the source file would be something like:
<![CDATA[
public string emphasise(string input) {
return input+"!";
}
]]>
Is this possible? The functions are generally complex (unlike this example) and cannot be reproduced with XSLT code. Would namespace and using keywords from the external file be read or would I have to include them outside of it with <msxsl:using> tags?
I'm quite new to the use of <msxsl> tags, and if I'm misunderstanding something fundamental then do please let me know!