ABAP - Keyword Documentation →  ABAP - Data Interfaces and Communication Interfaces →  ABAP and XML →  XML - Transformations →  XSL Transformations →  XSL - User-Defined Transformations →  XSL - Instructions →  XSL - SAP Instructions → 
Mail Feedback

XSL - New XPath Functions

New XPath functions can be defined in XSLT programs using the instruction sap:function.

<sap:function name="prefix:fName">
   <sap:argument    name = "arg1"/>
   <sap:argument    name = "arg2"/>
      ...
   <sap:result      define = "
                            <!-- function definition -->
                            "/>
</sap:function>

Hint

Multiple functions can be called with the same name, if they have different arguments.

Example

You can define a function for calculating the factorial as follows.

<sap:function name ="p:fact">
   <sap:argument      name ="n"/>
   <sap:result        define ="sapxsl:if($n &lt;= 0,
                                        0,
                                        sapxsl:if($n=1,
                                                  1,
                                                  $n*p:fact($n-1)))"/>
</sap:function>