When developing pure messaging solutions (no orchestrations) in BizTalk often there’s a need to apply transformation on the message. BizTalk has out of the box functionality to execute maps on receive (inbound map) and send (outbound map) ports. Sometimes using classic BizTalk map is not the best solution, for example for complex transformations with grouping (for example, using Muenchian Method). In other cases, it’s strongly preferable to keep transformation easily configurable to be able to change it on the fly without overhead of deploying new map. Transformations using XSL stylesheet seems to fit that task very well.
One problem though, using standard .Net XML/XSL API won’t yield the best performance. Performance degradation will be especially noticeable in high throughput scenarious with large message size. BizTalk internally uses more efficient transformation API that is tuned for better performance for large messages. The classes that make this possible are VirtualStream (located in microsoft.biztalk.streaming.dll) and BTSXslTransform (located in Microsoft.xlangs.basetypes.dll). VirtualStream minimizes memory footprint by backing storage to file system.
Utilizing these classes I created generic pipeline component that can execute XSL transformation inside pipeline in a scalable fashion. As an additional feature it can be configured to execute standard BizTalk map.
Following configuration properties are available on the component:
Property
|
Values
|
Description
|
IsScalable
|
True | False
|
Indicates if transform should always be scalable
|
MapName
|
{XslUrl} | {BizTalk Map Name}
|
Defines the XSL URL or fully qualified map name to use for transformation
|
MessageType
|
{namespace}#{root}
|
Target message type
|
SchemaStrongName
|
{Class}, {Assembly}, Version={}, Culture={}, PublicKeyToken={}
|
Fully qualified .Net schema type name
|
TransformUsing
|
XslStylesheet | BizTalkMap
|
Indicates what kind of transformation is used
|
Source code with example project is available at http://www.box.net/shared/93p7n1vsl6