cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to call Java Map in XSLT map

Former Member
0 Likes
700

Hello,

Can anyone tell me how to call Java Map in XSLT map.

Thanks and Regards

Hemant

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Likes

Answered

Shabarish_Nair
Active Contributor
0 Likes

make sure once you code the java, you have it imported after compilation under the imported archive.

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

Former Member
0 Likes

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

For some more reading: http://help.sap.com/saphelp_nwpi71/helpdata/en/55/7ef3003fc411d6b1f700508b5d5211/content.htm

Edited by: abhishek salvi on May 27, 2009 11:57 AM

Former Member
0 Likes

Thanks Abhishek,

This blog is very helpful "/people/pooja.pandey/blog/2005/06/27/xslt-mapping-with-java-enhancement-for-beginners

But in this blog here we are passing a static value as input parameter.

But Can you tell how can we pass the whole payload as an Input parameter instead of static value.

Thanks and Regards

Hemant

Shabarish_Nair
Active Contributor
0 Likes

for that first get the whole payload into a field using this - https://www.sdn.sap.com/irj/scn/wiki?path=/display/xi/wholePayloadtoaXML+field

and then in the next mapping say mapping B use the XSLT method on that field.

call the mapping in sequence in your interface mapping i.e mapping A and then Mapping B

Former Member
0 Likes

Hello, Vijay,

Can you help in understanding how can we pass whole payload in the parameter in XSLT map.....

for eg

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

<xsl:stylesheet version="2.0"

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

xmlns:javamap="java:DATEandTIME.Date_Time">

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:param name="inputparam" />

<xsl:template match="/">

<MT_TARGET>

<date>

<xsl:if test="function-available('javamap:getDateValue')">

<xsl:value-of select="javamap:getDateValue($inputparam)"/> </xsl:if>

</date>

<time>

<xsl:if test="function-available('javamap:getTimeValue')">

<xsl:value-of select="javamap:getTimeValue($inputparam)"/> <xsl:value-of select="$test"/>

</xsl:if>

</time>

<project>

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

</project>

</MT_TARGET>

</xsl:template>

</xsl:stylesheet>

here we are passing static value in parameter.....

Java code is:

private static AbstractTrace trace = null;

public static String getDateValue(Map inputparam)

{

trace = (AbstractTrace)inputparam.get(

StreamTransformationConstants.MAPPING_TRACE );

Date now1 = new Date();

SimpleDateFormat formatter = new SimpleDateFormat ("yyyyMMd");

String dateString = formatter.format(now1);

return dateString;

}

public static String getTimeValue(Map inputparam)

{

trace = (AbstractTrace)inputparam.get(

StreamTransformationConstants.MAPPING_TRACE );

Date now1 = new Date();

SimpleDateFormat formatter = new SimpleDateFormat ("hhmmss");

String dateString1 = formatter.format(now1);

return dateString1;

}

}

I want to pass whole payload so how can i pass it.

Former Member
0 Likes
Can you help in understanding how can we pass whole payload in the parameter in XSLT map.....

define a variable/parameter in your XSLT mapping....now it should be not a normal define like:

<xsl:param name="inputparam"/>

Your parameter should enclose the CDATA logic within its definition like

<xsl:param name="inputparam" select="expression">
CDATA
</xsl:param>

This will push the required node into the inputparam as string.....

so you have only one XSLT mapping and one referenced JAVA mapping.....

Check this logic....for more help on xsl:param refer: http://www.w3schools.com/xsl/el_param.asp

Once you are successful in getting the string into inputparam you can pass it here:

<xsl:value-of select="javamap:getDateValue($inputparam)"/>

Regards,

Abhishek.

Edited by: abhishek salvi on May 27, 2009 1:06 PM