This repository has been archived by the owner on Jan 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedition.xquery
162 lines (155 loc) · 7.8 KB
/
edition.xquery
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
xquery version "3.0";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
declare namespace functx = "http://www.functx.com";
(: Local function written by David J. Birnbaum ([email protected]) :)
declare namespace djb = "www.obdurodon.org";
declare option exist:serialize "method=xhtml media-type=application/xhtml+html indent=no";
declare function djb:locus($from as node()?, $to as node()?)
{
(if ($from eq $to)
then
$from/string()
else
if (substring($from, 1, string-length($from) - 1) eq substring($to, 1, string-length($to) - 1))
then
concat($from, '-v')
else
concat($from, '-', $to))
};
declare function functx:is-node-in-sequence-deep-equal
($node as node()?,
$seq as node()*) as xs:boolean {
some $nodeInSeq in $seq
satisfies deep-equal($nodeInSeq, $node)
};
declare function functx:distinct-deep
($nodes as node()*) as node()* {
for $seq in (1 to count($nodes))
return
$nodes[$seq][not(functx:is-node-in-sequence-deep-equal(
., $nodes[position() < $seq]))]
};
declare variable $cantigas := collection('/db/variatio/edition')//tei:div[@type eq 'poem'];
declare variable $poets := doc('/db/variatio/ancillary/corpus-autores.xml')//tei:person[@xml:id/string() = $cantigas//tei:name[@role eq 'author']/substring(@ref, 2)];
declare variable $partialselection := request:get-parameter("song", ());
declare variable $partialSelection := request:get-parameter("author", ());
declare variable $nextSelection := request:get-parameter("scribe", ());
declare variable $line := request:get-parameter("line", ());
let $selectionPoet := for $i in tokenize($partialSelection, ',+')
return
concat('#', $i)
let $selectionSong := for $y in tokenize($partialselection, ',+')
return
concat('#', $y)
let $selectionScribe := for $g in tokenize($nextSelection, ',+')
return
concat('#', $g)
let $songs := $cantigas[@corresp = $selectionSong] |
$cantigas[descendant::tei:name[@ref = $selectionPoet]] |
$cantigas[tei:head/descendant::tei:rdg[@hand = $selectionScribe]]
return
<div
class="multiple">
<section>
{
for $song in functx:distinct-deep($songs)
let $author := doc('/db/variatio/ancillary/corpus-autores.xml')//tei:person[concat('#', @xml:id) = $song//tei:name[@role eq 'author']/@ref]
order by $song/number(substring-before(substring(@corresp, 3), 'B'))
return
<div
id="{$song/substring(@corresp, 2)}"
class="poem">
<div
class="metadata">
<h2><span
class="pt gl">Cantiga</span><span
class="en">Song</span>
{': ' || string-join($song//tei:title//tei:idno, ', ')}</h2>
<h2><span
class="pt gl">Autor</span><span
class="en">Author</span>
{': ' || $author/tei:persName/string()}</h2>
<h2><span
class="pt gl">Período</span><span
class="en">Period</span>
{': ' || $author/tei:floruit/@from/string()}-{$author/tei:floruit/@to/string()}
(<span
class="pt gl">período</span><span
class="en">period</span>
{' ' || $author/tei:floruit/@period/string()})</h2>
</div>
<p
style="text-align:center"><a
class="pt"
href="http://gl-pt.obdurodon.org/editionTab.php?song={$song/substring(@corresp, 2)}"
target="_blank">Ver edição tabular</a><a
class="gl"
href="http://gl-pt.obdurodon.org/editionTab.php?song={$song/substring(@corresp, 2)}"
target="_blank">Ver edición tabular</a>
<a
class="en"
href="http://gl-pt.obdurodon.org/editionTab.php?song={$song/substring(@corresp, 2)}">Ver edición tabular</a></p>
<div
class="body">
{
for $witness in $song/tei:head/descendant::tei:rdg
let $parameter :=
<parameters>
<param
name="wit"
value="{$witness/@wit}"/>
<param
name="line"
value="{$line}"/>
</parameters>
return
<div
class="witness">
<h3><span
class="pt gl">Testemu<span
class="pt">nh</span><span
class="gl">ñ</span>o</span><span
class="en">Witness</span>: {$witness/substring(@wit, 2)}</h3>
<h4>Text<span
class="pt gl">o</span>: {$witness/tei:idno/string()}</h4>
<h4><span
class="pt gl">Localiza<span
class="pt">ção</span><span
class="gl">ción</span></span><span
class="en">Location</span>: {djb:locus($witness/tei:locus/@from, $witness/tei:locus/@to)}</h4>
<h4><span
class="pt gl">Copista</span><span
class="en">Copyist</span>: {$witness/substring(@hand, 2)}</h4>
{transform:transform($song//tei:lg, doc('/db/variatio/xslt/reading.xsl'), $parameter)}
</div>
}
</div>
</div>
}
</section>
<aside
id="summary">
{
(if (count($songs) gt 1) then
(<h3
class="pt">Cantigas</h3>,
<h3
class="en">Songs</h3>,
<ul>{
for $song in $songs
order by $song/number(substring-before(substring(@corresp, 3), 'B'))
return
<li><a
href="{$song/@corresp}">{string-join($song//tei:title//tei:idno, ', ')}</a></li>
}
</ul>)
else
())
}
<p
class="dinamic"><span
class="pt">Mudar critérios</span><span
class="gl">Cambiar criterios</span><span
class="en">Change criteria</span></p>
</aside>
</div>