Creating a Library Module

An XQuery module consists of:

l The module namespace definition
l One or more function declarations for user-defined functions

Consider the following example of a simple XQuery library module that contains two user-defined functions - total-price and titleQuantity:

You create an XQuery library module by typing the module definition in the XQuery editor. If you copy/paste user-defined functions from other XQuery, make sure to change the namespace prefix for each user-defined function as described in the following section, About Namespaces.

About Namespaces

An XQuery library module requires a namespace definition. You can specify the namespace using

l A symbolic name, like the one shown in the previous example
l A URI, such as "http://example.com/xquery/library/book"

The prefix you assign to the namespace must be used with any user-defined functions you declare in the XQuery library module. For example, if you create a user-defined function using the Stylus Studio refactoring feature, you must replace the default namespace that was created with the user-defined function (local:) with the namespace associated with the XQuery library module (ns:, in the previous example).

 
Free Stylus Studio XML Training:
W3C Member