tidysimple-test.xql 11.8 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
xquery version "3.1";

(: This library module contains XQSuite tests for the all modules module stored 
 : in tidysimple.xqm :)

module namespace tidysimple-test = "http://fontane-nb.dariah.eu/tidysimple-test";

import module namespace tidySimple ="http://fontane-nb.dariah.eu/tidysimple" at "../tidysimple.xqm";

declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace test="http://exist-db.org/xquery/xqsuite";

MRodz's avatar
MRodz committed
13
(: handshifts :)
14
declare 
15
    %test:name("handShift - Sort out invalid ones")
MRodz's avatar
MRodz committed
16
    %test:args("<milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""handshift"" subtype=""#Stempel2""/>")
MRodz's avatar
MRodz committed
17
18
    %test:assertEmpty   
    
MRodz's avatar
MRodz committed
19
20
    %test:args("<milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""handshift"" subtype=""#Fontane"" rend=""script(Latf) medium()""/>")
    %test:assertEquals("<milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""handshift"" subtype=""#Fontane"" rend=""script(Latf) medium()""/>")
MRodz's avatar
MRodz committed
21
    
22
23
    function tidysimple-test:handShift-invalid($node as element(*)) {
        tidySimple:sort-out-invalid-hands($node)
24
};
25
26
27

declare 
    %test:name("handShift - Sort out invalid nodes after an invalid hand")
MRodz's avatar
MRodz committed
28
    %test:args("<body xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""handshift"" subtype=""#Friedrich_Fontane"" rend=""script(Latn clean) medium(black_ink)""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""font-size:small"">Dieses Buch hat 52 Blatt.</seg></body>")
29
30
    %test:assertEquals("<body xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/></body>")  
    
MRodz's avatar
MRodz committed
31
32
    %test:args("<body xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""handshift"" subtype=""#Friedrich_Fontane"" rend=""script(Latn clean) medium(black_ink)""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""font-size:small"">Dieses Buch hat 52 Blatt.</seg><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""handshift"" subtype=""#Fontane"" rend=""script(Latn clean) medium(black_ink)""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""paragraph""/><seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""font-size:small"">Text von Fontane</seg><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""paragraph""/></body>")
    %test:assertEquals("<body xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""handshift"" subtype=""#Fontane"" rend=""script(Latn clean) medium(black_ink)""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""paragraph""/><seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""font-size:small"">Text von Fontane</seg><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""paragraph""/></body>") 
MRodz's avatar
MRodz committed
33
    
MRodz's avatar
MRodz committed
34
    %test:args("<div xmlns=""http://www.tei-c.org/ns/1.0"" type=""label"" xml:id=""a4""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""handshift"" subtype=""#fremde_Hand3"" rend=""script(Latn clean) medium()""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line"" rendition=""align(center)""/>✓ </div>")
MRodz's avatar
MRodz committed
35
    %test:assertEquals("<div xmlns=""http://www.tei-c.org/ns/1.0"" type=""label"" xml:id=""a4""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line"" rendition=""align(center)""/></div>")
36
    
37
    function tidysimple-test:handShift-invalid-nodes($node as element(*)) {
38
39
        tidySimple:sort-out-invalid-hands($node)
};
40

MRodz's avatar
MRodz committed
41
declare 
42
    %test:name("handShift - Sort out surplus ones")
MRodz's avatar
MRodz committed
43
44
    %test:args("<div xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""handshift"" subtype=""#Fontane"" rend=""script(Latf clean) medium()""/>Some text<milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""handshift"" subtype=""#Fontane"" rend=""script(Latn clean) medium()""/></div>")
    %test:assertEquals("<div xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""handshift"" subtype=""#Fontane"" rend=""script(Latf clean) medium()""/>Some text<milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""handshift"" subtype=""#Fontane"" rend=""script(Latn clean) medium()""/></div>")    
MRodz's avatar
MRodz committed
45
    
MRodz's avatar
MRodz committed
46
47
    %test:args("<div xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""handshift"" subtype=""#Fontane"" rend=""script(Latn clean) medium()""/>Some text<milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""handshift"" subtype=""#Fontane"" rend=""script(Latn clean) medium()""/></div>")
    %test:assertEquals("<div xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""handshift"" subtype=""#Fontane"" rend=""script(Latn clean) medium()""/>Some text</div>")   
48
    
MRodz's avatar
MRodz committed
49
50
    %test:args("<body xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""handshift"" subtype=""#Fontane"" rend=""script(Latf standard) medium()""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""handshift"" subtype=""#Fontane"" rend=""script() medium()""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""section"" type=""Text_1"" spanTo=""#C07_3r_s""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""handshift"" subtype=""#Fontane"" rend=""script(Latn clean) medium()""/><head xmlns=""http://www.tei-c.org/ns/1.0"" type=""x-large"" rend=""align(center)""><rs xmlns=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""psn:Luther""><hi xmlns=""http://www.tei-c.org/ns/1.0"">Luther</hi></rs></head></body>")
    %test:assertEquals("<body xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""section"" type=""Text_1"" spanTo=""#C07_3r_s""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""handshift"" subtype=""#Fontane"" rend=""script(Latn clean) medium()""/><head xmlns=""http://www.tei-c.org/ns/1.0"" type=""x-large"" rend=""align(center)""><rs xmlns=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""psn:Luther""><hi xmlns=""http://www.tei-c.org/ns/1.0"">Luther</hi></rs></head></body>")
MRodz's avatar
MRodz committed
51
    
52
    function tidysimple-test:handShift-surplus($node as element(*)) {
53
        tidySimple:sort-out-surplus-elements($node)
MRodz's avatar
MRodz committed
54
55
56
};


57
(: Sections :)
58
59

declare 
60
    %test:name("Sections")
MRodz's avatar
MRodz committed
61
62
(:    %test:args("<body xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""section"" type=""Text_2"" spanTo=""#C07_4r_s""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""handshift"" subtype=""#Fontane"" rend=""script(Latn clean) medium()""/><head xmlns=""http://www.tei-c.org/ns/1.0"" type=""x-large"" rend=""align(center)""><seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""font-size:x-large; letter-spacing:0.2cm""><rs type=""direct"" ref=""psn:Cranach""><hi xmlns=""http://www.tei-c.org/ns/1.0"">Lucas Cranach</hi></rs>.</seg></head><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""handshift"" subtype=""#Fontane"" rend=""script(Latf clean) medium()""/><anchor xmlns=""http://www.tei-c.org/ns/1.0"" xml:id=""C07_4r_s""/></body>"):)
(:    %test:assertEquals("<body xmlns=""http://www.tei-c.org/ns/1.0""><div xmlns=""http://www.tei-c.org/ns/1.0"" type=""section""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""handshift"" subtype=""#Fontane"" rend=""script(Latn clean) medium()""/><head xmlns=""http://www.tei-c.org/ns/1.0"" type=""x-large"" rend=""align(center)""><seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""font-size:x-large; letter-spacing:0.2cm""><rs type=""direct"" ref=""psn:Cranach""><hi xmlns=""http://www.tei-c.org/ns/1.0"">Lucas Cranach</hi></rs>.</seg></head><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""handshift"" subtype=""#Fontane"" rend=""script(Latf clean) medium()""/></div></body>")    :)
63
    
64
65
    %test:args("<body xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><rs xmlns=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""psn:Amalberga""><hi xmlns=""http://www.tei-c.org/ns/1.0"" xml:id=""C07_7r_d"" prev=""#C07_7r_c"">Amalberga</hi></rs></body>")
    %test:assertEquals("<body xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><rs xmlns=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""psn:Amalberga""><hi xmlns=""http://www.tei-c.org/ns/1.0"" xml:id=""C07_7r_d"" prev=""#C07_7r_c"">Amalberga</hi></rs></body>")
66
    
67
    %test:args("<body xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""paragraph""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line"" rendition=""indent""/>Dies dauerte <date xmlns=""http://www.tei-c.org/ns/1.0"" from=""1125"" to=""1425"" type=""asynchronous"">300 Jahr</date>.<milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""paragraph""/></body>")
68
    %test:assertEquals("<body xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""paragraph""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line"" rendition=""indent""/>Dies dauerte <date xmlns=""http://www.tei-c.org/ns/1.0"" from=""1125"" to=""1425"" type=""asynchronous"">300 Jahr</date>.<milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""paragraph""/></body>")    
69
70
71
72
    
    function tidysimple-test:sections($node as element(*)) {
        tidySimple:make-structure($node)
};
73
74
75
76
77
78
79
80
81
82


(: tidying :)
declare 
    %test:name("Tidying up surplus elements")
    %test:args("<text xmlns:tei=""http://www.tei-c.org/ns/1.0""><pb xmlns:tei=""http://www.tei-c.org/ns/1.0"" n=""58r""/><milestone xmlns:tei=""http://www.tei-c.org/ns/1.0"" unit=""line""/><pb xmlns:tei=""http://www.tei-c.org/ns/1.0"" n=""58v""/></text>")
    %test:assertEquals("<text xmlns:tei=""http://www.tei-c.org/ns/1.0""><pb xmlns:tei=""http://www.tei-c.org/ns/1.0"" n=""58r""/><pb xmlns:tei=""http://www.tei-c.org/ns/1.0"" n=""58v""/></text>")
    
    function tidysimple-test:tidying($node as element(*)) {
        tidySimple:sort-out-surplus-elements($node)
83
84
85
86
87
88
};


(: TOC by Friedrich Fontane :)
declare
    %test:name("TOC by Friedrich Fontane")
mrodzis's avatar
mrodzis committed
89
90
    %test:args("<div xmlns:tei=""http://www.tei-c.org/ns/1.0"" type=""toc"" subtype=""Friedrich_Fontane""><milestone unit=""handshift"" subtype=""#Archivar2"" rend=""script() medium()""/><milestone unit=""line""/><milestone unit=""handshift"" subtype=""#Friedrich_Fontane"" rend=""script() medium(blue_ink)""/><milestone unit=""line""/>Material zu<milestone unit=""handshift"" subtype=""#Friedrich_Fontane"" rend=""script(Latn) medium()""/><item>Ellernklipp</item><milestone unit=""handshift"" subtype=""#Friedrich_Fontane"" rend=""script(Latn) medium(black_ink)""/><item><ref target=""#xpath(//surface[@n='21r'])"">Wanderungen (Spreeland)</ref></item><milestone unit=""handshift"" subtype=""#Fontane"" rend=""script(Latf) medium(pencil)""/></div>")
    %test:assertEquals("<div xmlns:tei=""http://www.tei-c.org/ns/1.0"" type=""toc"" subtype=""Friedrich_Fontane""><milestone unit=""handshift"" subtype=""#Friedrich_Fontane"" rend=""script() medium(blue_ink)""/>Material zu<milestone unit=""handshift"" subtype=""#Friedrich_Fontane"" rend=""script(Latn) medium()""/><item>Ellernklipp</item><milestone unit=""handshift"" subtype=""#Friedrich_Fontane"" rend=""script(Latn) medium(black_ink)""/><item><ref target=""#xpath(//surface[@n='21r'])"">Wanderungen (Spreeland)</ref></item><milestone unit=""handshift"" subtype=""#Fontane"" rend=""script(Latf) medium(pencil)""/></div>")
91
92
93
94
95
96

    function tidysimple-test:toc-by-friedrich($node as element(*)) {
        tidySimple:sort-out-invalid-hands($node) 
        => tidySimple:sort-out-surplus-elements()
        => tidySimple:whitespaces()
        => tidySimple:split-headings()
97
};