In complex maps is usual to have scripting functoid with custom inline XSLT, and sometimes is useful to call custom .NET components directly from XSLT.
So, how can we do this?
You can add a custom extension XML file to your solution in order to declare the namespace and use a method from a .NET assembly from XSLT.
The extension file should look something like this:
<ExtensionObjects> <ExtensionObject Namespace="http://MapperHelper" AssemblyName="BizTalk.Mapper.Helper, Version=188.8.131.52, Culture=neutral, PublicKeyToken=b39e2eca2a3d19ec" ClassName="BizTalk.Mapper.Helper.MappingHelper "/> </ExtensionObjects>
In the properties of your BizTalk Mapper, use the Custom Extension XML property to open the Select Custom Extension XML File dialog box, in which you can select the file that contains the custom extension XML for the map (file above).
Note: There are two cases in which you will need to build your own custom extension XML file and set the Custom Extension XML file to refer to it, as follows:
- If you use the Custom XSLT Path property to specify your own XSLT for the entire map file and you call an external .NET assembly from your XSLT, you are responsible for creating a properly formatted custom extension XML file that provides the appropriate namespace-to-assembly binding.
- If you use the Inline XSLT or the Inline XSLT Call Template script types in a Scripting functoid and you call a method in an external .NET assembly from that XSLT, you are responsible for creating a properly formatted custom extension XML file that provides the appropriate namespace-to-assembly binding. This is required because BizTalk Mapper does not parse into the XSLT you provide looking for calls to external assemblies. Any binding information you provide by using the Custom Extension XML property will be appended to any binding information that has already been generated when the map was compiled (such as bindings required by other Scripting functoids in the map that use the external assembly option). When you validate the map, the resulting contents of the custom extension XML file contain the union of the binding information you provided and any binding information generated by BizTalk Mapper.
Finally, in your Inline XSLT functoid, you can use the methods from the assembly by:
<xsl:variable name="result" xmlns:myScriptPrefix="http://MapperHelper" select="myScriptPrefix:myConcat($param1, $param2)" />