|
Home >Online Product Documentation >Table of Contents >Function Blocks Function BlocksStylus Studio supports standard functions defined by the W3C and any user-defined functions you might have created. This section describes how to work with function blocks in Stylus Studio and covers the following topics: See Using Web Services in XQuery to learn about the wscall function. Standard Function Block TypesStylus Studio provides graphic support for the following types of XQuery functions:
l anyURI
l Accessor
l Aggregate
l Boolean
l Context
l DataDirect XQuery
l Date/time, duration
l Error
l Node
l Numeric values
l QName
l Sequence
l Sequence generator
l Special constructor
l String
l Trace
If a standard function does not provide the functionality you need, create a user-defined function. See User-Defined Functions. Creating a Function BlockThe procedure for creating standard and user-defined function blocks varies slightly:
To create a standard function block:
1. Right-click on the mapper canvas.
2. Select New > Function Block from the shortcut menu. Available functions are displayed in submenu categories.
To create a user-defined function block:
1. Right-click on the mapper canvas.
2. Select New > User Functions from the shortcut menu.
Any user-defined functions defined in the XQuery source are displayed in a sublist.
See User-Defined Functions to learn more about creating user-defined functions in Stylus Studio.
Parts of a Function BlockFunction blocks are drawn as a purple block with an italic "f" at its center, and connectors, called ports, placed along the block's border. Input ports (none or more based on the function), the Flow port at the top, and the Return port on the right: Input portsInput ports are on the left side of the function block. The number and definition of input ports varies from function to function. To specify a value for an input port, drag a source document element or attribute to the port and release it. Flow portFlow ports, on the top of function blocks, are the same for FLWOR, function, and IF blocks. See Flow port. Return portThe Return port is on the right side of the function block. You use the Return port to map the function result directly to a target structure element or attribute, or to a FLWOR, IF, condition, or another function block. User-Defined FunctionsYou can declare your own functions in XQuery. Such functions are referred to as user-defined functions. For more information, see User-Defined Functions. concat Function BlocksThere are three types of concatenation (concat) functions for strings:
l concat() as string allows you to specify a literal value that you might wish to concatenate to some other value in your XQuery.
l concat($op1 as string?) as string allows you to specify a variable that you might wish to concatenate to some other value.
l concat($op1 as string?, $op2 as string?, ...) as string allows you to concatenate two or more variables.
Note that only the first two input ports are associated with variables ($op1 as string? and $op2 as string?). When you map a value to the third input port (...), Stylus Studio automatically adds a fourth input port to allow you concatenate a fourth value. This behavior is repeated for each additional string you define.
|