A project I'm working on involves 3 distinct systems/platforms. C#, Java, and XSLT. I have some simple algorithms (just a bunch of conditionals), expressed in pseudo-code as something like:
 if inputParameter1 is equal to 1
    return "one"
 else if inputParameter2 is equal to 5
    return "five" concatenated with inputParameter1
 else
    return "not found"
simple stuff like that.
I'm trying to figure out a mechanism that will:
- Let me write the algorithm once
- Be able to execute the algorithm in the native language of each system (C#, Java, and XSL)
- Have each system (C#, Java, and XSL) always use the latest version of the algorithm when the algorithm is updated.
So to elaborate on my example, the C# representation would be:
    public string TheMethod(int inputParameter1, int inputParameter2)
    {
       if (inputParameter1 == 1)
       {
          return "one";
       }
       else if (inputParameter2 == 5)
       {
          return string.Concat("five", inputParameter1.ToString());
       }
       else
       {
          return "not found";
       }
    }
and the XSLT representation would be:
<xsl:template name="TheMethod">
  <xsl:param name="inputParameter1" />
  <xsl:param name="inputParameter2" />
  <xsl:choose>
    <xsl:when test="$inputParameter1 = 1">
      <xsl:text>one</xsl:text>
    </xsl:when>
    <xsl:otherwise>
      <xsl:choose>
        <xsl:when test="$inputParameter2 = 5">
          <xsl:text>five</xsl:text>
          <xsl:value-of select="$inputParameter1" />
        </xsl:when>
        <xsl:otherwise>
          <xsl:text>Not Found</xsl:text>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>
hopefully you get the idea.
How would I express an algorithm in a generic way and be able to automatically convert it to C#, Java, or XSL?
Thanks!
-Mike