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
43ffaf59
Unverified
Commit
43ffaf59
authored
7 years ago
by
MRodz
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
added further preprocessing for whitespaces
parent
7d3b8bb3
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/intermediate_format/whitespace-handling.xqm
+42
-11
42 additions, 11 deletions
modules/intermediate_format/whitespace-handling.xqm
with
42 additions
and
11 deletions
modules/intermediate_format/whitespace-handling.xqm
+
42
−
11
View file @
43ffaf59
xquery
version
"3.0"
;
(:~
(:~
: WHITESPACE Module ("whitespace", "http://bdn.edition.de/intermediate_format/whitespace_handling")
: *******************************************************************************************
: This module contains the functions to handle different whitespace operations on text
...
...
@@ -9,12 +9,14 @@ xquery version "3.0";
: @author Uwe Sikora
:)
module
namespace
whitespace
=
"http://bdn.edition.de/intermediate_format/whitespace_handling"
;
import
module
namespace
pre
=
"http://bdn.edition.de/intermediate_format/preprocessing"
at
"preprocessing.xqm"
;
declare
default
element
namespace
"http://www.tei-c.org/ns/1.0"
;
(:############################# Modules Functions #############################:)
(:~
(:~
: whitespace:text()
: This function handles whitespace in defined text() nodes
:
...
...
@@ -28,26 +30,26 @@ declare default element namespace "http://www.tei-c.org/ns/1.0";
:)
declare
function
whitespace:text
(
$text
as
text
()
*,
$escape-char
as
xs:string
?
)
as
text
()
*
{
let
$normalized
:=
normalize-space
(
$text
)
let
$whitespace-node
:=
$text
[
matches
(
.,
"[\s\n\r\t]"
)
and
normalize-space
(
.
)
=
""
]
let
$single-whitespace-between-nodes
:=
$text
=
' '
return
return
if
(
not
(
$whitespace-node
)
or
$single-whitespace-between-nodes
)
then
(
if
(
$escape-char
)
then
(
whitespace:escape-text
(
$text
,
"#"
)
whitespace:escape-text
(
$text
,
"#"
)
)
else
(
whitespace:escape-text
(
$text
,
" "
)
)
)
)
else
()
};
(:~
(:~
: whitespace:escape-text()
: This function replaces whitespaces in a text()
: This function replaces whitespaces in a text()
: with a defined preservation character
:
: @param $text the text-node to be converted
...
...
@@ -63,3 +65,32 @@ declare function whitespace:escape-text
text
{
replace
(
$text
,
'[\s]+'
,
$escape
)}
};
(:~
: whitespace:set-additional-whitespace()
: This function creates a "break-after"-attribute for a node, that has to be
: followed by a whitespace in PDF.
:
:
: @param $node the current node
: @return node() the new node with an attribute where necessary
:
: @version 1.0 (2018-02-13)
: @status working
: @author Michelle Rodzis
:)
declare
function
whitespace:set-additional-whitespace
(
$node
as
node
())
as
node
()
{
let
$following-node
:=
$node
/
following-sibling
::
node
()[
1
]
let
$following-sibling
:=
$node
/
following-sibling
::*
[
1
]
return
element
{
$node
/
name
()}{
$node
/
@
*,
(
if
(
$following-node
[
matches
(
.,
"[\s\n\r\t]"
)
and
normalize-space
(
.
)
=
""
]
and
$following-sibling
[
self
::
ref
or
self
::
app
or
self
::
hi
or
self
::
bibl
or
self
::
foreign
or
self
::
choice
or
self
::
milestone
or
self
::
persName
or
self
::
choice
or
self
::
index
])
then
attribute
{
"break-after"
}{
"yes"
}
else
())
,
pre:preprocessing
(
$node
/
node
())
}
};
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