Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
fontane-notizbuecher
SADE
Commits
15b872a5
Commit
15b872a5
authored
Nov 06, 2018
by
MRodz
Committed by
mrodzis
Feb 05, 2019
Browse files
Implement handling of @prev elements
parent
bfbcd458
Changes
2
Hide whitespace changes
Inline
Side-by-side
modules/fontane/teisimpleprint/presort.xqm
View file @
15b872a5
...
...
@@ -36,19 +36,30 @@ declare function presort:main($file as xs:string) as node()? {
declare function presort:sort($nodes as node()*) as node()* {
for $node in $nodes
return
typeswitch ($node)
case text() return
case text() return
$node
case attribute(prev) return
()
case attribute(next) return
"blubb"
default return
element {QName("http://www.tei-c.org/ns/1.0", $node/name())} {
$node/@*,
presort:sort($node/node())
}
if($node/@prev and $node/@next) then
presort:keep-node($node)
else if($node/@prev) then
()
else if($node/@next) then
()
else
presort:keep-node($node)
};
declare function presort:keep-node($node as node()*) as node()* {
element {$node/name()} {
namespace tei {"http://www.tei-c.org/ns/1.0"},
$node/@*,
presort:sort($node/node())
}
};
declare function presort:copy-next-to-right-place($node as node()*) {
()
};
\ No newline at end of file
modules/fontane/teisimpleprint/tests/presort-test.xql
View file @
15b872a5
...
...
@@ -29,34 +29,39 @@ declare
(: Default nodes :)
declare
%test:name("Default nodes")
%test:args("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" medium=""pencil"" script=""Latf""/>")
%test:assertEquals("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" medium=""pencil"" script=""Latf""/>")
%test:args("<handShift xmlns
:tei
=""http://www.tei-c.org/ns/1.0"" medium=""pencil"" script=""Latf""/>")
%test:assertEquals("<handShift xmlns
:tei
=""http://www.tei-c.org/ns/1.0"" medium=""pencil"" script=""Latf""/>")
%test:args("<seg xmlns=""http://www.tei-c.org/ns/1.0""><stamp xmlns=""http://www.tei-c.org/ns/1.0"">STAATSBIBLIOTHEK •BERLIN•</stamp></seg>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0""><stamp xmlns=""http://www.tei-c.org/ns/1.0"">STAATSBIBLIOTHEK •BERLIN•</stamp></seg>")
%test:args("<seg xmlns
:tei
=""http://www.tei-c.org/ns/1.0""><stamp xmlns
:tei
=""http://www.tei-c.org/ns/1.0"">STAATSBIBLIOTHEK •BERLIN•</stamp></seg>")
%test:assertEquals("<seg xmlns
:tei
=""http://www.tei-c.org/ns/1.0""><stamp xmlns
:tei
=""http://www.tei-c.org/ns/1.0"">STAATSBIBLIOTHEK •BERLIN•</stamp></seg>")
function presort-test:default-nodes($node as element(*)) {
presort:sort($node)
};
(: @
prev
nodes :)
(: @
next
nodes :)
declare
%test:name("
Om
it @
prev
nodes")
%test:args("<handShift xmlns=""http://www.tei-c.org/ns/1.0""
medium=""pencil"" script=""Latf
""/>")
%test:assertE
quals("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" medium=""pencil"" script=""Latf""/>")
%test:name("
Establishing right order w
it
h
@
next
nodes")
%test:args("<handShift xmlns
:tei
=""http://www.tei-c.org/ns/1.0""
next=""#some-test-id
""/>")
%test:assertE
mpty
%test:args("<seg xmlns=""http://www.tei-c.org/ns/1.0"" prev=""#some_id""><stamp xmlns=""http://www.tei-c.org/ns/1.0"">STAATSBIBLIOTHEK •BERLIN•</stamp></seg>")
%test:assertEmpty
function presort-test:omit-prev-nodes($node as element(*)) {
function presort-test:next-nodes($node as element(*)) {
presort:sort($node)
};
(: @next nodes :)
(: @prev nodes :)
declare
%test:name("Establishing right order with @next nodes")
%test:args("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" next=""#some-test-id""/>")
%test:name("Omit @prev nodes")
%test:args("<handShift xmlns:tei=""http://www.tei-c.org/ns/1.0"" medium=""pencil"" script=""Latf""/>")
%test:assertEquals("<handShift xmlns:tei=""http://www.tei-c.org/ns/1.0"" medium=""pencil"" script=""Latf""/>")
%test:args("<seg xmlns:tei=""http://www.tei-c.org/ns/1.0"" prev=""#some_id""><stamp xmlns:tei=""http://www.tei-c.org/ns/1.0"">STAATSBIBLIOTHEK •BERLIN•</stamp></seg>")
%test:assertEmpty
function presort-test:next-nodes($node as element(*)) {
%test:args("<seg xmlns:tei=""http://www.tei-c.org/ns/1.0"" prev=""#some_id"" next=""#some_other_id""><stamp xmlns:tei=""http://www.tei-c.org/ns/1.0"">STAATSBIBLIOTHEK •BERLIN•</stamp></seg>")
%test:assertEquals("<seg xmlns:tei=""http://www.tei-c.org/ns/1.0"" prev=""#some_id"" next=""#some_other_id""><stamp xmlns:tei=""http://www.tei-c.org/ns/1.0"">STAATSBIBLIOTHEK •BERLIN•</stamp></seg>")
%test:args("<seg xmlns:tei=""http://www.tei-c.org/ns/1.0"" prev=""#some_id"" next=""#some_other_id""><stamp prev=""#id"" xmlns:tei=""http://www.tei-c.org/ns/1.0"">STAATSBIBLIOTHEK •BERLIN•</stamp></seg>")
%test:assertEquals("<seg xmlns:tei=""http://www.tei-c.org/ns/1.0"" prev=""#some_id"" next=""#some_other_id""/>")
function presort-test:omit-prev-nodes($node as element(*)) {
presort:sort($node)
};
\ No newline at end of file
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment