Calling an external assembly from Custom XSLT

This is a discussion on Calling an external assembly from Custom XSLT within the Commerce server forums in Microsoft Tools category; I have several instances where I put a Scripting Functoid in my map, configure it as Inline Visual Basic .NET, and then call that function from my Custom XSLT using the userVB namespace. Now I want to be able to do the same thing with a Scripting Functoid configured as an External Assembly. If I drop the Scripting Functoid in the map, configure it as an External Assembly, and then use it directly in the map (connecting its inputs and outputs directly to the source and target schemas) and then do Validate Map to see the resultant XSL, the XSL ...

Go Back   Application Development Forum > Microsoft Tools > Commerce server

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 03-18-2008, 03:19 PM
Zoe Hart
Guest
 
Default Calling an external assembly from Custom XSLT

I have several instances where I put a Scripting Functoid in my map,
configure it as Inline Visual Basic .NET, and then call that function from
my Custom XSLT using the userVB namespace. Now I want to be able to do the
same thing with a Scripting Functoid configured as an External Assembly. If
I drop the Scripting Functoid in the map, configure it as an External
Assembly, and then use it directly in the map (connecting its inputs and
outputs directly to the source and target schemas) and then do Validate Map
to see the resultant XSL, the XSL includes a declaration of the namespace
ScriptNS0 as http://schemas.microsoft.com/BizTalk/2003/ScriptNS0. The calls
to the external function then use this ScriptNS0 namespace. But if I remove
the input and output connections from the functoid and try to call it from
my custom XSLT, the namespace isn't defined. When I do the same thing with
an Inline Visual Basic .NET scripting functoid, the namespace declaration is
automatically added to the XSL.

So how can I configure a scripting functoid as External Assembly and call it
from my custom XSLT?

Thanks,
Zoe


Reply With Quote
  #2  
Old 03-19-2008, 04:10 AM
Randal van Splunteren
Guest
 
Default Re: Calling an external assembly from Custom XSLT

Hi Zoe,

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 XSL.

The extension file should look something like this:

<ExtensionObjects>
<ExtensionObject Namespace="http://mapHelper"
AssemblyName="MyHelperAssembly, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=..." ClassName="MyHelper.MappingHelper"/>
</ExtensionObjects>

In the properties of your BizTalk map point the value of the 'custom
extension file' property to the file above.

Finally in your xsl you can use the method from the assembly. For example:

<xsl:variable name="methodResult" xmlns:mapHelper="http://mapHelper"
select="MappingHelperoMethod()" />
<xsl:value-of select="$methodResult" />

Although this solution doesn't use a scripting functoid as an external
assembly you can use it to call a custom .Net method from your code. If I
interpret your question correctly that is what you need to do.

HTH,

Randal van Splunteren

"Zoe Hart" <zoe.hart@nospam.competitive.com> wrote in message
news:%23Z0K9zSiIHA.4376@TK2MSFTNGP05.phx.gbl...
> I have several instances where I put a Scripting Functoid in my map,
> configure it as Inline Visual Basic .NET, and then call that function from
> my Custom XSLT using the userVB namespace. Now I want to be able to do the
> same thing with a Scripting Functoid configured as an External Assembly.

If
> I drop the Scripting Functoid in the map, configure it as an External
> Assembly, and then use it directly in the map (connecting its inputs and
> outputs directly to the source and target schemas) and then do Validate

Map
> to see the resultant XSL, the XSL includes a declaration of the namespace
> ScriptNS0 as http://schemas.microsoft.com/BizTalk/2003/ScriptNS0. The

calls
> to the external function then use this ScriptNS0 namespace. But if I

remove
> the input and output connections from the functoid and try to call it from
> my custom XSLT, the namespace isn't defined. When I do the same thing with
> an Inline Visual Basic .NET scripting functoid, the namespace declaration

is
> automatically added to the XSL.
>
> So how can I configure a scripting functoid as External Assembly and call

it
> from my custom XSLT?
>
> Thanks,
> Zoe
>
>



Reply With Quote
  #3  
Old 03-20-2008, 08:26 AM
Zoe Hart
Guest
 
Default Re: Calling an external assembly from Custom XSLT

You are correct. I don't need the scripting functoid. I was just using that
as a means of accessing my external assembly. I will try the approach you
describe instead.

Thanks,
Zoe

"Randal van Splunteren" <Randal.van.Splunteren@hotmail.com> wrote in message
news:O3TS9iZiIHA.4344@TK2MSFTNGP03.phx.gbl...
> Hi Zoe,
>
> 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 XSL.
>
> The extension file should look something like this:
>
> <ExtensionObjects>
> <ExtensionObject Namespace="http://mapHelper"
> AssemblyName="MyHelperAssembly, Version=1.0.0.0, Culture=neutral,
> PublicKeyToken=..." ClassName="MyHelper.MappingHelper"/>
> </ExtensionObjects>
>
> In the properties of your BizTalk map point the value of the 'custom
> extension file' property to the file above.
>
> Finally in your xsl you can use the method from the assembly. For example:
>
> <xsl:variable name="methodResult" xmlns:mapHelper="http://mapHelper"
> select="MappingHelperoMethod()" />
> <xsl:value-of select="$methodResult" />
>
> Although this solution doesn't use a scripting functoid as an external
> assembly you can use it to call a custom .Net method from your code. If I
> interpret your question correctly that is what you need to do.
>
> HTH,
>
> Randal van Splunteren
>
> "Zoe Hart" <zoe.hart@nospam.competitive.com> wrote in message
> news:%23Z0K9zSiIHA.4376@TK2MSFTNGP05.phx.gbl...
>> I have several instances where I put a Scripting Functoid in my map,
>> configure it as Inline Visual Basic .NET, and then call that function
>> from
>> my Custom XSLT using the userVB namespace. Now I want to be able to do
>> the
>> same thing with a Scripting Functoid configured as an External Assembly.

> If
>> I drop the Scripting Functoid in the map, configure it as an External
>> Assembly, and then use it directly in the map (connecting its inputs and
>> outputs directly to the source and target schemas) and then do Validate

> Map
>> to see the resultant XSL, the XSL includes a declaration of the namespace
>> ScriptNS0 as http://schemas.microsoft.com/BizTalk/2003/ScriptNS0. The

> calls
>> to the external function then use this ScriptNS0 namespace. But if I

> remove
>> the input and output connections from the functoid and try to call it
>> from
>> my custom XSLT, the namespace isn't defined. When I do the same thing
>> with
>> an Inline Visual Basic .NET scripting functoid, the namespace declaration

> is
>> automatically added to the XSL.
>>
>> So how can I configure a scripting functoid as External Assembly and call

> it
>> from my custom XSLT?
>>
>> Thanks,
>> Zoe
>>
>>

>
>



Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 08:17 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.