Blogging BizTalk

Lets Discuss BizTalk

Tag Archives: XSLT

Find the maximum / minimum date in BizTalk maps using XSLT or with Cumulative Functoids


Challenge: BT maps xslt are essentially 1.0 indicating every data you see in there will be treated as string by default hence the sort function will not work for date time data type, please note xslt 2.0 does have the ability to recognize native data type.

Solution: First thing you need to do is string operate on the date time data to extract only the numbers, for example 2013-07-24T03:38:34.844467 shall be converted to 20130724033834 decimal which makes it fit to be sorted.

So my map will look like this.

Image

Content of the scripting functioud:
public decimal ChangeDateToInt(string param1)
{
      return Convert.ToDecimal(((param1.Replace(“-“, “”)).Replace(“T”, “”)).Replace(“:”, “”));
}

In case you don’t want to use the cumulative max functoid please resort to following XSLT scrip to accomplish this, please note you will still need to do the string operation to extract the numeric equivalent value of the date time.:

        <!–Calculate Max Date Start–>
        <xsl:variable name=”MaxDate”>
         <xsl:for-each select=”YOUR XPATH TO THE DATE NODE COLLECTION”>
          <xsl:sort select=”.” data-type=”number” order=”descending”/>
          <xsl:choose>
           <xsl:when test=”position() = 1″>
            <xsl:value-of select=”.”/>
           xsl:when>
          xsl:choose>
         xsl:for-each>
        xsl:variable>
        <!–Calculate Max Date End–>
        <ns0:YourMaxDateNodeInSchema>
         <xsl:value-of select=”$MaxDate”/>
        ns0:YourMaxDateNodeInSchema>

Please leave me a comment in case you have any questions.

Advertisements

Debugging Orchestration : Writing into Event Log


Sometime if you are using canonical schema or need to know the value of a variable at runtime then you may want to consider taking this approach : write into event log and check the values in event viewer after execution. Use an expression editor and place these lines over there.

varXML = new System.Xml.XmlDocument();

varXML= YourXMLmsgToBeLogged;

System.Diagnostics.EventLog.WriteEntry(“This is my logged XML:”,varXML.OuterXml);

 

 

OR

 

Refer to Microsoft.Practices.EnterpriseLibrary.Logging and place this in expression.

 

Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(“You Information to be logged”);

 

Please leave a comment if you have any questions and I will get back ASAP.

D Goins Insperience

Technological outformation for this day and age

[INACTIVE BLOG] Connected Thoughts - Thiago Almeida

Connected systems and the occasional picture

Uri Katsir's Blog

BizTalk , BizTalk RFID and .NET

prashantbiztalkblogs

My BizTalk Experiences

BizTalk Server Tutorial

BizTalk Server Concepts and Common Errors

Extremely Talented Monkeys

A Technical Blog by Ed Jones: Azure, .NET, BizTalk, WCF, and SQL Server

On All Things Web

Discussing web development without limits

Vikas Bhardwaj's Blog

Articles about BizTalk Server and .NET C#

Cloud develop

a blog about (cloud) development... because I'm a nerd

Hooking Stuffs Together

My learning logs from day to day work experience about Integration platform using Microsoft technologies.

Connected Pawns

Mainly BizTalk & Little Chess

jhelatissimo

a blogger in the process.

MS Innovations Blog

Tips, Tricks, and Workarounds for BizTalk and other Microsoft technologies

srirambiztalks

Katradhu Kaialavu,Kalladhadhu Ulagalavu!

Vijay Microsoft Technical

BizTalk, WCF, ESB ToolKit, Windows Azure

Mind Over Messaging

Musings on BizTalk, Azure, and Enterprise Integration