|
Home >Online Product Documentation >Table of Contents >User-Defined Functions User-Defined FunctionsA user-defined function is an XQuery function that you define. Consider the following example, which illustrates the total-price user-defined function:
The total-price user-defined function takes an inventory element as its argument and returns a sum reflecting the dollar value of that inventory (quantity * price). Here is an example of how it might be used (the user-defined function is shown in italics):
When you create a user-defined function, Stylus Studio adds it to the New > User Functions shortcut menu available when you right-click the mapper canvas. This makes it easy to reuse a user-defined function on the Mapper tab once it has been defined in the XQuery source. See Building an XQuery Using the Mapper for more information. Another way to use user-defined functions is to include them in a library module. You can then import this library module into other XQuery instead of rewriting the user-defined function each time you need it. See Working with XQuery Library Modules |