none
How to pass Concatenated value of elements into a C# Scripting functiod RRS feed

  • Question

  • Hi,

    I have an XML , an example of if it is below.

    In the existing map a call to the Biztalk functoid is made to make a caluclation and result of it is mapped to element on Destination Schema.

    Now I want to concatenate all the Message values into one Variable and then pass that variable to c# scriptig functiod.

    Is there a way I can do it ??
    .
    .
    .
    .
    <Test>
       <Message>
    </Test>
    <Test>
       <Message>
    </Test>
    <Test>
       <Message>
    </Test>
    <Test>
       <Message>
    </Test>
    <Test>
       <Message>
    </Test>
    <Test>
       <Message>
    </Test>
    .
    .
    .
    .

    Thanks,

    Gopi


    Krishna

    Thursday, November 1, 2012 1:11 PM

Answers

  • Try with Custom XSLT :
    <?xml version="1.0" encoding="UTF-16"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" exclude-result-prefixes="msxsl var userCSharp" version="1.0" xmlns:ns0="http://BizTalk_Server_Project4.Schema1" xmlns:userCSharp="http://schemas.microsoft.com/BizTalk/2003/userCSharp">
      <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
      <xsl:template match="/">
        <xsl:apply-templates select="/Root" />
      </xsl:template>
      <xsl:template match="/Root">
        <ns0:Root>
          <xsl:for-each select="Test">
            <xsl:variable name="var:v1" select="userCSharp:CustomStringConcat(string(Message/text()))" />
            </xsl:for-each> 
          <Field>
            <xsl:variable name="var:v2" select="userCSharp:returnFx()" />
              <xsl:value-of select="$var:v2" />
            </Field>
         
        </ns0:Root>
      </xsl:template>
      <msxsl:script language="C#" implements-prefix="userCSharp">
      <![CDATA[
      string Final;
    public void CustomStringConcat(string param0)
    {
       Final = Final + param0;
    }
    
    public string returnFx()
    {
    return Final;
    }
    
    
    ]]></msxsl:script>
    </xsl:stylesheet>


    • Marked as answer by Krishna Kal Thursday, November 1, 2012 8:11 PM
    Thursday, November 1, 2012 1:45 PM

All replies

  • Try with Custom XSLT :
    <?xml version="1.0" encoding="UTF-16"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" exclude-result-prefixes="msxsl var userCSharp" version="1.0" xmlns:ns0="http://BizTalk_Server_Project4.Schema1" xmlns:userCSharp="http://schemas.microsoft.com/BizTalk/2003/userCSharp">
      <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
      <xsl:template match="/">
        <xsl:apply-templates select="/Root" />
      </xsl:template>
      <xsl:template match="/Root">
        <ns0:Root>
          <xsl:for-each select="Test">
            <xsl:variable name="var:v1" select="userCSharp:CustomStringConcat(string(Message/text()))" />
            </xsl:for-each> 
          <Field>
            <xsl:variable name="var:v2" select="userCSharp:returnFx()" />
              <xsl:value-of select="$var:v2" />
            </Field>
         
        </ns0:Root>
      </xsl:template>
      <msxsl:script language="C#" implements-prefix="userCSharp">
      <![CDATA[
      string Final;
    public void CustomStringConcat(string param0)
    {
       Final = Final + param0;
    }
    
    public string returnFx()
    {
    return Final;
    }
    
    
    ]]></msxsl:script>
    </xsl:stylesheet>


    • Marked as answer by Krishna Kal Thursday, November 1, 2012 8:11 PM
    Thursday, November 1, 2012 1:45 PM
  • Thanks

    Your suggestion did help me 


    Krishna

    Thursday, November 1, 2012 8:12 PM