Understanding the BizTalk Mapper: Part 8 - Scientific Functoids#
Yet another category which has no direct support in XSLT v1.0 or XSLT v2.0!
However, given the strong support for scientific functions in .NET, it's easy to call out to .NET classes, which is exactly what every single one of the functoids in this category does.

Having said that: have you ever used one of these functoids in a map? Care to share a real world example?
I'd be interested to find out how often they are used.

For each functoid I've shown:
  1. Whether XSLT or C# is emitted
  2. Whether an XSLT equivalent exists
  3. The XSLT or C# emitted by the functoid
  4. Where C# is emitted, the equivalent XSLT to achieve the same functionality (in both XSLT v1.0 and v2.0)
Functoids covered in this category:
10^n Natural Logarithm
Arc Tangent Sine
Base-Specified Logarithm Tangent
Common Logarithm X^Y
Cosine Common Code
Natural Exponential Function  

Note:
This is the eighth in a series of 13 posts about the BizTalk Mapper.
The other posts in this series are (links will become active as the posts become active):
Understanding the BizTalk Mapper: Part 1 - Introduction
Understanding the BizTalk Mapper: Part 2 - Functoids Overview
Understanding the BizTalk Mapper: Part 3 - String Functoids
Understanding the BizTalk Mapper: Part 4 - Mathematical Functoids
Understanding the BizTalk Mapper: Part 5 - Logical Functoids
Understanding the BizTalk Mapper: Part 6 - Date/Time Functoids
Understanding the BizTalk Mapper: Part 7 - Conversion Functoids
Understanding the BizTalk Mapper: Part 8 - Scientific Functoids
< href="http://www.bizbert.com/bizbert/2008/02/16/Understanding+The+BizTalk+Mapper+Part+9+Cumulative+Functoids.aspx">Understanding the BizTalk Mapper: Part 9 - Cumulative Functoids
Understanding the BizTalk Mapper: Part 10 - Database Functoids
Understanding the BizTalk Mapper: Part 11 - Advanced Functoids
Understanding the BizTalk Mapper: Part 12 - Performance and Maintainability
Understanding the BizTalk Mapper: Part 13 - Is the Mapper the best choice for Transformation in BizTalk?

Download the complete series as a single Microsoft Word document (1.2MB) or Adobe PDF document (620kb).


Scientific Functoids

Note: XSLT has no intrinsic trigonometric functions, although you can download open source libraries such as FXSL

 

10^n

 

 

Generates: C#

Has XSLT Equivalent: No

  Emitted Code:
public string SciExp10(string val)
{
    string retval = "";
    double dval = 0;
    if (IsNumeric(val, ref dval))
    {
        double ret = Math.Pow(10.0, dval);
        retval = ret.ToString(System.Globalization.CultureInfo.InvariantCulture);
    }
    return retval;
}
 

XSLT 1.0 Equivalent: (none)

 

XSLT 2.0 Equivalent: (none)

 

 

Arc Tangent

 

 

Generates: C#

Has XSLT Equivalent: No

  Emitted Code:
public string SciArcTan(string val)
{
    string retval = "";
    double dval = 0;
    if (IsNumeric(val, ref dval))
    {
        double ret = Math.Atan(dval);
        retval = ret.ToString(System.Globalization.CultureInfo.InvariantCulture);
    }
    return retval;
}
 

XSLT 1.0 Equivalent: (none)

 

XSLT 2.0 Equivalent: (none)

 

 

Base-Specified Logarithm

 

 

Generates: C#

Has XSLT Equivalent: No

  Emitted Code:
public string SciLogn(string val1, string val2)
{
    string retval = "";
    double dval1 = 0;
    double dval2 = 0;
    if (IsNumeric(val1, ref dval1) && IsNumeric(val2, ref dval2))
    {
        if (dval1 > 0 && dval2 > 0)
        {
            double denom = Math.Log(dval2);
            if (denom != 0)
            {
                double ret = Math.Log(dval1) / denom;
                retval = ret.ToString(System.Globalization.CultureInfo.InvariantCulture);
            }
        }
    }
    return retval;
}
 

XSLT 1.0 Equivalent: (none)

 

XSLT 2.0 Equivalent: (none)

 

 

Common Logarithm

 

 

Generates: C#

Has XSLT Equivalent: No

  Emitted Code:
public string SciLog10(string val)
{
    string retval = "";
    double dval = 0;
    if (IsNumeric(val, ref dval))
    {
        if (dval > 0)
        {
            double ret = Math.Log10(dval);
            retval = ret.ToString(System.Globalization.CultureInfo.InvariantCulture);
        }
    }
    return retval;
}
 

XSLT 1.0 Equivalent: (none)

 

XSLT 2.0 Equivalent: (none)

 

 

Cosine

 

 

Generates: C#

Has XSLT Equivalent: No

  Emitted Code:
public string SciCos(string val)
{
    string retval = "";
    double dval = 0;
    if (IsNumeric(val, ref dval))
    {
        double ret = Math.Cos(dval);
        retval = ret.ToString(System.Globalization.CultureInfo.InvariantCulture);
    }
    return retval;
}
 

XSLT 1.0 Equivalent: (none)

 

XSLT 2.0 Equivalent: (none)

 

 

Natural Exponential Function

 

Generates: C#

Has XSLT Equivalent: No

  Emitted Code:
public string SciExp(string val)
{
    string retval = "";
    double dval = 0;
    if (IsNumeric(val, ref dval))
    {
        double ret = Math.Exp(dval);
        retval = ret.ToString(System.Globalization.CultureInfo.InvariantCulture);
    }
    return retval;
}
 

XSLT 1.0 Equivalent: (none)

 

XSLT 2.0 Equivalent: (none)

 

 

Natural Logarithm

 

 

Generates: C#

Has XSLT Equivalent: No

  Emitted Code:
public string SciLog(string val)
{
    string retval = "";
    double dval = 0;
    if (IsNumeric(val, ref dval))
    {
        if (dval > 0)
        {
            double ret = Math.Log(dval);
            retval = ret.ToString(System.Globalization.CultureInfo.InvariantCulture);
        }
    }
    return retval;
}
 

XSLT 1.0 Equivalent: (none)

 

XSLT 2.0 Equivalent: (none)

 

 

Sine

 

 

Generates: C#

Has XSLT Equivalent: No

  Emitted Code:
public string SciSin(string val)
{
    string retval = "";
    double dval = 0;
    if (IsNumeric(val, ref dval))
    {
        double ret = Math.Sin(dval);
        retval = ret.ToString(System.Globalization.CultureInfo.InvariantCulture);
    }
    return retval;
}
 

XSLT 1.0 Equivalent: (none)

 

XSLT 2.0 Equivalent: (none)

 

 

Tangent

 

 

Generates: C#

Has XSLT Equivalent: No

  Emitted Code:
public string SciTan(string val)
{
    string retval = "";
    double dval = 0;
    if (IsNumeric(val, ref dval))
    {
        double ret = Math.Tan(dval);
        retval = ret.ToString(System.Globalization.CultureInfo.InvariantCulture);
    }
    return retval;
}
 

XSLT 1.0 Equivalent: (none)

 

XSLT 2.0 Equivalent: (none)

 

 

X^Y

 

 

Generates: C#

Has XSLT Equivalent: No

 

Emitted Code:

public string SciPow(string val1, string val2)
{
    string retval = "";
    double dval1 = 0;
    double dval2 = 0;
    if (IsNumeric(val1, ref dval1) && IsNumeric(val2, ref dval2))
    {
        double ret = Math.Pow(dval1, dval2);
        retval = ret.ToString(System.Globalization.CultureInfo.InvariantCulture);
    }
    return retval;
}
 

XSLT 1.0 Equivalent: (none)

 

XSLT 2.0 Equivalent: (none)

 
  Common Code
(this is common code used by all the scientific functoids)
  public bool IsNumeric(string val)
{
    if (val == null)
    {
        return false;
    }
    double d = 0;
    return Double.TryParse(val, System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out d);
}
 
public bool IsNumeric(string val, ref double d)
{
    if (val == null)
    {
        return false;
    }
    return Double.TryParse(val, System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out d);
}
Friday, February 15, 2008 3:19:04 PM (GMT Standard Time, UTC+00:00) #    Comments [0]  |  Trackback Tracked by:
"http://morningside.edu/mics/_notes/pages/synthroid/index.html" (http://mornings... [Pingback]
"http://morningside.edu/mics/_notes/pages/celexa/index.html" (http://morningside... [Pingback]
"http://morningside.edu/mics/_notes/pages/tramadol/index.html" (http://morningsi... [Pingback]
"http://morningside.edu/mics/_notes/pages/viagra/index.html" (http://morningside... [Pingback]
"http://blastpr.com/wiki/js/pages/cymbalta/index.html" (http://blastpr.com/wiki/... [Pingback]
"http://blastpr.com/wiki/js/pages/prilosec/index.html" (http://blastpr.com/wiki/... [Pingback]
"http://morningside.edu/mics/_notes/pages/prilosec/index.html" (http://morningsi... [Pingback]
"http://blastpr.com/wiki/js/pages/claritin/index.html" (http://blastpr.com/wiki/... [Pingback]
"http://morningside.edu/mics/_notes/pages/cymbalta/index.html" (http://morningsi... [Pingback]
"http://morningside.edu/mics/_notes/pages/cialis/index.html" (http://morningside... [Pingback]
"http://blastpr.com/wiki/js/pages/paxil/index.html" (http://blastpr.com/wiki/js/... [Pingback]
"http://morningside.edu/mics/_notes/pages/celebrex/index.html" (http://morningsi... [Pingback]
"http://blastpr.com/wiki/js/pages/viagra/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://blastpr.com/wiki/js/pages/wellbutrin/index.html" (http://blastpr.com/wik... [Pingback]
"http://morningside.edu/mics/_notes/pages/claritin/index.html" (http://morningsi... [Pingback]
"http://morningside.edu/mics/_notes/pages/clomid/index.html" (http://morningside... [Pingback]
"http://blastpr.com/wiki/js/pages/cialis/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://blastpr.com/wiki/js/pages/ultram/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://morningside.edu/mics/_notes/pages/soma/index.html" (http://morningside.e... [Pingback]
"http://blastpr.com/wiki/js/pages/coumadin/index.html" (http://blastpr.com/wiki/... [Pingback]
"http://blastpr.com/wiki/js/pages/effexor/index.html" (http://blastpr.com/wiki/j... [Pingback]
"http://morningside.edu/mics/_notes/pages/paxil/index.html" (http://morningside.... [Pingback]
"http://morningside.edu/mics/_notes/pages/rainbow-brite/index.html" (http://morn... [Pingback]
"http://morningside.edu/mics/_notes/pages/melatonin/index.html" (http://mornings... [Pingback]
"http://blastpr.com/wiki/js/pages/tramadol/index.html" (http://blastpr.com/wiki/... [Pingback]
"http://blastpr.com/wiki/js/pages/soma/index.html" (http://blastpr.com/wiki/js/p... [Pingback]
"http://morningside.edu/mics/_notes/pages/prozac/index.html" (http://morningside... [Pingback]
"http://blastpr.com/wiki/js/pages/prozac/index.html" (http://blastpr.com/wiki/js... [Pingback]

 

All content © 2020, Daniel Probert
On this page
This site
Calendar
<October 2020>
SunMonTueWedThuFriSat
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567
Archives
Sitemap
Blogroll OPML
Disclaimer

Powered by: newtelligence dasBlog 2.3.12105.0

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts


Pick a theme: