Commit 15b872a5 authored by MRodz's avatar MRodz Committed by mrodzis
Browse files

Implement handling of @prev elements

parent bfbcd458
......@@ -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
......@@ -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("Omit @prev 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:name("Establishing right order with @next nodes")
%test:args("<handShift xmlns:tei=""http://www.tei-c.org/ns/1.0"" next=""#some-test-id""/>")
%test:assertEmpty
%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
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment