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
bb654744
Commit
bb654744
authored
6 years ago
by
Jakob Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
update from upstream
parent
54f65403
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
xquery/app-shared.xqm
+13
-11
13 additions, 11 deletions
xquery/app-shared.xqm
xquery/str.xqm
+13
-20
13 additions, 20 deletions
xquery/str.xqm
with
26 additions
and
31 deletions
xquery/app-shared.xqm
+
13
−
11
View file @
bb654744
...
...
@@ -139,22 +139,24 @@ declare
: @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 c
k
ec
h
was succesful, the empty sequence otherwise
: @return the processed $node if the c
h
ec
k
was succesful, the empty sequence otherwise
:)
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
)
}
let
$thisOr
:=
if
(
$or
castable
as
xs:boolean
)
then
xs:boolean
(
$or
)
else
false
()
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
()
...
...
This diff is collapsed.
Click to expand it.
xquery/str.xqm
+
13
−
20
View file @
bb654744
...
...
@@ -19,7 +19,16 @@ import module namespace functx="http://www.functx.com";
: @return xs:string
:)
declare
function
str:normalize-space
(
$string
as
xs:string
?
)
as
xs:string
{
normalize-unicode
(
normalize-space
(
replace
(
$string
,
' | | | '
,
' '
)))
normalize-unicode
(
normalize-space
(
replace
(
(: diverse Control Codes entsorgen, siehe https://en.wikipedia.org/wiki/List_of_Unicode_characters :)
replace
(
$string
,
'||€'
,
''
)
,
(: diversen Whitespace entsorgen, siehe https://en.wikipedia.org/wiki/Whitespace_character :)
' | | | '
,
' '
)
)
)
};
(:~
...
...
@@ -41,30 +50,14 @@ declare function str:join-path-elements($segs as xs:string*) as xs:string {
: @author Peter Stadler
: @return xs:string
:)
declare
function
str:print
F
orname
S
urname
(
$name
as
xs:string
?
)
as
xs:string
?
{
declare
function
str:print
-f
or
e
name
-s
urname
(
$name
as
xs:string
?
)
as
xs:string
?
{
let
$clearName
:=
str:normalize-space
(
$name
)
return
if
(
functx:number-of-matches
(
$clearName
,
','
)
eq
1
)
then
if
(
ends-with
(
$clearName
,
' d’'
))
then
normalize-space
(
string-join
(
reverse
(
tokenize
(
$clearName
,
','
))))
else
normalize-space
(
string-join
(
reverse
(
tokenize
(
$clearName
,
','
))
,
' '
))
if
(
functx:number-of-matches
(
$clearName
,
','
)
eq
1
)
then
normalize-space
(
string-join
(
reverse
(
tokenize
(
$clearName
,
','
))
,
' '
))
else
$clearName
};
(:~
: Print forename surname from a TEI persName element
: In contrast to str:printFornameSurname() this function checks the appearance of forenames, i.e.
: <persName type="reg"><forename>Eugen</forename> <forename>Friedrich</forename> <forename>Heinrich</forename>, <roleName>Herzog</roleName> <nameLink>von</nameLink> Württemberg</persName>
: is turned into "Eugen Friedrich Heinrich, Herzog von Württemberg" rather than "Herzog von Württemberg Eugen Friedrich Heinrich"
:
: @param $name a tei persName element
: @author Peter Stadler
: @return xs:string
:)
declare
function
str:printFornameSurnameFromTEIpersName
(
$persName
as
element
(
tei:persName
)
?
)
as
xs:string
?
{
if
((
$persName
/
element
()[
1
])[
self
::
tei:forename
])
then
str:normalize-space
(
$persName
)
else
str:printFornameSurname
(
string
(
$persName
))
};
(:~
: Surround a string with typographic double quotes
:
...
...
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