cancel
Showing results for 
Search instead for 
Did you mean: 

errror::Illegal number of arguments or types of arguments in XSLT

0 Kudos

HI All,

In our scenario we are using XSLT mapping with java enhancement.Its working fine in Stylus studio but when the same is imported into XI its throwing the below mentioned error:

javax.xml.transform.TransformerException: com.sap.engine.lib.xml.util.NestedException: Illegal number of arguments or types of arguments in a call of function 'Trans:Convert'.

Our requirement is that we are summing up the Field "Grant_Amount" which occurs multiple times in the source structure.PFB the XSL and the source XML:

<

XSL:

===

<Sum>

<xsl:value-of select="Trans:Convert(//Grant_Amount)"/>

</Sum>

XML:

===

<Recordset>

<DETAILRECORD>

<Grant_Amount>$100.00</Grant_Amount>

</DETAILRECORD>

<DETAILRECORD>

<Grant_Amount>$200.00</Grant_Amount>

</DETAILRECORD>

</Recordset>

Java Code:

========

package com.company.group;

public class String2Number

{

public static String Convert(String[] a)

{

double sum=0;

String[] temp = new String[100];

for(int i=0;i<a.length;i++)

{

temp<i> = (a<i>).replaceAll("[,
$
\"]","");

{

sum=sum+Double.parseDouble(temp<i>);

}

}

return sum+"";

}

}

>

Please guide me into the right solution.

Thanks and Regards,

Karanam

Accepted Solutions (0)

Answers (1)

Answers (1)

GabrielSagaya
Active Contributor
0 Kudos

<xsl:transform version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns:sap="http://www.sap.com/sapxsl"

xmlns:p2="http://XXX.com">

<xsl:template match="/">

<p2:MT_STUD>

<Sum>

<xsl:value-of select="Trans:Convert(p2:MT_STUD_SORC/Recordset/DETAILRECORD/Grant_Amount)"/>

</Sum>

</p2:MT_STUD>

</xsl:template>

</xsl:transform>

0 Kudos

Thanq for your response,

But my stylesheet is as below

<

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

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="http://www.infosys.com/sap/xi/projects/sce/n1" xmlns:Trans="com.company.group.String2Number">

<xsl:template match="/">

<a:MT_TargetXSLJava>

<Record>

<Detailrecord>

<Sum>

<xsl:value-of select="Trans:Convert(//Grant_Amount)"/>

</Sum>

<Flag>

<xsl:value-of select="//DETAILRECORD/Grant_Amount"/>

</Flag>

</Detailrecord>

</Record>

</a:MT_TargetXSLJava>

</xsl:template>

</xsl:stylesheet>

>

GabrielSagaya
Active Contributor
0 Kudos

/people/pooja.pandey/blog/2005/06/27/xslt-mapping-with-java-enhancement-for-beginners

http://help.sap.com/saphelp_nw04/helpdata/en/55/7ef3003fc411d6b1f700508b5d5211/frameset.htm

<Flag>

<xsl:value-of select="//DETAILRECORD/Grant_Amount"/>

</Flag>

But there is no Flag element in target MT???