Changes

Jump to navigation Jump to search
660 bytes added ,  14:36, 26 January 2022
<syntaxhighlight lang="xquery">
let $uri := 'code.xqm'
let $name := "'run"'
for $f in inspect:functions($uri)
where local-name-from-QName(function-name($f)) = $name
==inspect:type==
{{Mark|Introduced Updated with Version 9.36:}}options added.
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|inspect:type|$value as item()*|xs:string}}<br/>{{Func|inspect:type|$value as item()*, $options as map(*)|xs:string}}
|-
| '''Summary'''
|Returns a string representation of the type of a {{Code|$value}}:
* The string includes the occurrence indicator.
* The type of functions and nodes may be stricter than the returned type.
* For type checking, the standard expressions {{Code|typeswitch}} and {{Code|instance of}} should be used instead.
The following {{Code|$options}} are available:
* {{Code|item}}: If enabled, only the item type is returned and the occurrence indicator is omitted. The default is {{Code|false()}}.
* {{Code|mode}}: If {{Code|value}} is specified, the assigned type of the result value is returned. With {{Code|expression}} the type of the input expression is returned (please note that the original expression may already have been rewritten at compile-time). With {{Code|computed}}, the exact value is computed at runtime, based on the expression and the result value. The default is {{Code|computed}}.
|-
| '''Examples'''
|
* <code>inspect:type(1 to 100(<a/>, <a/>))</code> returns yields <code>xs:integerelement(a)+</code>* <code>inspect:type(map { 'a': (1, 2)[. = 1] })</code> returns <code>map(*)</code>; a stricter type representation would be yields <code>map(xs:string, xs:stringinteger)</code>* <code>inspect:type(<a/>1 to 100, map { 'item': true()</code> returns <code>element(})</code>; a stricter type representation would be yields <code>element(a)xs:integer</code>
|}
|-
| '''Summary'''
|Retrieves the resource located at the specified {{Code|$uri}}, 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 more recent versions of XQuery (Schema: [https://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.
=Changelog=
 
;Version 9.6
* Updated: [[#inspect:type|inspect:type]]: options added
;Version 9.3
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu