cancel
Showing results for 
Search instead for 
Did you mean: 

concatenating multiple occurances of the same fieldin XSLT

former_member187447
Participant
0 Kudos

Hi Folks, I have to concatenate multiple occurances of the same field into one string. ABC  DEF the output after concatenation ABCDEF I am trying to use string-join function as follows but getting syntax error

Accepted Solutions (0)

Answers (1)

Answers (1)

Harish
Active Contributor
0 Kudos

Hi Kalyan,

It would be easier to implement in UDF (java code) in message mapping. I would suggest to use graphical mapping unless you have specific requirement to use XSLT.

refer the below discussion for Java udf

regards,

Harish

former_member183910
Participant
0 Kudos

Hi Kalyan,

try this mapping, just now I wrote:

<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="/">

  <xsl:for-each select="//name">

  <xsl:value-of select="."/>

  </xsl:for-each>

  </xsl:template>

</xsl:stylesheet>

Input file:

<a>

<name>Sandeep</name>

<name>Kalyan</name>

</a>

Output :

SandeepKalyan

Please let me know if you have any question.

Thanks

Sandeep Maurya.

former_member187447
Participant
0 Kudos

Hi Sandeep, Yes your code works, but I found I have a slightly different requirement     


<E1EDKT1 SEGMENT="1">

         <TDID>F01</TDID>

         <E1EDKT2 SEGMENT="1">

            <TDLINE>Combination of Header and Detail</TDLINE>

         </E1EDKT2>

         <E1EDKT2 SEGMENT="1">

            <TDLINE>Concatenated</TDLINE>

         </E1EDKT2>

</E1EDKT1>

I need to concatenate TDLINE occurrences based on TDID = F01, to make the output as


<Output>combination of Header and Detail concatenated</Output>

So I am trying with the following code which is not quite concatenating      


<xsl:for-each select="E1EDKT1">

    <xsl:choose>

     <xsl:when test="normalize-space(TDID) = 'F01'">

      <xsl:for-each select="E1EDKT2/TDLINE">

  <Output>

  

         <xsl:value-of select="." />

                       

    </Output>

  </xsl:for-each>

    </xsl:when>

   </xsl:choose>

</xsl:for-each>

former_member187447
Participant
0 Kudos

Hi Sandeep, I think I got it with a slight modification, Thank You.


<xsl:for-each select="E1EDKT1">

  <xsl:choose>

  <xsl:when test="normalize-space(TDID) = 'F01'">

  <Reference>

  <xsl:for-each select="E1EDKT2/TDLINE">

  <xsl:value-of select="."/>

  </xsl:for-each>

  </Reference>

  </xsl:when>

  </xsl:choose>

  </xsl:for-each>

former_member183910
Participant
0 Kudos

No Problem.