Mapping

Viewing 1 reply thread
  • Author
    Posts
    • #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,

    • #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.

       

      • #25604

        I don’t think it’s possible to write inline C# script inside XSLT template functoid. Or I just don’t know how.

        • #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.

          • #25615

            Thanks, Greg

            That exactly what I’m looking for. How I can call external assmebly from my xslt template?

            • #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.

Viewing 1 reply thread
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.