cancel
Showing results for 
Search instead for 
Did you mean: 

Value Mapping using XSLT mapping

former_member214909
Participant
0 Kudos

Hello All,

We have change requirement of storing some xsl Key-Value in SAP PI and on run time existing XSLT mapping need to look that values and in target structure map the value as per source key value.

For this requirement i am going with value mapping that will call from  XSLT mapping and created a test scenario before actual changes in XSLT mapping

I have created table in ID.


But unfortunately  i am getting below error :


Transformer Configuration Exception occurred when loading XSLT Test_Mapping.xsl; details: Could not load stylesheet.com.sap.engine.lib.xsl.xpath.XPathException: Prefix not mapped: ValueMap -> java.lang.Exception: XMLParser: Prefix 'ValueMap' is not mapped to a namespace


Below is my XSLT mapping code :


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

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="urn:kesko.fi.XSLTTest" xmlns:ns1="urn:kesko.fi.XSLTTest">

<xsl:template match="/">

  <xsl:param name="Dept_ID">

  <xsl:value-of select="ns0:MT_EmpDet_S/ID"/>

  </xsl:param>

  <xsl:param name="inputparam"/>

  <ns1:MT_EDet_R>

  <Name>

   <xsl:value-of select="ns0:MT_EmpDet_S/Name"/>

  </Name>

  <Department>

   <xsl:if test="function-available('ValueMap:getValueMapping')">

     <xsl:value-of select="ValueMap:getValueMapping('http://sap.com/XI/xi', 'http://sap.com/XI/xi', 'S','S1', 'T', 'T1', $Dept_ID, $inputparam,'TRUE')"/>

   </xsl:if>

  </Department>

  <PersonalInfo>

    <xsl:value-of select="concat(ns0:MT_EmpDet_S/Add, ns0:MT_EmpDet_S/SAL)"/>

  </PersonalInfo>

  </ns1:MT_EDet_R>

  </xsl:template>

</xsl:stylesheet>

Thanks,

Anant

Accepted Solutions (1)

Accepted Solutions (1)

iaki_vila
Active Contributor
0 Kudos

Hi Anat,

You need to define the namespace ValueMap

Regards.

former_member214909
Participant
0 Kudos

Hello,

Thanks for reply but can you please explain in detail.

Anant

iaki_vila
Active Contributor
0 Kudos

Hi Anant,

Check the point 5 in this document

ValueMap is a namespace and you need to give the correspondent URL value, like you give with xsl in xmlns:xsl="http://www.w3.org/1999/XSL/Transform".

Regards.

former_member214909
Participant
0 Kudos

Thanks again.

But after adding the namespace  I am still getting error.

Can you please extend your help so that i can proceed further.

Please check below code that i tried to execute :

1st :

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

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ValueMap="com.sap.aii.mapping.value.api.XIVMService"

xmlns:ns0="urn:kesko.fi.XSLTTest" xmlns:ns1="urn:kesko.fi.XSLTTest">

<xsl:template match="/">

  <xsl:param name="Dept_ID">

  <xsl:value-of select="ns0:MT_EmpDet_S/ID"/>

  </xsl:param>

  <xsl:param name="inputparam"/>

  <ns1:MT_EDet_R>

  <Name>

   <xsl:value-of select="ns0:MT_EmpDet_S/Name"/>

  </Name>

  <Department>

   <xsl:if test="function-available('ValueMap:getValueMapping')">

     <xsl:value-of select="ValueMap:getValueMapping('http://sap.com/XI/xi', 'http://sap.com/XI/xi', 'S','S1', 'T', 'T1', $Dept_ID, $inputparam,'TRUE')"/>

   </xsl:if>

  </Department>

  <PersonalInfo>

    <xsl:value-of select="concat(ns0:MT_EmpDet_S/Add, ns0:MT_EmpDet_S/SAL)"/>

  </PersonalInfo>

  </ns1:MT_EDet_R>

  </xsl:template>

</xsl:stylesheet>

2nd :

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

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ValueMap="com.sap.aii.mapping.value.api.XIVMService"

xmlns:ns0="urn:kesko.fi.XSLTTest" xmlns:ns1="urn:kesko.fi.XSLTTest">

<xsl:template match="/">

  <xsl:param name="Dept_ID">

  <xsl:value-of select="ns0:MT_EmpDet_S/ID"/>

  </xsl:param>

  <xsl:param name="inputparam"/>

  <ns1:MT_EDet_R>

  <Name>

   <xsl:value-of select="ns0:MT_EmpDet_S/Name"/>

  </Name>

  <Department>

     <xsl:value-of select="ValueMap:executeMapping('S','S1',$Dept_ID,'T','T1')"/>

  </Department>

  <PersonalInfo>

    <xsl:value-of select="concat(ns0:MT_EmpDet_S/Add, ns0:MT_EmpDet_S/SAL)"/>

  </PersonalInfo>

  </ns1:MT_EDet_R>

  </xsl:template>

</xsl:stylesheet>

for above both the cases messages are failing in MONI.

Thanks in advance.

Anant

former_member214909
Participant
0 Kudos

Please check the below error that i am  getting in MONI

<SAP:Stack>TransformerException occurred during XSLT mapping Test_Mapping (urn:kesko.fi.XSLTTest, 0dd1b1b0-7bf0-11e2-8620-f56e9d90200d, -1)</SAP:Stack>

Former Member
0 Kudos

Hello,

I tried testing ur XSLT and it seems that it's working fine for the below set of input payload.

For testing purpose, open any OM -> select ur XSLT mapping program -> go to test tab -> open source text view -> paste below input message and then test.

Note - change ID element value as per ur Value mapping which u have maintained in ID.

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

<MT_EmpDet_S>

  <Name>Amit</Name>

  <ID>123</ID>

  <Add>12</Add>

  <SAL>10000</SAL>

</MT_EmpDet_S>


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

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ValueMap="com.sap.aii.mapping.value.api.XIVMService">

<xsl:template match="/">

  <xsl:param name="Dept_ID">

  <xsl:value-of select="MT_EmpDet_S/ID"/>

  </xsl:param>

  <xsl:param name="inputparam"/>

  <MT_EDet_R>

  <Name>

   <xsl:value-of select="MT_EmpDet_S/Name"/>

  </Name>

<Department>

     <xsl:value-of select="ValueMap:executeMapping('S','S1',$Dept_ID,'T','T1')"/>

  </Department>

   <PersonalInfo>

    <xsl:value-of select="concat(MT_EmpDet_S/Add, MT_EmpDet_S/SAL)"/>

  </PersonalInfo>

  </MT_EDet_R>

  </xsl:template>

</xsl:stylesheet>

Thanks

Amit Srivastava

Former Member
0 Kudos

May be u can also select "use sap xml toolkit" option and then test?

former_member214909
Participant
0 Kudos

Hi Amit,

Thanks for reply.

I have already checked that in OM test tab but related node(Department) in target msg after mapping is coming blank as below

<ns1:MT_EDet_R xmlns:ns1="urn:kesko.fi.XSLTTest"><Name>Amit</Name><Department/><PersonalInfo>Pune1000000</PersonalInfo></ns1:MT_EDet_R>

Also on runtime please check the related field in msg after mapping is coming blank in MONI:

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

- <ns1:MT_EDet_R xmlns:ns1="urn:kesko.fi.XSLTTest">

<Name>Amit</Name>

<Department />

<PersonalInfo>Pune1000000</PersonalInfo>

</ns1:MT_EDet_R>

Regards,

Anant.

Former Member
0 Kudos

Hello,

So it clearly means ur VM is not getting executed properly.

Paste ur VM screenshot?

Thanks

Amit Srivastava

former_member214909
Participant
0 Kudos

Hi Amit,

Thanks for all you help.

As per your suggestion I have used the below code and test it using "sap xml toolkit" option.

My scenario is working as expected and

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

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ValueMap="com.sap.aii.mapping.value.api.XIVMService"

xmlns:ns0="urn:kesko.fi.XSLTTest" xmlns:ns1="urn:kesko.fi.XSLTTest">

<xsl:template match="/">

<xsl:param name="Dept_ID">

<xsl:value-of select="ns0:MT_EmpDet_S/ID"/>

</xsl:param>

<xsl:param name="inputparam"/>

  <ns1:MT_EDet_R>

  <Name>

    <xsl:value-of select="ns0:MT_EmpDet_S/Name"/>

  </Name>

  <Department>

      <xsl:value-of select="ValueMap:executeMapping('S','S1',$Dept_ID,'T','T1')"/>

  </Department>

  <PersonalInfo>

     <xsl:value-of select="concat(ns0:MT_EmpDet_S/Add, ns0:MT_EmpDet_S/SAL)"/>

  </PersonalInfo>

  </ns1:MT_EDet_R>

</xsl:template>

</xsl:stylesheet>

Value mapping :

Result :

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Anant,

Have a look at below link