cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping using Context handling

Former Member
0 Kudos

Hi All,

Kindly help me with below mapping requirement. I have used context handling in various ways but not able to map values correctly when there are multiple values.

Also note that there can be multiple tables also.

Structure

Input data:

Output Data:

Note: Value1 and Value2 corresponds to value of Col1 and Col2 and they will always be in respective order.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Thank you all for your inputs. I have created a java mapping to handle this scenario using stax parser.

Muniyappan
Active Contributor
0 Kudos

Hi Aman,

if possible can you share input and output xml?

it will be helpful to get your requirement.

Regards,

Muniyappan.

former_member201264
Active Contributor
0 Kudos

Hi Amanjot,

please do the mapping as below:

Regards,

Sreeni.

Former Member
0 Kudos

Hi Sreeni,

Thanks for replying.

The column Name field in header tag is 0..unbounded. The number of columns will vary every time and so is value in accordance to it. Also table tag is 1..unbounded.

I think it was not clear by what i mentioned in the question.

I don't think the above mapping will work for my requirement.

Former Member
0 Kudos

Hello,

Use XSLT mapping..dynamically create element names (col1, col2...) by reading the column field value and then assign value to these elements.

Thanks

Amit Srivastava

Former Member
0 Kudos

Adjust xslt as per ur requirement:

<?xml version="1.0" encoding="UTF-8"?>

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

   <xsl:template match="/">

      <MT_Target>

         <xsl:for-each select="/ns0:mt/table/Data">

            <table>

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

                  <xsl:variable name="counter">

                     <xsl:value-of select="position()"/>

                  </xsl:variable>

                  <xsl:variable name="element_name">

                     <xsl:call-template name="element">

                        <xsl:with-param name="i" select="$counter"/>

                     </xsl:call-template>

                  </xsl:variable>

                  <xsl:element name="{$element_name}">

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

                  </xsl:element>

               </xsl:for-each>

            </table>

         </xsl:for-each>

      </MT_Target>

   </xsl:template>

   <xsl:template name="element">

      <xsl:param name="i"/>

      <xsl:value-of select="/ns0:mt/table/Header/Column[$i]"/>

   </xsl:template>

</xsl:stylesheet>

Output:

Thanks

Amit Srivastava