|'''Examples'''
|Invokes the declared functions and returns their values:<br/>
<syntaxhighlight pre lang="'xquery"'>
declare %private function local:one() { 12 };
declare %private function local:two() { 34 };
for $f in inspect:functions() return $f()
</syntaxhighlightpre>
Compiles all functions in {{Code|code.xqm}} and invokes the function named {{Code|run}}:
<syntaxhighlight pre lang="'xquery"'>
let $uri := 'code.xqm'
let $name := 'run'
where local-name-from-QName(function-name($f)) = $name
return $f()
</syntaxhighlightpre>
|- valign="top"
| '''Errors'''
|
* Returns the static base URI (same as {{Code|static-base-uri()}}):
<syntaxhighlight pre lang="'xquery"'>
inspect:static-context((), 'base-uri')
</syntaxhighlightpre>
* Returns a map with all namespaces that are statically known in the module of the specified function:
<syntaxhighlight pre lang="'xquery"'>
import module namespace data = 'data.xqm';
inspect:static-context(data:get#1, 'namespaces')
</syntaxhighlightpre>
|- valign="top"
| '''Errors'''
|'''Examples'''
|The query {{Code|inspect:function(count#1)}} yields:
<syntaxhighlight pre lang="xml">
<function name="count" uri="http://www.w3.org/2005/xpath-functions" external="false">
<argument type="item()" occurrence="*"/>
<return type="xs:integer"/>
</function>
</syntaxhighlightpre>
The function…
<syntaxhighlight pre lang="'xquery"'>
(:~
: This function simply returns the specified integer.
$number
};
</syntaxhighlightpre>
…is represented by {{Code|inspect:function(local:same#1)}} as…
<syntaxhighlight pre lang="xml">
<function name="local:same" uri="http://www.w3.org/2005/xquery-local-functions" external="false">
<argument type="xs:integer" name="number">number to return</argument>
<return type="xs:integer">specified number</return>
</function>
</syntaxhighlightpre>
|}
| '''Examples'''
|Evaluate all user-defined functions with zero arguments in the query context:<br/>
<syntaxhighlight pre lang="'xquery"'>
inspect:context()/function ! function-lookup(QName(@uri, @name), 0) ! .()
</syntaxhighlightpre>
Return the names of all private functions in the current context:
<syntaxhighlight pre lang="'xquery"'>
for $f in inspect:context()/function
where $f/annotation/@name = 'private'
return $f/@name/string()
</syntaxhighlightpre>
|}
This is the {{Code|sample.xqm}} library module:
<syntaxhighlight pre lang="'xquery"'>
(:~
: This module provides some sample functions to demonstrate
$number
};
</syntaxhighlightpre>
If {{Code|inspect:module('sample.xqm')}} is run, the following output will be generated:
<syntaxhighlight pre lang="xml">
<module prefix="samples" uri="http://basex.org/modules/samples">
<description>This module provides some sample functions to demonstrate
</function>
</module>
</syntaxhighlightpre>
The output looks as follows if {{Code|inspect:xqdoc('sample.xqm')}} is called:
<syntaxhighlight pre lang="xml">
<xqdoc:xqdoc xmlns:xqdoc="http://www.xqdoc.org/1.0">
<xqdoc:control>
</xqdoc:functions>
</xqdoc:xqdoc>
</syntaxhighlightpre>
=Errors=