Changes

Jump to navigation Jump to search
3,109 bytes added ,  15:01, 16 January 2017
no edit summary
=Conventions=
All functions and errors in this module are assigned to the <code><nowiki>http://basex.org/modules/inspect</nowiki></code> namespace, which is statically bound to the {{Code|inspect}} prefix.<br/>
xqDoc document instances are assigned to the <code><nowiki>http://www.xqdoc.org/1.0</nowiki></code> namespace, which is statically bound to the {{Code|xqdoc}} prefix.
All errors are assigned to the <code><nowiki>http://basex.org/errors</nowiki></code> namespace, which is statically bound to the {{Code|bxerr}} prefix.
=Reflection=
|-
| '''Summary'''
|Returns function items for all user-defined functions (both public and private) that are known in the current query context. If a {{Code|$uri}} is specified, the addressed module will be compiled, and its functions will be added to the query context and returned to the user. A relative URI will be resolved against the static base URI of the query.
|-
|'''Examples'''
return $f()
</pre>
|}
 
==inspect:function-annotations==
 
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|inspect:function-annotations|$function as function(*)?|map(xs:QName, xs:anyAtomicType*)}}<br/>
|-
| '''Summary'''
|Returns the annotations of the specified {{Code|$function}} in a map.
|-
| '''Examples'''
|
* Returns an empty map:
<pre class="brush:xquery">
inspect:function-annotations(true#0)
</pre>
* Returns a map with a single key <code><nowiki>Q{http://www.w3.org/2012/xquery}private</nowiki></code> and an empty sequence as value:
<pre class="brush:xquery">
declare %private function local:f() { 'well hidden' };
inspect:function-annotations(local:f#0)
</pre>
|}
 
==inspect:static-context==
 
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|inspect:static-context|$function as function(*)?, $name as xs:string|item()*}}<br/>
|-
| '''Summary'''
|Returns a component of the [https://www.w3.org/TR/xquery-31/#dt-static-context static context] of a {{Code|$function}} with the specified {{Code|$name}}. If no function is supplied, the current static context is considered.<br/>The following components can be requested:
* {{Code|base-uri}}: Static base URI.
* {{Code|namespaces}}: Prefix/URI map with all statically known namespaces.
* {{Code|element-namespace}}: Default element/type namespace URI, or an empty sequence if it is absent.
* {{Code|function-namespace}}: Default function namespace URI, or an empty sequence if it is absent.
* {{Code|collation}}: URI of the default collation.
* {{Code|ordering}}: Ordering mode ({{Code|ordered}}/{{Code|unordered}})
* {{Code|construction}}: Construction mode ({{Code|preserve}}/{{Code|strip}})
* {{Code|default-order-empty}}: Default order for empty sequences ({{Code|greatest}}/{{Code|least}})
* {{Code|boundary-space}}: Boundary-space policy ({{Code|preserve}}/{{Code|strip}})
* {{Code|copy-namespaces}}: Copy-namespaces mode ({{Code|inherit}}/{{Code|no-inherit}}, {{Code|preserve}}/{{Code|no-preserve}})
* {{Code|decimal-formats}}: Nested map with all statically known decimal formats
|-
| '''Examples'''
|
* Returns the static base URI (same as {{Code|static-base-uri()}}):
<pre class="brush:xquery">
inspect:static-context((), 'base-uri')
</pre>
* Returns a map with all namespaces that are statically known in the module of the specified function:
<pre class="brush:xquery">
import module namespace data = 'data.xqm';
inspect:static-context(data:get#1, 'namespaces')
</pre>
|-
| '''Errors'''
|{{Error|unknown|#Errors}} The specified component does not exist.
|}
==inspect:function==
 
{| width='100%'
|-
|The query {{Code|inspect:function(count#1)}} yields:
<pre class="brush:xml">
<function name="count" uri="http://www.w3.org/2005/xpath-functions" external="false">
<argument type="item()" occurrence="*"/>
<return type="xs:integer"/>
…is represented by {{Code|inspect:function(local:same#1)}} as…
<pre class="brush: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>
<annotation name="private" uri="http://www.w3.org/2012/xquery"/>
==inspect:context==
 
{| width='100%'
|-
==inspect:module==
 
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|inspect:module|$input uri as xs:string|element(module)}}
|-
| '''Summary'''
|Retrieves the resource addressed by located at the specified {{Code|$inputuri}}, parses it as XQuery module, and generates an element that describes the module's structure. A relative URI will be resolved against the static base URI of the query.
|-
| '''Errors'''
==inspect:xqdoc==
 
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|inspect:xqdoc|$input uri as xs:string|element(xqdoc:xqdoc)}}
|-
| '''Summary'''
|Retrieves the resource addressed by located at the specified {{Code|$inputuri}}, parses it as XQuery module, and generates an xqDoc element. A relative URI will be resolved against the static base URI of the query.<br/>[http://xqdoc.org xqDoc] provides a simple vendor-neutral solution for generating documentation from XQuery modules. The documentation conventions have been inspired by the JavaDoc standard. Documentation comments begin with {{Code|(:~}} and end with {{Code|:)}}, and tags start with {{Code|@}}. xqDoc comments can be specified for main and library modules and variable and function declarations.<br/>We have slightly extended the xqDoc conventions to do justice to the current status more recent versions of XQuery (Schema: [http://files.basex.org/etc/xqdoc-1.1.30052013.xsd xqdoc-1.1.30052013.xsd]):<br/>
* an {{Code|<xqdoc:annotations/>}} node is added to each variable or function that uses annotations. The xqdoc:annotation child nodes may have additional {{Code|xqdoc:literal}} elements with {{Code|type}} attributes (xs:string, xs:integer, xs:decimal, xs:double) and values.
* a single {{Code|<xqdoc:namespaces/>}} node is added to the root element, which summarizes all prefixes and namespace URIs used or declared in the module.
<see>http://docs.basex.org/wiki/XQDoc_Module</see>
<version>1.0</version>
<variable name="samples:test-string" uri="http://basex.org/modules/samples" type="xs:string" external="false">
<description>This is a sample string.</description>
</variable>
<function name="samples:same" uri="http://basex.org/modules/samples" external="false">
<argument name="number" type="xs:integer">number to return</argument>
<annotation name="private" uri="http://www.w3.org/2012/xquery"/>
</xqdoc:xqdoc>
</pre>
 
=Errors=
 
{| class="wikitable" width="100%"
! width="110"|Code
|Description
|-
|{{Code|unknown}}
|The specified component does not exist.
|}
=Changelog=
 
;Version 8.5
* Added: [[#inspect:function-annotations|inspect:function-annotations]], [[#inspect:static-context|inspect:static-context]]
* Updated: {{Code|external}} attribute added to variables and functions
* Updated: Relative URIs will always be resolved against the static base URI of the query
;Version 7.9
 
* Updated: a query URI can now be specified with [[#inspect:functions|inspect:functions]].
This module was introduced with Version 7.7.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu