cancel
Showing results for 
Search instead for 
Did you mean: 

Multi Mapping using XSLT

0 Kudos

Hi Gurus,

My requirement is to do Multimapping using XSLT only. All the configuration is working fine with Graphical mapping.

Input Payload :

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

<ns0:MT_BO_S xmlns:ns0="namespace0">

  <Source>

      <Header>

        <Recipent>asd</Recipent>

      </Header>

      <Item>

        <Value>1</Value>

      </Item>

      <Item>

        <Value>2</Value>

      </Item>

       </Source>

</ns0:MT_BO_S>

I need to generate same number of files as the occurrence of ‘item’ field in source.  For ex, 3 items in the above payload, so 3 files will get generated.

Steps I did for Graphical:

Changed the occurrence of Target MT in MM to 0..Unbounded

Changed the occurrence of Target SI in OM to 0..Unbounded

Got the perfect output and getting 2 files generated E2E.

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

<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">

    <ns0:Message1>

          <ns1:MT_BO_R xmlns:ns1="namespace">

                <Target>

                    <Header>

                          <Recipent>asd</Recipent>

                    </Header>

                    <Item>

                          <Value>1</Value>

                    </Item>

                </Target>

          </ns1:MT_BO_R>

          <ns1:MT_BO_R xmlns:ns1="namespace">

                <Target>

                    <Header>

                          <Recipent>asd</Recipent>

                    </Header>

                    <Item>

                          <Value>2</Value>

                    </Item>

                </Target>

          </ns1:MT_BO_R>

    </ns0:Message1>

</ns0:Messages>

For Xslt, I did

Changed the occurrence of Target SI in OM to 0..Unbounded

Please help me with the mapping in XSLT, I want the same output as it is coming for Graphical.

Source :

<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_BO_S xmlns:ns0="namespace1">
  <Source>
     <Header>
        <Recipent>asd</Recipent>
     </Header>
     <Item>
        <Value>1</Value>
     </Item>
  </Source>
</ns0:MT_BO_S>

Target :
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_BO_R xmlns:ns0="namespace1">
  <Target>
     <Header>
        <Recipent></Recipent>
     </Header>
     <Item>
        <Value></Value>
     </Item>
  </Target>
</ns0:MT_BO_R>

Appreciate early reply.

Regards,

Prashanthi

Accepted Solutions (0)

Answers (1)

Answers (1)

ambrish_mishra
Active Contributor
0 Kudos
0 Kudos

Hi Ambrish,

Thanks for your reply.

I already seen these threads.

/people/aleksey.popov2/blog/2010/09/23/xslt-multi-mapping-example

Exact requirement is to generate the same output as coming in the graphical mapping output.

As far as I know, we need to add manually below structure in the xslt

<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">

    <ns0:Message1>

please correct me if I am wrong.

Regards,

Prashanthi

ambrish_mishra
Active Contributor
0 Kudos

yes thats correct.

0 Kudos

okay, so I wrote this xsl code

<?xml version='1.0' ?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge" xmlns:a="namespace">

     <xsl:template match="/">

           <ns0:Messages>

                <ns0:Message1>

                     <xsl:for-each select="a:MT_BO_S/Source/Item">

                           <a:MT_BO_R>

                                <Target>

                                     <Header>

                                           <Recipent>

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

                                           </Recipent>

                                     </Header>

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

                                           <Item>

                                                <Value>

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

                                                </Value>

                                           </Item>

                                     </xsl:for-each>

                                </Target>

                           </a:MT_BO_R>

                     </xsl:for-each>

                </ns0:Message1>

           </ns0:Messages>

     </xsl:template>

</xsl:stylesheet>

this is what I am getting in external editor from the above xsl.

<?xml version="1.0"?>

<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge" xmlns:a="namespace">

     <ns0:Message1>

           <a:MT_BO_R>

                <Target>

                     <Header>

                           <Recipent>asd</Recipent>

                     </Header>

                     <Item>

                           <Value>1</Value>

                     </Item>

                </Target>

           </a:MT_BO_R>

           <a:MT_BO_R>

                <Target>

                     <Header>

                           <Recipent>asd</Recipent>

                     </Header>

                     <Item>

                           <Value>2</Value>

                     </Item>

                </Target>

           </a:MT_BO_R>

     </ns0:Message1>

</ns0:Messages>

but when I am executing it in OM, only Message fields are coming.

I guess we need to include the namespace in the root node, as marked in the image. please help 🙂

ambrish_mishra
Active Contributor
0 Kudos

How about simply adding the namespace in the node in XSL like (

<a:MT_BO_R> to <a:MT_BO_R xmlns:ns0="namespace1">