Compiled XSLT in Biztalk Orchestrations

One of the new features in the Visual Studio 2008 release is the XSLT Compiler tool xsltc.exe.  The documentation can be found here.  This tool will precompile the xslt sheets into an assembly.

It has been my experience over the years that the xsl mappings change more often than the message flows.  With the xsltc.exe tool the mappings can be changed, compiled and installed without changing the Biztalk orchestrations.

First you need to create the xsl DLLs:

xsltc.exe  /settings:document+,script+ myXsl.xsl

This will create a DLL file with the compiled xsl.  There also might be DLLs for embedded scripts.

To use the xsl DLLs the assemblies have to be signed.  Use ILDASM and ILASM to disassemble and then sign and reassemble the xsl DLL

sn -k xsltc.snk

ildasm myXsl.dll /

ilasm /dll /key:xsltc.snk /out:myXslSN.dll

OK.  Now include the myXslSN.dll in the biztalk Project

Create an orchestration with 3 vars: xmlDocIn,xt,xmlDocOut.  Add a message assignment Shape  with this expression:

//Assuming xmlDocIn has already been assigned
xt = new System.Xml.Xsl.XslCompiledTransform();

xmlDocOut = new System.Xml.XmlDocument();
xt.Transform(xmlDocIn, (System.Xml.Xsl.XsltArgumentList)null, xmlDocOut.CreateNavigator().AppendChild());

There might be performance issues with loading the XSLT dlls but I'm researching that.

Print | posted on Thursday, April 3, 2008 2:36 PM