dba/databases
library moduleUR
Summary
Save users information.
- Tags
Author: Christian Grün, BaseX Team 2005-21, BSD License
__source : users/users-info.xqm
Imports
This module is imported by 0 modules. It imports 1 modules.
Variables
Functions
4.1 dba:users-info
Arities: dba:users-info#1UR
dba:users-info
(
$info
as
xs:string
)
as
empty-sequence()
- info
as
xs:string
users information
empty-sequence()
redirection
Invokes 8 functions from 4 modules
- util:redirect#2
- {http://basex.org/modules/user}info#0
- {http://basex.org/modules/user}update-info#1
- {http://www.w3.org/2001/XMLSchema}QName#1
- {http://www.w3.org/2005/xpath-functions}deep-equal#2
- {http://www.w3.org/2005/xpath-functions}error#1
- {http://www.w3.org/2005/xpath-functions}not#1
- {http://www.w3.org/2005/xpath-functions}parse-xml#1
Invoked by 0 functions from 0 modules
Annotations
%updating | () |
%rest:POST | () |
%rest:path | ('/dba/users-info') |
%rest:form-param | ('info','{$info}') |
Source ( 20 lines)
function dba:users-info(
$info as xs:string
) as empty-sequence() {
try {
(: change user info :)
let $xml := if($info) then (
parse-xml($info)/*[self::info or error(xs:QName(err:FORC0006))]
) else (
<info/>
)
where not(deep-equal(user:info(), $xml))
return user:update-info($xml),
util:redirect($dba:CAT, map { 'info': 'User was saved.' })
} catch err:FODC0006 {
util:redirect($dba:CAT, map { 'error': 'Information must be XML with an info root element.' })
} catch * {
util:redirect($dba:CAT, map { 'error': $err:description })
}
}
Namespaces
The following namespaces are defined:
Prefix | Uri |
---|---|
ann | http://www.w3.org/2012/xquery |
dba | dba/databases 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
rest | http://exquery.org/ns/restxq |
util | dba/util |
Source Code
(:~
: Save users information.
:
: @author Christian Grün, BaseX Team 2005-21, BSD License
:)
module namespace dba = 'dba/databases';
import module namespace util = 'dba/util' at '../lib/util.xqm';
(:~ Top category :)
declare variable $dba:CAT := 'users';
(:~
: Saves users information.
: @param $info users information
: @return redirection
:)
declare
%updating
%rest:POST
%rest:path('/dba/users-info')
%rest:form-param('info', '{$info}')
function dba:users-info(
$info as xs:string
) as empty-sequence() {
try {
(: change user info :)
let $xml := if($info) then (
parse-xml($info)/*[self::info or error(xs:QName(err:FORC0006))]
) else (
<info/>
)
where not(deep-equal(user:info(), $xml))
return user:update-info($xml),
util:redirect($dba:CAT, map { 'info': 'User was saved.' })
} catch err:FODC0006 {
util:redirect($dba:CAT, map { 'error': 'Information must be XML with an info root element.' })
} catch * {
util:redirect($dba:CAT, map { 'error': $err:description })
}
};