Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Mapping
- This topic has 6 replies, 1 voice, and was last updated 8 years, 4 months ago by
community-content.
-
AuthorPosts
-
-
August 11, 2010 at 9:52 AM #25601
Hi,
I have different loops and want to use xslt template, but I also have to do some manipulation with a date. A I know XSLT 2.0 functions are not supported. How I can call or use C# code inside the xslt functoid?
Thanks,
-
August 11, 2010 at 10:30 AM #25602
Hi,
Check out the following blog on how to embed C# code in custom XSLT:
http://www.modhul.com/2006/10/01/inline-c-javascript-and-jscript-in-xslt/
Daniel.
-
August 11, 2010 at 11:37 AM #25604
I don’t think it’s possible to write inline C# script inside XSLT template functoid. Or I just don’t know how.
-
August 11, 2010 at 6:19 PM #25608
It may be possible to put inline C# inside an Xslt template but probalbly not worth the hassle.
1. You can use a custom Xslt file with the mapper and add inline C# as described by Nick Heppleston above.
2. You can also add a scripting functoid with your C# code that is not connected to anything and call this from your Xslt template functoid.
3. You can also create an external library and call this from with your Xslt template (need to add an external assembly scripting functoid) You can also call this external assembly in a custom Xslt file by adding an Custom Extensions Xml file to your map definition.The easiest way to discover how to do this, is to create a map using various scripting functoids, use the Validate Map command and view the resulting Xslt.
-
August 12, 2010 at 4:43 PM #25615
Thanks, Greg
That exactly what I’m looking for. How I can call external assmebly from my xslt template?
-
August 12, 2010 at 5:33 PM #25617
You need to use an extension Xml file to specify the external assembly:
I created this assembly:
namespace Map.ExternalAssembly
{
public class Functions
{
public static string GetValue(string value)
{
return value;
}
}
}Create an Xml file called mapextensions.xml:
<ExtensionObjects>
<ExtensionObject Namespace=“urn:external:assembly:functions“ AssemblyName=“Map.ExternalAssembly, Map.ExternalAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8c009a5582cccc7e“ ClassName=“Map.ExternalAssembly.Functions“ />
</ExtensionObjects>
In your map click on the grid and set Custom Extension XML property to point at this xml file.Then in your Xslt template code:
<xsl:template name=”MyTemplate” xmlns:Functions=”urn:external:assembly:functions”>
<xsl:element name=”ModifiedOutput”>
<xs:value-of select=”Functions:GetValue(/some/xpath)” />
</xsl:element>
</xsl:template>The namespace prefix Functions is used to establish the namespace “urn:external:assembly:functions” which is used to find the class from the extensions xml file. You can chose your own prefix and namespace as long as the namespace matchs between the xslt and the extension xml file.
-
August 16, 2010 at 10:09 AM #25643
Thanks Greg. It’s working great. You are the best!
-
-
-
-
-
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.