Date-time in BizTalkMapper using xslt

811 Views Asked by At

Am writing some InlineXslt script in scripting functoid of BizTalk(2010) mapping file in VisualStudio2010.(It supports only version 1.0).

I need to use current date-time at many places in my xslt script. To get current date-time, I was using Date-time functoid or writing some C# code in one scripting functoid and passing it as a parameter to another scripting functoid (where XSLT script is written).

But now if I generate XSL file out of mapper, it contains C# namespace and C# code.

Now I want to do it using only XSLT. I want to include EXSLT namespace (http:/exslt.org/dates-and-times) and extension-element-prefixes="date" , and use a function "date:date-time()" to get current date and time.

Instead of modifying the generated XSL file, I want to achieve this at an earlier stage so that when I generate xsl file out of BizTalk mapper, it contains only XSLT script.

Is it possible to include this namespace in InlineXslt or Inlinexslt template of scripting functoid, so that I can use the function date-time() while writing XSLT script in functoid?

1

There are 1 best solutions below

0
On

From this blog How the extend a custom Xslt in BizTalk using EXSLT and the Mvp.Xml project by Richard Hallgren

You have to create an XML extension

<?xml version="1.0" encoding="utf-8"?>
<ExtensionObjects>
    <ExtensionObject
     Namespace="http://exslt.org/dates-and-times"
     AssemblyName="Mvp.Xml,
     Version=2.3.0.0, Culture=neutral,
     PublicKeyToken=6ead800d778c9b9f"
     ClassName="Mvp.Xml.Exslt.ExsltDatesAndTimes"/>
</ExtensionObjects>

Create a custom XSLT

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:S1="http://ExtendedMapping.Schema1"
                xmlns:S2="http://ExtendedMapping.Schema2"
                xmlns:exslt="http://exslt.org/dates-and-times"
                version="1.0"> 

    <xsl:template match="/">
        <S2:Root>
            <Field>
                <xsl:value-of select="exslt:dateTime()"/>
            </Field>
        </S2:Root>
    </xsl:template>
</xsl:stylesheet>

And then configure the map to point the Custom Extension XML to the first and the Custom XSL Path to the second. This means you will need to do all mapping in the XSL file, rather than on the mapper grid with functoids as those will be ignored.