cancel
Showing results for 
Search instead for 
Did you mean: 

process external functions within xsl maps

Former Member
0 Kudos

Hi,

i am working with xslt maps, and i have now the problem to generate the current date/time.

I found some postings with the solution to implement some new java classes.

Does somebody know, how to use the registerd java libs within xslt maps ?

- publish the xslns

- define the xsl:script

- use the class

Thanks

Bernd

Accepted Solutions (0)

Answers (2)

Answers (2)

sunilchandra007
Active Contributor
0 Kudos

Hi,

You can refer the following link:-

XSLT Mapping with Java Enhancement

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

Regards,

Chandra

Former Member
0 Kudos

Hi Chandra,

many thanks

Regards Mario

Former Member
0 Kudos

Mario:

this solution works in XI Maping, because it supports Sun's Java classes calls. In XMLSPY probably this isn't supported (I believe XSL engine here is not able to call Sun's Java)

Sunil:

Thanks for link, but this shows again just creating own classes and importing them into the archive. My post tried to show how to avoid it, when just standard Java's functionality necessary is.

Nice day Rasto

Former Member
0 Kudos

Hi Bernd,

Invoking a Java class is simple in XSL mapping,

1) Have the class files in a Jar,

2) give a namespace in your mapping for the appropriate CLASS (xmlns:somename="com.abc.xyz.getDate")

2a) you can call the appropriate method in a variable (<xsl:variable name="varCurrentDate" select="somename:getDate()"/>)

3) upload the jar file in the imported archive in IR (as like other XSL zip files)

For testing, if you use any XSL map editors, you can set the necessary paths/ classpaths to execute the map.

Hope this helps to fix your issue

Regards

Vishnu

Former Member
0 Kudos

Hi Vishnu,

thanks for the note. I tried a simple sample :

xmlns:mystring="com.inqmy.lib.xml.util.StringUtils"

<xsl:value-of select="mystring:isWhitespace(' ')/>

Success !

My question is now :

How can i find the function for my problem/issue to process ?

I need the current date. In which standard sap xi jar file is this class i need ? Is there a documentation available which functions i can use ?

I take also a look in the SLD / Class Browser. But i can't get the information i need.

Thanks

Bernd

Former Member
0 Kudos

I do not think there is a standard SAP class file that offers you that functionality. You have to write your own class file with a static method getDate() that could have one line of code instantiating java.util.Date and returning the string value. Package this class in a jar file and import it into the integration repository.

Regards,

Suresh.

Former Member
0 Kudos

Hi Bernd,

good that u got succeeded,

we normally create our own functions. Also I dont think there is any such jars provided by SAP.

Good luck

Regards

Vishnu

Former Member
0 Kudos

Hi Suresh,

can i use the libs from http://exslt.org/dates-and-times ?

If yes, please tell me, how to import or publish these standard libs into SAP XI integration repository.

Many Thanks

Bernd

Former Member
0 Kudos

Hi Bernd,

exslt libs implement custom functions using jscript. I am not sure if the XSLT processor in XI supports jscript. I have not tried it myself. But I could guess that it may not be supported.

I would recommend writing a simple java class with one static method that would return you the date in the format you want. The class could be like this:

public class MyDateFormatter{
  public static String getDateString() {
    return new java.util.Date().toString();
  }
}

You could jar this class up and import this into IR and invoke it in your stylesheet.

Regards,

Suresh

Former Member
0 Kudos

Hi XSLT supports jscript as well, but XI has restrictions that it could support particular versions of parsers, and limitations on XSLT capabilities.

Former Member
0 Kudos

Hi guys,

you don't need to write your own funktionality, when Sun Java has already implemented it.

Instead of writing your class and importing it to the archives, just use standard classes of Java.

Example of using and formatting current date in XSL mapping:

xmlns:date="java:java.util.Date"

xmlns:formatter="java:java.text.SimpleDateFormat">

<xsl:variable name="v_dNow" select="date:new()"/>

<xsl:variable name="v_formatter" select="formatter:new('yyyyMMdd')"/>

<xsl:variable name="v_dateToday" select="formatter:format($v_formatter, $v_dNow)"/>

This works in our XI xslt mapping

Regards Rasto

Former Member
0 Kudos

Hi Rasto,

very good.

Could you please send the whole xslt.

The following does not work (in XMLSPY):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:date="java:java.util.Date" xmlns:formatter="java:java.text.SimpleDateFormat">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:template match="ROOT">
	<xsl:variable name="v_dNow" select="date:new()"/>
	<xsl:value-of select="$v_dNow"/>
	<!-- <xsl:variable name="v_formatter" select="formatter:new('yyyyMMdd')"/> -->
	<!-- <xsl:variable name="v_dateToday" select="formatter:format($v_formatter, $v_dNow)"/> -->
	<!-- <xsl:value-of select="$v_dateToday"/> -->
	</xsl:template>
</xsl:stylesheet>

Thanks Regards

Mario

Former Member
0 Kudos

Hi,

I am also trying same kind of activity but i am like to read the KM property so i like to create Java Class to do the action.

I am portal developer, so i am used to create Abstract portal component, JSP Dyn Page and services. But i am not aware to create the java class and bring that in to portal for use it.

Can you please help to sort out this issue.

Regards,

Kathiresan R