cancel
Showing results for 
Search instead for 
Did you mean: 

Issue calling Java Standard Class java.lang.StringBuffer in XSLT Mapping

Former Member
0 Kudos

Hi Friends,

I have a simple

XSLT mapping in which I have declared "java.lang.StringBuffer" class and used a method like append in it. This mapping is present in PI 7.31 box.

The XSLT code is something like this:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sb="java:java.lang.StringBuffer">

<Record>
  <Name>
   <xsl:variable name="concatname" select="sb:append('A')"/>
   <xsl:variable name="concatname" select="sb:append('B')"/>
   <xsl:value-of select="$concatname"/>
  </Name>
</Record>
</xsl:stylesheet>

It is throwing an error as below:

  • javax.xml.transform.TransformerException: com.sap.engine.lib.xsl.xslt.XSLException: -> com.sap.engine.lib.xsl.xpath.XPathException: Illegal number of arguments or types of arguments in a call of function 'sb:append'.

Could any of you advise if this is the right

way of calling the class/method in my XSLT code.

Thank you.

Regards,

Subbalaxmi Musunuri

Accepted Solutions (0)

Answers (3)

Answers (3)

iaki_vila
Active Contributor
0 Kudos

Hi Subbalaxmi,

In sap.help document talks about static method, the java method to be called. May be,  you should to wrap that function in a new one being static. Check the example here (page 12) http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f03df013-289f-2e10-acb9-d1fcf782a...

Regards.

Former Member
0 Kudos

Hi,

Just one more point to add.

This same code is working in PI 7.0 by directly calling the standard java class in XSLT.

This issue is occuring only PI 7.31.

Former Member
0 Kudos

Hello,

Just a thought - go to OM and tick " SAP XML Toolkit" checkbox and then check?

Thanks

Amit Srivastava

Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Amit,

I know it's a bit late and I hope you have fixed this issue by now.

Just for history purposes: have you checked the your JDK version. I know there is a problem with StringBuffer append method. Check the NWDS JDK version and the PI JRE version.

It looks like StringBuffer from Java 1.4 spec will work correctly, but you could be running it against an older JRE (1.3).

Check under Window -> Preferences -> Java -> Compiler -> "Compiler And Classfiles" -> "Compiler compliance level" if you have the same JRE version as you server's.

StringBuffer should be replaced with StringBuilder on newer JRE whenever possible.

BR,

Ivan

Former Member
0 Kudos

Hello,

Check this blog which will explain how to call java functions inside XSLT

Thanks

Amit Srivastava

Former Member
0 Kudos

Hi

Change this line


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sb="java:java.lang.StringBuffer">


to


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sb="java.lang.StringBuffer">

Former Member
0 Kudos

Hi Indrajit,

Tried, as you told. But still the same issue.