Skip to Content

Mapping between XML

Hi all,

I would like to use a tool to make a mapping between two XML files

(this tool has to be accessible from SAP Basis system R/3 - ABAP)

The structure of the first one could change (Client structure)

The second xml file is the target one, his structure is known

The idea is to map element by element or attributes by attributes and

if needed to indicate which conversion's function to use

very simple example :

xml source:

<CLIENT:doc>

  <CLIENT:title>TITRE</CLIENT:title>

  <CLIENT:description>DESCRIPTION</CLIENT:description>

  <CLIENT:price>12.5</CLIENT:price>

</CLIENT:doc>

and with this wonderfull mapping tool the result could be depending on rules set :

<INTER:mydoc>

  <INTER:my_title>TITRE<INTER:my_title>

  <INTER:desc>DESCRIPTION<INTER:desc>

  <INTER:full_price>12 , 50 ?</INTER:full_price>

</INTER:mydoc>

do you know kind of similar tool ?

thanks for your answer

best regards,

Emmanuel.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Oct 15, 2003 at 06:48 PM

    Hi Emmanuel,

    This sounds like a job for XSLT.

    The xml source:  (I added additional info to make it valid.)

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

    http://mydomain.com/test/client">

      <CLIENT:title>TITRE</CLIENT:title>

      <CLIENT:description>DESCRIPTION</CLIENT:description>

      <CLIENT:price>12.5</CLIENT:price>

    </CLIENT:doc>

    The XSL program/template:

    <?xml version="1.0" ?>

    http://www.w3.org/1999/XSL/Transform"

      xmlns:CLIENT="http://mydomain.com/test/client">

      <xsl:template match="CLIENT:*">

        http://mydomain.com/test/inter">

          <INTER:my_title>

            <xsl:value-of select="//CLIENT:title"/>

          </INTER:my_title>

          <INTER:desc>

            <xsl:value-of select="//CLIENT:description"/>

          </INTER:desc>

          <INTER:full_price>

            <xsl:value-of select="//CLIENT:price"/>

          </INTER:full_price>

        </INTER:mydoc>

      </xsl:template>

    </xsl:stylesheet>

    The result XML:

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

    http://mydomain.com/test/inter">

      <INTER:my_title>TITRE</INTER:my_title>

      <INTER:desc>DESCRIPTION</INTER:desc>

      <INTER:full_price>12.5</INTER:full_price>

    </INTER:mydoc>

    Please note that this is only an example of 1 way to do it in XSL.

    Please reference XSLT manuals for additional features.

    Ciao,

    Bill

    Add comment
    10|10000 characters needed characters exceeded

    • Hello Bill,

      ok, thanks for your example 😊

      in fact it is one of possible solution

      But this solution is not easy for a client to change or to add an element

      Also, as I wrote from my first post, I need some conversion (12.5 -> 12,50 ?)

      or I need to call some function modules to add for example some runtime data or new data

      I would like in fact to find a SAP tool to do this mapping user friendly.

      I know already XSLT program but I search another solution to do a mapping

      between 2 xml using a kind of UI or anything else

      Regards,

      Emmanuel