Skip to Content

Overview

As mentioned in Part1,it is about references between mapping programs. Part 1 (References between Mapping Programs-Part1)  talks about how to trigger java class from message mapping and Java mapping.

Part2:covers last two topics, means how to trigger java class from xslt mapping and how to trigger xslt mapping from other xslt mapping.

                                                    Part2

3. XSLT mapping can use (cross reference) other java class of an archive.

4. XSLT mapping can use (cross reference) other xslt mapping with help of “import”.

Note:Same source message type and target message types are used as in the part1.

3. XSLT mapping can use (cross reference) other java class of an archive.

XSLT mapping can call a java method of other java class which is archived in the same software component.

In the given example xslt program calls “grade” method to find the grade of a students as providing their marks as input to the method.

Steps:

a) Create java class and import into XI (import archive).

b) Create xslt mapping program to trigger java method and import into xi(import archive)

<p>Xslt and Java class (archive) </p>

//Java class which can be called from xslt mapping program:

*

package prasad.map

public class XSLTTesting {

public static String grade(String a,String b,String c)

{

    int e = Integer.parseInt(a);

    int f = Integer.parseInt(b);

     int g = Integer.parseInt(c);

     float average = (efg)/3;

     if(average>=90)

      return “Grade A”;

      else if(average>=80)

      return “Grade B”;

      else if(average>=70)

      return “Grade C”;

      else if(average>=60)

      return “First Class”;

      else if(average>=50)

      return “Pass”;

       else

       return “fail”;

     }

}

<p>//XSLT Mapping:- </p>

<!Author@ Prasad Babu Nemalikanti>

<!Company@ Mahindra Satyam>

<!Date@12th Arpil 2011> <xsl:value-of select=”javamap:grade($Mathmatics,$Sceince,$Language)”/>

     * <!Calling Java method></p><p>                           </xsl:if> </p><p>                       </xsl:element> </p><p>                   </Marks> </p><p>                 </Rows> </p><p>             </xsl:for-each> </p><p>          </Students> </p><p>        </MT_StudentDetails> </p><p>      </xsl:template> </p><p>    </xsl:stylesheet> </p><p>Archiving of xslt and Java </p><p>!https://weblogs.sdn.sap.com/weblogs/images/47240/sat2_IA1.JPG|height=366|alt=|width=611|src=https://weblogs.sdn.sap.com/weblogs/images/47240/sat2_IA1.JPG!</p><p> </p><p>Operational Mapping </p><p>!https://weblogs.sdn.sap.com/weblogs/images/47240/sat2_om2.JPG|height=319|alt=|width=599|src=https://weblogs.sdn.sap.com/weblogs/images/47240/sat2_om2.JPG!</p><p> </p><p>Testing of operation mapping</p><p>!https://weblogs.sdn.sap.com/weblogs/images/47240/sat2_tm3.JPG|height=278|alt=|width=627|src=https://weblogs.sdn.sap.com/weblogs/images/47240/sat2_tm3.JPG!</p><p>h4. 4. XSLT mapping can use (cross reference) other xslt mapping with help of “import”.

</p><p>Description: It talks about how to call one xslt program into another xslt program. In this example there are two xslt mappings. </p><p>

Steps:

*</p><p>1)”xslt_to_xslt_called.xsl” which implements complete mapping and it is triggered by main xslt mapping. </p><p>2)” xslt_to_xslt_main.xsl” which just calls the first xsl program. </p><p>a) Create xslt mapping (xslt_to_xslt_called.xsl</strong>) which should be called from main xslt mapping and deploy it into xi (import archive). </p><p>b) Create main xslt mapping (xslt_to_xslt_main.xsl) to trigger other xslt and deploy into xi (import archive) </p><p> </strong></p><p>XSL Codes </p><p>

//XSL code which is called in main xsl mapping (xslt_to_xslt_called.xsl)

</strong></p><p><?xml version=”1.0″ encoding=”UTF-8″?> </p><p><!Date@14th Arpil 2011> </p><p><!Company@ Mahindra Satyam> </p><p><!Author@ Prasad Babu Nemalikanti> </p><p><xsl:stylesheet version=”2.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform“> </p><p>   <xsl:template match=”/”> </p><p>    <MT_StudentDetails> </p><p>      <Students> </p><p>        <xsl:for-each select=”MT_Students/Students/Records”> </p><p>          <Rows> </p><p>            <xsl:element name=”StudentID”> </p><p>              <xsl:value-of select=”StudentID”/> </p><p>            </xsl:element> </p><p>            <xsl:element name=”StudentName”> </p><p>            <xsl:value-of select=”concat(FirstName,LastName)”/> </p><p>            </xsl:element> </p><p>            <xsl:element name=”DOJ”> </p><p>            <xsl:value-of select=”DOJ”/> </p><p>            </xsl:element> </p><p>          </p><p>            <Marks> </p><p>             <xsl:variable name=”Mathmatics”> </p><p>            <xsl:value-of select=”Subjects/Maths”/> </p><p>            </xsl:variable> </p><p>            <xsl:element name=”Maths”> </p><p>            <xsl:value-of select=”Subjects/Maths”/> </p><p>            </xsl:element> </p><p>            <xsl:variable name=”Sceince”> </p><p>            <xsl:value-of select=”Subjects/Sceince”/> </p><p>            </xsl:variable> </p><p>            <xsl:element name=”Physics”> </p><p>           <xsl:value-of select=”Subjects/Sceince”/> </p><p>           </xsl:element> </p><p>           <xsl:variable name=”Language”> </p><p>           <xsl:value-of select=”Subjects/Language”/> </p><p>           </xsl:variable> </p><p>            <xsl:element name=”English”> </p><p>               <xsl:value-of select=”Subjects/Language”/> </p><p>              </xsl:element> </p><p>            <xsl:variable name=”Total”> </p><p>           <xsl:value-of select=”number($Mathmatics)number($Sceince)number  ($Language)”/> </p><p>              </xsl:variable> </p><p>             <xsl:if test=”$Total>=270″> </p><p>              <xsl:element name=”Grade”> </p><p>                 <xsl:value-of select=”&apos;GradeA&apos;”/> </p><p>               </xsl:element> </p><p>             </xsl:if> </p><p>             <xsl:if test=”($Total>=240)and($Total <270)”> </p><p>              <xsl:element name=”Grade”> </p><p>                  <xsl:value-of select=”&apos;GradeB&apos;”/> </p><p>              </xsl:element> </p><p>            </xsl:if> </p><p>            <xsl:if test=”($Total>=210)and($Total <240)”> </p><p>             <xsl:element name=”Grade”> </p><p>                <xsl:value-of select=”&apos;GradeC&apos;”/> </p><p>              </xsl:element> </p><p>            </xsl:if> </p><p>           <xsl:if test=”($Total>=180)and($Total <210)”> </p><p>             <xsl:element name=”Grade”> </p><p>                <xsl:value-of select=”&apos;FirstClass&apos;”/> </p><p>                 </xsl:element> </p><p>               </xsl:if> </p><p>               <xsl:if test=”($Total>=150)and($Total <180)”> </p><p>                 <xsl:element name=”Grade”> </p><p>                 <xsl:value-of select=”&apos;Pass&apos;”/> </p><p>                </xsl:element> </p><p>               </xsl:if> </p><p>               <xsl:if test=”($Total <150)”> </p><p>                <xsl:element name=”Grade”> </p><p>                 <xsl:value-of select=”&apos;Fail&apos;”/> </p><p>                    </xsl:element> </p><p>                 </xsl:if> </p><p>              </Marks> </p><p>            </Rows> </p><p>         </xsl:for-each> </p><p>    </Students> </p><p></MT_StudentDetails> </p><p></xsl:template> </p><p></xsl:stylesheet> </p><p> </p><p>

//XSL Main Mapping Program(xslt_to_xslt_main.xsl) which calls the above mentioned xsl

*

<!Author@ Prasad Babu Nemalikanti>

<!Company@ Mahindra Satyam>

<!Date@14th Arpil 2011</p><p>    <xsl:template match=”/”> </p><p>      <xsl:apply-imports/> </p><p>      </xsl:template> </p><p>     </xsl:stylesheet> </p><p>Import archive “xslt_to_xslt_called.xsl ” *

</p><p>Main xslt mapping(xslt_to_xslt_main.xsl) which calls “xslt_to_xslt_called.xsl” *

</p><p>Operational mapping*

* **Testing of Operational mapping </p><p>!https://weblogs.sdn.sap.com/weblogs/images/47240/sat2_xsl_tm4.JPG|height=263|alt=|width=531|src=https://weblogs.sdn.sap.com/weblogs/images/47240/sat2_xsl_tm4.JPG!</p><p>!https://weblogs.sdn.sap.com/weblogs/images/47240/sat2_xsl_tm5.JPG|height=286|alt=|width=591|src=https://weblogs.sdn.sap.com/weblogs/images/47240/sat2_xsl_tm5.JPG!</body>

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply