Inspection Module

From BaseX Documentation
Revision as of 09:08, 31 May 2013 by CG (talk | contribs) (moved XQDoc Module to Inspection Module)
Jump to navigation Jump to search

This XQuery Module contains functions for generating xqDoc files from XQuery modules.


xqDoc provides a simple vendor neutral solution for generating a documentation from XQuery modules. The documentation conventions have been inspired by the JavaDoc standard. Documentation comments begin with (:~ and end with :), and tags start with @. xqDoc comments can be specified for main and library modules and variable and function declarations. We have slightly extended the conventions and updated the xqDoc schema:

  • an <xqdoc:namespaces/> node lists all namespaces of a module
  • if annotations are attached to variables or functions, an <xqdoc:annotations/> node is added
  • variables now have a name and a type.

An example is shown below.


All functions in this module are assigned to the namespace, which is statically bound to the xqdoc prefix.
All errors are assigned to the namespace, which is statically bound to the bxerr prefix.



Signatures xqdoc:parse($input as xs:string) as element(xqdoc:xqdoc)
Summary Parses the specified $input and generates an xqDoc element.


The query xqdoc:parse('sample.xq') will convert the following example module...

 : This module provides some sample functions to demonstrate
 : the features of the XQDoc Module.
 : @author BaseX Team
 : @see
 : @version 1.0
module namespace samples = '';

(:~ This is a sample string. :)
declare variable $samples:test-string
  as xs:string := 'this is a string';

 : This function simply returns the specified integer.
 : @param $number number to return
 : @return specified number
declare %private function samples:same(
  $number as xs:integer
) as xs:integer {
}; the following output:

<xqdoc:xqdoc xmlns:xqdoc="">
  <xqdoc:module type="library">
    <xqdoc:namespace prefix="samples" uri=""/>
        <xqdoc:description>This is a sample string.</xqdoc:description>
    <xqdoc:function arity="1">
        <xqdoc:description>This function simply returns the specified integer.</xqdoc:description>
        <xqdoc:param>$number number to return</xqdoc:param>
        <xqdoc:return>specified number</xqdoc:return>
        <xqdoc:annotation name="private"/>
      <xqdoc:signature>declare %private function samples:same($number as xs:integer) as xs:integer</xqdoc:signature>


This module was introduced with Version 7.7.