sap:function
Use
The statement sap:function allows you to define new XPath functions in XSLT programs.
Syntax
<sap:function name="prefix:fName"> <sap:argument name = "arg1"/> <sap:argument name = "arg2"/> ... <sap:result define = " <!-- function definition --> "/> </sap:function>
Description
All function arguments are declared using the sub-statement sap:argument. These are specified solely by their names.
The result of the function is defined as an XPath expression for the attribute define within the sub-statement sap:result. The function body can contain calls of functions that are already defined.
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 <= 0, 0, sapxsl:if($n=1, 1, $n*p:fact($n-1)))"/> </sap:function>