- do not combine code-linting and content work in one commit
- Whitespace handling
- Use whitespaces, not tabs to indent code
- Close file with a newline character
For formatting of XQuery files we generally rely on the basic configuration of Synchrosoft’s oXygen XML software family and its “Format & Indent” function.
We use xqDoc for documenting the XQueries in this repository. Please refer to the section xqDoc Comments of the xqDoc-website for details on formatting the documentation comment blocks.
- XQuery modules must have a library module xqDoc comment preceding the module declaration.
- Function declarations must have a library module xqDoc function comment preceding the function.
XQuery version declaration
xquery version 3.1;
Beginning comments
For now, the beginning comments should only include the following:
(:
: Copyright: For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
:)
The beginning comments and the structuring comments (see below) of the prolog are separated by a blank line.
Prolog
- The parts of the prolog, are introduced by a comment followed by a new line.
- The below form of the comments and the order of the parts is prescriptive.
- Each part of the prolog ends with a blank line.
(: IMPORTS ================================================================= :)
Sort imports by type:
- All
import module namespace
statements registered with eXist-db - All
import module namespace
statements of custom modules that are not registered with eXist-db. Always use relative URIs for unregisteredimport module namespace
statements. - Separate groups with a blank line.
- In the groups sort alphabetically by prefix.
(: NAMESPACE DECLARATIONS ================================================== :)
All declare namespace
statements, sorted alphabetically by prefix.
(: OPTION DECLARATIONS ===================================================== :)
All declare option
statements.
(: VARIABLE DECLARATIONS =================================================== :)
- Use
declare variable
statements for all required external parameters - All global variable declarations, i.e.
declare variable
statements. - Separate these two groups with a blank line.
- In the groups, sort alphabetically.
(: FUNCTION DECLARATIONS =================================================== :)
- All
declare function
statements. - All function declarations have to be preceded by an xqDoc comment.
- The xqDoc comment and function declaration belonging together are not separated by blank lines – not even one ;-)
- The comment-function-groups are separated by blank lines.
A prototypical example:
(: FUNCTION DECLARATIONS =========================================== :)
(:~
:
:)
declare function eg:addComment($comment as xs:string, $function as function())
as xs:string
{
…
}
(:~
:)
declare function eg:addComment($comment as xs:string, $function as function())
as xs:string
{
…
}
Query body
The Query body start after a structuring comment as follows:
(: QUERY BODY ============================================================== :)
Strings
Note: this is derived from the current usage in Edirom-Online code
- escape with U+00027 APOSTROPHE:
'
Literal results
TODO: how should literal results be indented, especially when they are long, e.g., as in the case of getAudioPlayer.xql.
let statements
Short variable definitions should be in a single line:
let $lang := 'de'
Longer assignments, especially when the contain if-else-statements or FLWOR-expressions, should break after :=
and then indent a further level, before following the rules applicable to the respective statements, e.g.:
let $elems :=
for $p in $participants
let $id := substring-after($p, '#')
return doc($doc)/id($id)
Function declarations
(:~
: XQdoc comment
:
…
:
:)
declare function prefix:function-name( $paramOne as datatype, §paramTwo as datatype )
as datatype
{
…
};
- at the moment return datatypes and opening curly braces of function declarations are still in the same line as the
declare function
statement - break long function argument
- literal results formatting
- nested return statements
- parenthesis placement
The class EdiromOnline.controller.AJAXController
provides a central method doAJAXRequest
for performing AJAX requests. The method is provided globally as window.doAJAXRequest
.
doAJAXRequest
takes the following arguments:
url
: The URL of the requestet site or end point.method
: The HTTP method likePUT
,GET
,POST
.params
: An object containing key-value-pairs of parameters for the request.successFn
: A callback function which is called when the AJAX request was successfull.retryNo
: The number of retries, if the requests fails. Standard is 2 retries.async
: Defines the async parameter for AJAX calls. Default is 'true'.
An example of using the function would be:
window.doAJAXRequest('data/xql/getAnnotationMeta.xql',
'GET',
{
uri: uri,
lang: lang
},
Ext.bind(function(response){
view.setMeta(response.responseText);
}, this)
);