dba/config
library moduleP
Summary
DBA configuration.
- Tags
Author: Christian Grün, BaseX Team 2005-21, BSD License
__source : lib/config.xqm
Imports
This module is imported by 16 modules. It imports 1 modules.
imports
→this
imports
→Variables
Functions
4.1 config:directory
Arities: config:directory#0config:directory#1
config:directory
(
)
as
xs:string
config:directory
(
$value
as
xs:string
)
as
empty-sequence()
xs:string
directory
Invokes 4 functions from 3 modules
- {http://basex.org/modules/session}get#1
- {http://basex.org/modules/session}set#2
- {http://expath.org/ns/file}exists#1
- {http://www.w3.org/2005/xpath-functions}exists#1
Invoked by 10 functions from 10 modules
Source ( 13 lines)
function config:directory() as xs:string {
let $dir := session:get($config:DIRECTORY)
return if(exists($dir) and file:exists($dir)) then (
$dir
) else (
$options:DBA-DIRECTORY
)
}
function config:directory(
$value as xs:string
) as empty-sequence() {
session:set($config:DIRECTORY, $value)
}
4.2 config:query
Arities: config:query#0config:query#1
config:query
(
)
as
xs:string ?
config:query
(
$value
as
xs:string
)
as
empty-sequence()
xs:string ?
current query
Invokes 2 functions from 1 modules
- {http://basex.org/modules/session}get#1
- {http://basex.org/modules/session}set#2
Invoked by 6 functions from 6 modules
Source ( 9 lines)
function config:query(
) as xs:string? {
session:get($config:QUERY)
}
function config:query(
$value as xs:string
) as empty-sequence() {
session:set($config:QUERY, $value)
}
4.3 config:query-files
Arities: config:query-files#0
config:query-files
(
)
as
xs:string *
xs:string *
list of files
Invokes 4 functions from 3 modules
- config:directory#0
- {http://expath.org/ns/file}exists#1
- {http://expath.org/ns/file}list#1
- {http://www.w3.org/2005/xpath-functions}matches#2
Invoked by 2 functions from 2 modules
Source ( 5 lines)
function config:query-files() as xs:string* {
let $dir := config:directory()
where file:exists($dir)
return file:list($dir)[matches(., '\.xqm?$')]
}
Namespaces
The following namespaces are defined:
Prefix | Uri |
---|---|
ann | http://www.w3.org/2012/xquery |
config | dba/config |
options | dba/options |
Source Code
(:~
: DBA configuration.
:
: @author Christian Grün, BaseX Team 2005-21, BSD License
:)
module namespace config = 'dba/config';
import module namespace options = 'dba/options' at 'options.xqm';
(:~ Session key. :)
declare variable $config:SESSION-KEY := 'dba';
(:~ Current directory. :)
declare %private variable $config:DIRECTORY := 'dba-directory';
(:~ Current query. :)
declare %private variable $config:QUERY := 'dba-query';
(:~
: Returns the current working directory.
: @return directory
:)
declare function config:directory() as xs:string {
let $dir := session:get($config:DIRECTORY)
return if(exists($dir) and file:exists($dir)) then (
$dir
) else (
$options:DBA-DIRECTORY
)
};
(:~
: Assigns a working directory.
: @param $value value
:)
declare function config:directory(
$value as xs:string
) as empty-sequence() {
session:set($config:DIRECTORY, $value)
};
(:~
: Returns the name of the current query.
: @return current query
:)
declare function config:query(
) as xs:string? {
session:get($config:QUERY)
};
(:~
: Assigns the name of the current query.
: @param $value value
:)
declare function config:query(
$value as xs:string
) as empty-sequence() {
session:set($config:QUERY, $value)
};
(:~
: Returns the names of all files.
: @return list of files
:)
declare function config:query-files() as xs:string* {
let $dir := config:directory()
where file:exists($dir)
return file:list($dir)[matches(., '\.xqm?$')]
};