cancel
Showing results for 
Search instead for 
Did you mean: 

call java function from xslt mapping

Former Member
0 Kudos

hi experts,

i am using xslt mapping

in that my requirentment is to paas the value of each value to java function and print the returning value of java function.

my source xml is

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

<ns0:CRMTalismaCommonPropertyRequest xmlns:ns0="urn:testing.com">

   <Header>

      <Name>abc</Name>

      <Name>xyz</Name>

      <Name>pqr</Name>

   </Header>

</ns0:CRMTalismaCommonPropertyRequest>

i am using <xsl:for each> tag but it is printing the value abc xyz pqr

i need to pass this value to java function .

xslt code is..

<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:Number="java:Number" exclude-result-prefixes="Number">

    <xsl:template match="Header">

        <value>

            <xsl:for-each>

                <xsl:variable name="temp">

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

                </xsl:variable>

                <xsl:value-of select="Number:hashmap($temp))"/>

            </xsl:for-each>

        </value>

    </xsl:template>

</xsl:stylesheet>

help me regradnig this.

thanks and regards

anup banerjee

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member184681
Active Contributor
0 Kudos

Hi,

Find and example in SAP Help here: http://help.sap.com/saphelp_nw04/helpdata/en/55/7ef3003fc411d6b1f700508b5d5211/content.htm

It deals with input parameters for Java functions, namespaces configuration etc.

Also, you can find many useful links about calling Java function from XSLT in this thread:

Hope this helps,

Greg

Former Member
0 Kudos

Hi

thanks for your reply

calling the java function is not the problem .

i have to call the java function  in <xsl:foreach> tag  .

the problem is in <xsl:foreach > </xsl:foreach>  i have to call java function with every different value as import parameter.

thanks and regards

anup banerjee

former_member184681
Active Contributor
0 Kudos

Did you just try it? I believe calling the Java function for each value will be done automatically by the mapping engine, since you put this execution inside an <xsl:for-each> block - it should work as if you executed a function module inside a loop. Is your experience different here?

Regards,

Greg

Former Member
0 Kudos

hi

i have try it  . its not working .

as u say i automatically work in this case what shoud be value of parameter of java function.

how do i identify the value of <xsl:for each>. for pass it to java function.

thanks and regards,

anup banerjee

former_member184681
Active Contributor
0 Kudos

I reviewed your XSLT code and I believe I can see the problem now. Change the XSLT code as follows:

<xsl:for-each select="Name">
   <xsl:variable name="temp">
      <xsl:value-of select="."/>
   </xsl:variable>
   <xsl:value-of select="Number:hashmap($temp))"/>
</xsl:for-each>

Hope this helps,

Greg

Former Member
0 Kudos

thanks to all,

i have solved the issue.

thanks Greg i use the same code as you given, its working fine.

thanks and reagrds

Anup Banerjee