This function takes a URI of an XQuery module and an XML entity and calls the module with the entity as a context. Depending on value of index parameter, either the result of the module is returned 'as is' or the sequence of results is returned.
Parameters can be passed to the module by specifying additional arguments to processXQuery(). The names of parameters should appear in argument list without the leading '$' sign. Unlike xquery_eval() function, parameter can not be ignored depending on the type of its value. If the same name appears more than once in the vector, the last name/value pair is used and all preceding pairs with this name are silently ignored. Obviously, names should be strings that are valid XPath variable names.
The XQuery standard does not offer a way of calling of a module from other XQuery expression. The reason is that there's no need for such calling if the code is designed properly. If an expression is re-used in various places then it should be turned into a function and placed into an XQuery library module; one should import the module and call the function instead of calling a non-library module. It is possible to use processXQuery() in XQuery expressions but it is much better to use library modules instead, and to use processXQuery() only for tricks in XPATH expressions.
For compatibility, the processXQuery() function can also be called as http://schemas.oracle.com/xpath/extension:processXQuery().
The type of return value depends on type of value returned by module.
Sample templates put the result of the call of module "mymodule.xq" for context node into the resulting document. This assumes that both the stylesheet and XQuery module "mymodule.xq" reside in the same directory so relative a URI "mymodule.xq" can be resolved using the URI of the stylesheet as base URI.
<xsl:template match="myelement"> <xsl:copy-of select="processXQuery('mymodule.xq')"/> </xsl:template>
This is equivalent with the following template:
<xsl:template match="myelement"> <xsl:copy-of select="processXQuery('mymodule.xq', current(), 1)"/> </xsl:template>