Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
intermediate-format
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
bibliothek-der-neologie
intermediate-format
Commits
4db7b546
"README.rst" did not exist on "a9c5da5bd566698bdff2278f214f0ad662b54cfd"
Commit
4db7b546
authored
7 years ago
by
uwe
Browse files
Options
Downloads
Patches
Plain Diff
added new module with helper functions
parent
6164e634
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/ifutils.xqm
+87
-0
87 additions, 0 deletions
modules/ifutils.xqm
with
87 additions
and
0 deletions
modules/ifutils.xqm
0 → 100644
+
87
−
0
View file @
4db7b546
xquery
version
"3.1"
;
(:~
: INTERMEDIATEFORMAT Utils Module ("ifutils", "http://bdn.edition.de/intermediate_format/utils")
: *******************************************************************************************
: This modules defines helpfull functions used all over the app
:
: @version 1.0 (2018-02-23)
: @status developing
: @author Uwe Sikora
:)
module
namespace
ifutils
=
"http://bdn.edition.de/intermediate_format/utils"
;
import
module
namespace
http
=
"http://expath.org/ns/http-client"
;
(:############################# Modules Variables #############################:)
(:############################# Modules Functions #############################:)
(:~
: ifutils:exists()
: This function checks if a resource exists in a directory
:
: @param $uri the uri of a resource
: @return xs:boolean ('true' else 'false')
:
: @version 1.0 (2018-03-23)
: @status working
: @author Uwe Sikora
:)
declare
function
ifutils:exists
(
$uri
as
xs:string
)
{
let
$files
:=
(
for
$i
in
collection
(
replace
(
$uri
,
'(.+)/.+$'
,
'$1'
))
return
base-uri
(
$i
))
return
$uri
=
$files
};
(:~
: ifutils:get-resource()
: This function gets a resource from the database or from a online source
:
: @param $uri the uri of a resource
: @return document-node
:
: @version 1.0 (2018-03-23)
: @status developing
: @author Uwe Sikora
:)
declare
function
ifutils:get-resource
(
$uri
as
xs:string
)
{
let
$resource
:=
(
if
(
ifutils:exists
(
$uri
)
)
then
(
doc
(
$uri
)
)
else
()
)
return
$resource
};
(:~
: ifutils:request()
: This http wrapper function models a request
:
: @param $uri the uri of a resource
: @param $method the http method
: @param $username the username
: @param $password the password
: @return http-response
:
: @version 1.0 (2018-03-23)
: @status developing
: @author Uwe Sikora
:)
declare
function
ifutils:request
(
$url
as
xs:string
,
$method
as
xs:string
,
$username
as
xs:string
?,
$password
as
xs:string
?
)
{
let
$req
:=
<http:request
href=
"
{
$url
}
"
method=
"
{
$method
}
"
username=
"
{
$username
}
"
password=
"
{
$password
}
"
auth-method=
"basic"
send-authorization=
"true"
/>
return
http:send-request
(
$req
)
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment