Creating a User-Defined Function

You can create a user-defined function by typing its definition in the XQuery Source tab, but it can be easier to have Stylus Studio create a user-defined function for you. You do this by selecting existing code and refactoring that code as a user-defined function. Any complete block of code can be used for refactoring. Examples include XML fragments and FLWOR expressions.

When you create a user-defined function using the refactoring feature, Stylus Studio

l Creates a function declaration for the newly created user-defined function
l Replaces the code you selected with a function call to the user-defined function
To create a user-defined function:
1. In the XQuery Source tab or the Text pane of the XQuery Mapper tab, select the fragment you want to use to create your user-defined function.
Consider the following example, which uses the createFullOrder.xquery that is part of the pipelines example project installed with Stylus Studio.
 
Free Stylus Studio XML Training: