Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WeGA-WebApp-lib
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
busoni-schriften
WeGA-WebApp-lib
Commits
9ff9f589
Commit
9ff9f589
authored
7 years ago
by
Peter Stadler
Browse files
Options
Downloads
Patches
Plain Diff
updated app-shared:if-not-exists()
in parallel with app-shared:if-exists()
parent
abbcac6e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
xquery/app-shared.xqm
+30
-20
30 additions, 20 deletions
xquery/app-shared.xqm
with
30 additions
and
20 deletions
xquery/app-shared.xqm
+
30
−
20
View file @
9ff9f589
...
...
@@ -101,10 +101,12 @@ declare
(:~
: Processes the node only if some $key exists in $model and its value is *not* the empty sequence, an empty string or false()
:
: @param $node the current node to process from the HTML template
: @parma $model the current model that's passed on by the templating module
: @param $key the key to look for in the current $model. Multiple keys must be separated by whitespace only
: @param $wrap whether to include the current node in the output (defaults to 'yes')
: @param $or whether to search for with an logical OR when mulitple keys are given (defaults to 'yes')
: @
author Peter Stadler
: @
return the processed $node if the ckech was succesful, the empty sequence otherwise
:)
declare
%templates:default
(
"wrap"
,
"yes"
)
...
...
@@ -132,26 +134,34 @@ declare
(:~
: Processes the node only if some $key (value) *not* exists in $model
:
: @author Peter Stadler
: @param $node the current node to process from the HTML template
: @parma $model the current model that's passed on by the templating module
: @param $key the key to look for in the current $model. Multiple keys must be separated by whitespace only
: @param $wrap whether to include the current node in the output (defaults to 'yes')
: @param $or whether to check with an logical OR when mulitple keys are given (defaults to 'yes')
: @return the processed $node if the ckech was succesful, the empty sequence otherwise
:)
declare
function
app-shared:if-not-exists
(
$node
as
node
()
,
$model
as
map
(
*
)
,
$key
as
xs:string
,
$wrap
as
xs:string
,
$or
as
xs:string
)
as
node
()
?
{
let
$thisOr
:=
$or
=
(
'yes'
,
'true'
)
let
$tokens
:=
tokenize
(
$key
,
'\s+'
)
let
$output
:=
function
()
{
if
(
$wrap
=
'yes'
)
then
element
{
node-name
(
$node
)}
{
$node
/
@
*,
$app-shared:templates-process
(
$node
/
node
()
,
$model
)
}
else
$app-shared:templates-process
(
$node
/
node
()
,
$model
)
}
return
if
(
$thisOr
)
then
if
(
some
$token
in
$tokens
satisfies
not
(
wega-util-shared:has-content
(
$model
(
$token
))))
then
$output
()
else
()
else
if
(
every
$token
in
$tokens
satisfies
not
(
wega-util-shared:has-content
(
$model
(
$token
))))
then
$output
()
else
()
declare
%templates:default
(
"wrap"
,
"yes"
)
%templates:default
(
"or"
,
"yes"
)
function
app-shared:if-not-exists
(
$node
as
node
()
,
$model
as
map
(
*
)
,
$key
as
xs:string
,
$wrap
as
xs:string
,
$or
as
xs:string
)
as
node
()
?
{
let
$thisOr
:=
$or
=
(
'yes'
,
'true'
)
let
$tokens
:=
tokenize
(
$key
,
'\s+'
)
let
$output
:=
function
()
{
if
(
$wrap
=
'yes'
)
then
element
{
node-name
(
$node
)}
{
$node
/
@
*,
$app-shared:templates-process
(
$node
/
node
()
,
$model
)
}
else
$app-shared:templates-process
(
$node
/
node
()
,
$model
)
}
return
if
(
$thisOr
)
then
if
(
some
$token
in
$tokens
satisfies
not
(
wega-util-shared:has-content
(
$model
(
$token
))))
then
$output
()
else
()
else
if
(
every
$token
in
$tokens
satisfies
not
(
wega-util-shared:has-content
(
$model
(
$token
))))
then
$output
()
else
()
};
(:~
...
...
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