diff --git a/XQuery/XSLT/dub.xsl b/XQuery/XSLT/dub.xsl
new file mode 100644
index 0000000..c09761e
--- /dev/null
+++ b/XQuery/XSLT/dub.xsl
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+ ]
+
+
+ //
+
+
+
+ --
+
+
+
+
+
+
+
+
+
+ --
+
+
+
+
+
+
+
+
+
+
+ error
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/XQuery/XSLT/ex.xsl b/XQuery/XSLT/ex.xsl
new file mode 100644
index 0000000..5d209bb
--- /dev/null
+++ b/XQuery/XSLT/ex.xsl
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+ ]
+
+
+ //
+
+
+
+ --
+
+
+
+
+
+
+
+
+
+
+ --
+
+
+
+
+
+
+
+
+
+
+ error
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/XQuery/XSLT/reading.xsl b/XQuery/XSLT/reading.xsl
new file mode 100644
index 0000000..b64f5b3
--- /dev/null
+++ b/XQuery/XSLT/reading.xsl
@@ -0,0 +1,623 @@
+
+
+
+
+
+
+
+ '
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ highlight
+
+
+
+
+
+
+
+
+
+
+
+ error en
+
+
+
+
+
+
+ error pt
+
+
+
+
+
+
+ error gl
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ linguistic en
+
+
+
+
+
+
+ linguistic pt
+
+
+
+
+
+
+ linguistic gl
+
+
+
+
+
+
+
+
+
+
+ equipolent en
+
+
+
+
+
+
+ equipolent pt
+
+
+
+
+
+
+ equipolent gl
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ error en
+
+
+
+
+
+
+ error pt
+
+
+
+
+
+
+ error gl
+
+
+
+
+
+
+
+
+
+
+
+ linguistic en
+
+
+
+
+
+
+ linguistic pt
+
+
+
+
+
+
+ linguistic gl
+
+
+
+
+
+
+
+
+ equipolent en
+ Divergent reading
+
+
+
+ equipolent pt
+ Lição divergente
+
+
+
+ equipolent gl
+ Lección diverxente
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ hide
+
+ (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ pt
+
+
+
+ Omissão provocada pelo estado de conservação do testemunho
+
+
+ Trecho ilegível
+
+
+
+
+
+ *
+
+
+
+
+
+
+
+
+
+ gl
+
+
+
+ Omisión provocada polo estado de conservación do testemuño
+
+
+ Trecho ilexíbel
+
+
+
+
+
+ *
+
+
+
+
+
+
+
+
+
+ en
+
+
+
+ Damaged witness
+
+
+ Illegible
+
+
+
+
+
+ *
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ gap pt
+
+
+
+ Erro de cópia
+
+
+ Omissão de conteúdos repetidos
+
+
+ Omissão de origem desconhecida
+
+
+ Omissão provocada pelo estado de conservação do testemunho
+
+
+ Trecho ilegível
+
+
+ Provavelmente, omissão presente no modelo
+
+
+ Testemunho inacabado
+
+
+
+
+ ∅
+
+
+ ⁅
+
+
+
+ *
+
+
+
+
+
+
+ ⁆
+
+
+ [ ]
+
+
+
+
+
+ gap gl
+
+
+
+ Erro de copia
+
+
+ Omisión de contidos repetidos
+
+
+ Omisión de orixe descoñecida
+
+
+ Omisión provocada polo estado de conservación do testemuño
+
+
+ Trecho ilexíbel
+
+
+ Probabelmente, omisión presente no modelo
+
+
+ Testemuño inacabado
+
+
+
+
+ ∅
+
+
+ ⁅
+
+
+
+ *
+
+
+
+
+
+
+ ⁆
+
+
+ [ ]
+
+
+
+
+
+ gap en
+
+
+
+ Scribal error
+
+
+ Omission of repeated contents
+
+
+ Unknown reason for omission
+
+
+ Damaged witness
+
+
+ Illegivel
+
+
+ Likely, omission present in the model of this witness
+
+
+ Unfinished witness
+
+
+
+
+ ∅
+
+
+ ⁅
+
+
+
+ *
+
+
+
+
+
+
+ ⁆
+
+
+ [ ]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ’
+
+
+
+
+
+
+
+
diff --git a/XQuery/XSLT/select.xsl b/XQuery/XSLT/select.xsl
new file mode 100644
index 0000000..c9d48ae
--- /dev/null
+++ b/XQuery/XSLT/select.xsl
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+ /
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/XQuery/XSLT/string.xsl b/XQuery/XSLT/string.xsl
new file mode 100644
index 0000000..4b550ff
--- /dev/null
+++ b/XQuery/XSLT/string.xsl
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/XQuery/XSLT/table.xsl b/XQuery/XSLT/table.xsl
new file mode 100644
index 0000000..8078935
--- /dev/null
+++ b/XQuery/XSLT/table.xsl
@@ -0,0 +1,486 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ error en
+
+
+
+
+
+
+ error pt
+
+
+
+
+
+
+ error gl
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ linguistic en
+
+
+
+
+
+
+ linguistic pt
+
+
+
+
+
+
+ linguistic gl
+
+
+
+
+
+
+
+
+
+
+ equipolent en
+
+
+
+
+
+
+ equipolent pt
+
+
+
+
+
+
+ equipolent gl
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ error en
+
+
+
+
+
+
+ error pt
+
+
+
+
+
+
+ error gl
+
+
+
+
+
+
+
+
+
+
+
+ linguistic en
+
+
+
+
+
+
+ linguistic pt
+
+
+
+
+
+
+ linguistic gl
+
+
+
+
+
+
+
+
+ equipolent en
+ Divergent reading
+
+
+
+ equipolent pt
+ Lição divergente
+
+
+
+ equipolent gl
+ Lección diverxente
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ (
+
+
+
+
+
+
+
+
+
+
+ gap pt
+
+
+
+ Erro de cópia
+
+
+ Omissão de conteúdos repetidos
+
+
+ Omissão de origem desconhecida
+
+
+ Omissão provocada pelo estado de conservação do testemunho
+
+
+ Trecho ilegível
+
+
+ Provavelmente, omissão presente no modelo
+
+
+ Testemunho inacabado
+
+
+
+
+
+
+ gap gl
+
+
+
+ Erro de copia
+
+
+ Omisión de contidos repetidos
+
+
+ Omisión de orixe descoñecida
+
+
+ Omisión provocada polo estado de conservación do testemuño
+
+
+ Trecho ilexíbel
+
+
+ Probabelmente, omisión presente no modelo
+
+
+ Testemuño inacabado
+
+
+
+
+
+
+ gap en
+
+
+
+ Scribal error
+
+
+ Omission of repeated contents
+
+
+ Unknown reason for omission
+
+
+ Damaged witness
+
+
+ Illegivel
+
+
+ Likely, omission present in the model of this witness
+
+
+ Unfinished witness
+
+
+
+
+
+
+
+
+
+ )
+
+
+
+
+
+ enhance
+
+
+
+
+
+
+
+
+ gap pt
+
+
+
+ Erro de cópia
+
+
+ Omissão de conteúdos repetidos
+
+
+ Omissão de origem desconhecida
+
+
+ Omissão provocada pelo estado de conservação do testemunho
+
+
+ Trecho ilegível
+
+
+ Provavelmente, omissão presente no modelo
+
+
+ Testemunho inacabado
+
+
+ [ ]
+
+
+
+ gap gl
+
+
+
+ Erro de copia
+
+
+ Omisión de contidos repetidos
+
+
+ Omisión de orixe descoñecida
+
+
+ Omisión provocada polo estado de conservación do testemuño
+
+
+ Trecho ilexíbel
+
+
+ Probabelmente, omisión presente no modelo
+
+
+ Testemuño inacabado
+
+
+ [ ]
+
+
+
+ gap en
+
+
+
+ Scribal error
+
+
+ Omission of repeated contents
+
+
+ Unknown reason for omission
+
+
+ Damaged witness
+
+
+ Illegivel
+
+
+ Likely, omission present in the model of this witness
+
+
+ Unfinished witness
+
+
+ [ ]
+
+
+
+
+
+
+
+
+
+
+
+ ’
+
+
+
+
+
\ No newline at end of file
diff --git a/XQuery/corpus.xquery b/XQuery/corpus.xquery
new file mode 100644
index 0000000..950104a
--- /dev/null
+++ b/XQuery/corpus.xquery
@@ -0,0 +1,313 @@
+xquery version "3.0";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
+declare option output:method "xhtml";
+declare option output:indent "yes";
+declare option output:encoding "UTF-8";
+let $authors := doc('/db/VTLGP/ancillary/corpus-autores.xml')//tei:person[concat('#', @xml:id) = collection('/db/VTLGP/edition')//tei:name[@role eq 'author']/@ref]
+let $periods := $authors/tei:floruit/@period
+let $copyists := collection('/db/VTLGP/edition')//tei:div//tei:title//tei:rdg/substring(@hand, 2)
+let $authorsImpar := doc('/db/VTLGP/ancillary/corpus-autores.xml')//tei:person[concat('#', @xml:id) = collection('/db/VTLGP/edition')//tei:name[@role eq 'author']/@ref][tei:persName/matches(., '^[A-J]')]
+let $authorsPar := doc('/db/VTLGP/ancillary/corpus-autores.xml')//tei:person[concat('#', @xml:id) = collection('/db/VTLGP/edition')//tei:name[@role eq 'author']/@ref][tei:persName/matches(., '^[L-Z]')]
+return
+
+ (
,
+ (: Por período By period ,
+ ,:)
+ Por copista By scribe ,
+
+ )
diff --git a/XQuery/count.xquery b/XQuery/count.xquery
new file mode 100644
index 0000000..9e14e47
--- /dev/null
+++ b/XQuery/count.xquery
@@ -0,0 +1,5 @@
+xquery version "3.0";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+let $songs := collection('/db/VTLGP/edition')//tei:div[@type eq 'poem']
+return
+ count($songs)
\ No newline at end of file
diff --git a/XQuery/count2.xquery b/XQuery/count2.xquery
new file mode 100644
index 0000000..5c66155
--- /dev/null
+++ b/XQuery/count2.xquery
@@ -0,0 +1,5 @@
+xquery version "3.0";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+declare variable $songs := collection('/db/VTLGP/edition')//tei:div[@type eq 'poem'];
+declare variable $authors := doc('/db/VTLGP/ancillary/corpus-autores.xml')//tei:person[concat('#', @xml:id) = $songs//tei:name[@role eq 'author']/@ref];
+count($authors)
diff --git a/XQuery/edition.xquery b/XQuery/edition.xquery
new file mode 100644
index 0000000..9ceb56e
--- /dev/null
+++ b/XQuery/edition.xquery
@@ -0,0 +1,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 (djbpitt@gmail.com) :)
+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/VTLGP/edition')//tei:div[@type eq 'poem'];
+declare variable $poets := doc('/db/VTLGP/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
+
+
+ {
+ for $song in functx:distinct-deep($songs)
+ let $author := doc('/db/VTLGP/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
+
+
+
Cantiga Song
+ {': ' || string-join($song//tei:title//tei:idno, ', ')}
+ Autor Author
+ {': ' || $author/tei:persName/string()}
+ Período Period
+ {': ' || $author/tei:floruit/@from/string()}-{$author/tei:floruit/@to/string()}
+ (período period
+ {' ' || $author/tei:floruit/@period/string()})
+
+
Ver edição tabular Ver edición tabular
+ Ver edición tabular
+
+ {
+
+ for $witness in $song/tei:head/descendant::tei:rdg
+ let $parameter :=
+
+
+
+
+ return
+
+
Testemunh ñ o Witness : {$witness/substring(@wit, 2)}
+ Texto : {$witness/tei:idno/string()}
+ Localização ción Location : {djb:locus($witness/tei:locus/@from, $witness/tei:locus/@to)}
+ Copista Copyist : {$witness/substring(@hand, 2)}
+
+ {transform:transform($song//tei:lg, doc('/db/VTLGP/xslt/reading.xsl'), $parameter)}
+
+
+
+ }
+
+
+ }
+
+
+
\ No newline at end of file
diff --git a/XQuery/form.xquery b/XQuery/form.xquery
new file mode 100644
index 0000000..1a198de
--- /dev/null
+++ b/XQuery/form.xquery
@@ -0,0 +1,208 @@
+xquery version "3.0";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
+declare option output:method "xhtml";
+declare option output:indent "yes";
+declare option output:encoding "UTF-8";
+let $songs := collection('/db/VTLGP/edition')//tei:div[@type eq 'poem']
+let $anas := $songs//tei:rdg/@ana
+let $ana := distinct-values(for $values in $anas
+return
+ tokenize($values, '\s+'))
+let $file := doc('/db/VTLGP/ancillary/feature-library.xml')
+let $ling-features := $file//tei:fvLib/tei:fs[concat('#', @xml:id) = $ana]
+let $phonetic := $ling-features[.//tei:fs[@type eq 'phonetic']]
+let $morph := $ling-features[.//tei:fs[@type eq 'morphosyntactic']/tei:f[@name eq 'POS']/tei:fs]
+let $other := $ling-features[.//tei:fs[@type eq 'morphosyntactic']/tei:f[@name eq 'POS']/tei:symbol]
+
+return
+
+ (
+
,
+
+
,
+
+
+
+ )
diff --git a/XQuery/graphs/arcaico.svg b/XQuery/graphs/arcaico.svg
new file mode 100644
index 0000000..ceef8c0
--- /dev/null
+++ b/XQuery/graphs/arcaico.svg
@@ -0,0 +1,168 @@
+
+
+
+ Grafos
+
+
+
+ arcaísmos A
+
+ arcaísmos B
+
+ inovações A
+
+ inovações B
+
+
+
+ arcaísmos A
+
+ arcaísmos B
+
+ inovações A
+
+ inovações B
+
+
+
+ inovações A (gl)
+
+ inovações B (gl)
+
+ inovações A (pt)
+
+ inovações B (pt)
+
+
+
+ inovações A (gl)
+
+ inovações B (gl)
+
+ inovações A (pt)
+
+ inovações B (pt)
+
+
+
+
diff --git a/XQuery/graphs/arcaismos-evol.svg b/XQuery/graphs/arcaismos-evol.svg
new file mode 100644
index 0000000..15292ae
--- /dev/null
+++ b/XQuery/graphs/arcaismos-evol.svg
@@ -0,0 +1,4353 @@
+
+
+
+
+
+ Número ocorrências
+
+
+ A309
+
+
+
+ A307
+
+
+
+ A297
+
+
+
+ A296
+
+
+
+ A295
+
+
+
+ A294
+
+
+
+ A293
+
+
+
+ A292
+
+
+
+ A290
+
+
+
+ A289
+
+
+
+ A288
+
+
+
+ A286
+
+
+
+ A285
+
+
+
+ A283
+
+
+
+ A266
+
+
+
+ A265
+
+
+
+ A264
+
+
+
+ A263
+
+
+
+ A262
+
+
+
+ A261
+
+
+
+ A260
+
+
+
+ A259
+
+
+
+ A258
+
+
+
+ A257
+
+
+
+ A255
+
+
+
+ A248
+
+
+
+ A246
+
+
+
+ A245
+
+
+
+ A244
+
+
+
+ A243
+
+
+
+ A242
+
+
+
+ A240
+
+
+
+ A234
+
+
+
+ A233
+
+
+
+ A232
+
+
+
+ A231
+
+
+
+ A230
+
+
+
+ A229
+
+
+
+ A225
+
+
+
+ A224
+
+
+
+ A223
+
+
+
+ A222
+
+
+
+ A221
+
+
+
+ A220
+
+
+
+ A219
+
+
+
+ A218
+
+
+
+ A217
+
+
+
+ A205
+
+
+
+ A203
+
+
+
+ A202
+
+
+
+ A201
+
+
+
+ A200
+
+
+
+ A199
+
+
+
+ A192
+
+
+
+ A189
+
+
+
+ A187
+
+
+
+ A179
+
+
+
+ A174
+
+
+
+ A173
+
+
+
+ A171
+
+
+
+ A166
+
+
+
+ A165
+
+
+
+ A149
+
+
+
+ A146
+
+
+
+ A145
+
+
+
+ A144
+
+
+
+ A138
+
+
+
+ A137
+
+
+
+ A136
+
+
+
+ A135
+
+
+
+ A133
+
+
+
+ A132
+
+
+
+ A122
+
+
+
+ A121
+
+
+
+ A120
+
+
+
+ A119
+
+
+
+ A118
+
+
+
+ A117
+
+
+
+ A116
+
+
+
+ A115
+
+
+
+ A113
+
+
+
+ A112
+
+
+
+ A111
+
+
+
+ A101
+
+
+
+ A99
+
+
+
+ A95
+
+
+
+ A93
+
+
+
+ A92
+
+
+
+ A90
+
+
+
+ A89
+
+
+
+ A88
+
+
+
+ A87
+
+
+
+ A86
+
+
+
+ A85
+
+
+
+ A84
+
+
+
+ A83
+
+
+
+ A82
+
+
+
+ A76
+
+
+
+ A75
+
+
+
+ A74
+
+
+
+ A73
+
+
+
+ A72
+
+
+
+ A71
+
+
+
+ A70
+
+
+
+ A67
+
+
+
+ A66
+
+
+
+ A65
+
+
+
+ A64
+
+
+
+ A54
+
+
+
+ A53
+
+
+
+ A52
+
+
+
+ A51
+
+
+
+ A50
+
+
+
+ A49
+
+
+
+ A48
+
+
+
+ A47
+
+
+
+ A46
+
+
+
+ A45
+
+
+
+ A44
+
+
+
+ A43
+
+
+
+ A42
+
+
+
+ A41
+
+
+
+ A40
+
+
+
+ A35
+
+
+
+ A34
+
+
+
+ A33
+
+
+
+ A32
+
+
+
+ A31
+
+
+
+ A25
+
+
+
+ A24
+
+
+
+ A23
+
+
+
+ A22
+
+
+
+ A21
+
+
+
+ A20
+
+
+
+ A19
+
+
+
+ A18
+
+
+
+ A17
+
+
+
+ A16
+
+
+
+ A15
+
+
+
+ A14
+
+
+
+ A10
+
+
+
+ A9
+
+
+
+ A8
+
+
+
+ A7
+
+
+
+ A6
+
+
+
+ A5
+
+
+
+ A4
+
+
+
+ A3
+
+
+
+ A2
+
+
+
+ A1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Roi Fernandiz de Santiago
+ Vasco Rodriguez de Calvelo
+ Pero da Ponte
+ Fernan Padron
+ Pedr’ Eanes Solaz
+ Bonifaci Calvo
+ Fernan Velho
+ Pai Gomez Charinho
+ Johan Vasquiz de Talaveira
+ Estevan Faian
+ Johan Garcia de Guilhade
+ Afonso Lopez de Baian
+ Pero Gomez Barroso
+ Fernan Gonçalvez de Seabra
+ Johan Lopez de Ulhoa
+ Roi Paez de Ribela
+ Johan Soarez Coelho
+ Vasco Gil
+ Roi Queimado
+ Fernan Garcia Esgaravunha
+ Johan Nunez Camanez
+ Pero Garcia de Burgalês
+ Nuno Fernandez Torneol
+ Airas Carpancho
+ Martin Soarez
+ Pai Soarez de Taveirós
+ Johan Soarez Somesso
+ Vasco Fernandez Praga de Sandin
+
+
diff --git a/XQuery/graphs/arcaismos.xquery b/XQuery/graphs/arcaismos.xquery
new file mode 100644
index 0000000..2e483d3
--- /dev/null
+++ b/XQuery/graphs/arcaismos.xquery
@@ -0,0 +1,298 @@
+xquery version "3.0";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+declare variable $increase := number('2');
+declare variable $height := number('22');
+declare variable $fs := doc('../../ancillary/feature-library.xml')//tei:fs[@type];
+declare variable $arcaic :=
+for $i in $fs[@type eq 'arcaico']/@xml:id
+return
+ concat('#', $i);
+declare variable $innova-pt := for $i in $fs[@type eq 'inova-pt']/@xml:id
+return
+ concat('#', $i);
+declare variable $innova-gl := for $i in $fs[@type eq 'inova-gl']/@xml:id
+return
+ concat('#', $i);
+declare variable $innova := for $i in $fs[@type eq 'inova']/@xml:id
+return
+ concat('#', $i);
+declare variable $songs := collection('../../edition')//tei:div[@type eq 'poem'];
+declare variable $readingsA := $songs//tei:rdg[contains(@wit, '#A')];
+declare variable $readingsB := $songs//tei:rdg[contains(@wit, '#B')];
+declare variable $poets := doc('../../ancillary/corpus-autores.xml')//tei:person;
+let $width1a := count($readingsA[tokenize(@ana, '\s+') = $arcaic])
+let $width1a-dis := count(distinct-values($readingsA[tokenize(@ana, '\s+') = $arcaic]))
+let $width2a := count($readingsA[tokenize(@ana, '\s+') = $innova]) + count($readingsA[tokenize(@ana, '\s+') = $innova-gl]) +
+count($readingsA[tokenize(@ana, '\s+') = $innova-pt])
+let $width2a-dis := count(distinct-values($readingsA[tokenize(@ana, '\s+') = $innova])) +
+count(distinct-values($readingsA[tokenize(@ana, '\s+') = $innova-gl])) + count(distinct-values($readingsA[tokenize(@ana, '\s+') = $innova-pt]))
+
+let $width1b := count($readingsB[tokenize(@ana, '\s+') = $arcaic])
+let $width1b-dis := count(distinct-values($readingsB[tokenize(@ana, '\s+') = $arcaic]))
+let $width2b := count($readingsB[tokenize(@ana, '\s+') = $innova]) + count($readingsB[tokenize(@ana, '\s+') = $innova-gl]) +
+count($readingsB[tokenize(@ana, '\s+') = $innova-pt])
+let $width2b-dis := count(distinct-values($readingsB[tokenize(@ana, '\s+') = $innova])) +
+count(distinct-values($readingsB[tokenize(@ana, '\s+') = $innova-gl])) + count(distinct-values($readingsB[tokenize(@ana, '\s+') = $innova-pt]))
+
+let $width3a := count($readingsA[tokenize(@ana, '\s+') = $innova-gl])
+let $width3a-dis := count(distinct-values($readingsA[tokenize(@ana, '\s+') = $innova-gl]))
+let $width3b := count($readingsB[tokenize(@ana, '\s+') = $innova-gl])
+let $width3b-dis := count(distinct-values($readingsB[tokenize(@ana, '\s+') = $innova-gl]))
+
+let $width4a := count($readingsA[tokenize(@ana, '\s+') = $innova-pt])
+let $width4a-dis := count(distinct-values($readingsA[tokenize(@ana, '\s+') = $innova-pt]))
+let $width4b := count($readingsB[tokenize(@ana, '\s+') = $innova-pt])
+let $width4b-dis := count(distinct-values($readingsB[tokenize(@ana, '\s+') = $innova-pt]))
+
+return
+
+
+ Grafos
+
+
+
+ arcaísmos A
+
+ arcaísmos B
+
+ inovações A
+
+ inovações B
+
+
+
+ arcaísmos A
+
+ arcaísmos B
+
+ inovações A
+
+ inovações B
+
+
+
+ inovações A (gl)
+
+ inovações B (gl)
+
+ inovações A (pt)
+
+ inovações B (pt)
+
+
+
+ inovações A (gl)
+
+ inovações B (gl)
+
+ inovações A (pt)
+
+ inovações B (pt)
+
+
+
+
\ No newline at end of file
diff --git a/XQuery/graphs/common-text.xquery b/XQuery/graphs/common-text.xquery
new file mode 100644
index 0000000..2cb1ad6
--- /dev/null
+++ b/XQuery/graphs/common-text.xquery
@@ -0,0 +1,56 @@
+xquery version "3.0";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+declare option exist:serialize "method=html5 media-type=text/html omit-xml-declaration=yes indent=yes";
+declare variable $songs := collection('/db/VTLGP/edition')//tei:div[@type eq 'poem'];
+declare variable $fs := doc('/db/VTLGP/ancillary/feature-library.xml');
+declare variable $ling-features := $fs//tei:fvLib[@corresp eq '#linguistic']/tei:fs/@xml:id;
+declare variable $equipolent := $fs//tei:fvLib[@n eq 'equipolent readings']/tei:fs/@xml:id;
+declare variable $scribalError := $fs//tei:fvLib[@corresp eq '#scribal']/tei:fs/@xml:id;
+declare variable $significant := $equipolent | $scribalError | $ling-features;
+let $authors := doc('/db/VTLGP/ancillary/corpus-autores.xml')//tei:person[concat('#', @xml:id) = $songs//tei:name[@role eq 'author']/@ref]
+return
+
+
+ Overlapping graphs
+
+
+{for $author in $authors
+let $booksong := $songs[descendant::tei:name[@role eq 'author']/@ref = concat('#', $author/@xml:id)]
+order by $author
+return
+
+ ({$author/tei:persName/string()} ,
+
+ {
+ let $widthA:= sum($booksong/descendant::tei:rdg[contains(@wit, '#A')]/string-length(.)) div 10
+ let $xB:= sum($booksong/descendant::tei:rdg[@wit eq'#A']/string-length(.)) div 10
+ let $widthB:= sum($booksong/descendant::tei:rdg[contains(@wit, '#B')]/string-length(.)) div 10
+ let $count:= count($booksong)
+ return
+ (: if (count($booksong) le 3) then
+
+
+
+
+ else
+ if(count($booksong) gt 8) then
+
+
+
+
+
+
+ else
+
+
+
+ :)
+
+
+
+
+
+ }
+ )}
+
+
\ No newline at end of file
diff --git a/XQuery/graphs/corpus-comparison-compact.xquery b/XQuery/graphs/corpus-comparison-compact.xquery
new file mode 100644
index 0000000..ab6b0cf
--- /dev/null
+++ b/XQuery/graphs/corpus-comparison-compact.xquery
@@ -0,0 +1,264 @@
+xquery version "3.0";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+declare variable $songs := //song[@class eq 'A'];
+declare variable $b := //song[@class eq 'B'];
+declare variable $collection := collection('../../edition')//tei:div[@type eq 'poem'];
+declare variable $authors := distinct-values($songs/author);
+declare variable $realauthors := $songs/author[not(. = ' ')];
+declare variable $colors := ('#B54D1A', '#EAE5C5', '#4E240A', '#351278', '#B0E9ED', '#FFFDF0', '#848DF1', '#58B94C', '#B15282', '#5B77EE', '#FD2F8D', '#311CE1',
+'#E399DE', '#6A685A', '#D03471', '#6C659D', '#398566', '#74A0D7', '#F20EDA', '#6BA901', '#A38A9E', '#1D8A3E', '#1A2BB0', '#5C647F', '#EFC88C', '#A303DA', '#2F7A9B', '#9A5C61', '#CABFE5',
+'#1C4D5D', '#679DA1', '#B788A4', '#9D9875', '#F45B43', '#050526', '#2D648A', '#4C0391', '#B1CFF3', '#AE709B', '#4A14F4', '#A21169', '#BA6CDF', '#D91A91', '#D40549', '#1842D3',
+'#68579C', '#157715', '#7FF998', '#4EA807');
+declare variable $colors2 := ('#B54D1A', '#4E240A', '#351278', '#B0E9ED', '#FFFDF0', '#848DF1', '#58B94C', '#B15282', '#5B77EE', '#FD2F8D', '#311CE1',
+'#E399DE', '#6A685A', '#D03471', '#6C659D', '#398566', '#74A0D7', '#F20EDA', '#6BA901', '#A38A9E', '#1D8A3E', '#1A2BB0', '#5C647F', '#EFC88C',
+'#A303DA', '#2F7A9B', '#9A5C61', '#CABFE5', '#1C4D5D', '#679DA1', '#B788A4', '#9D9875', '#F45B43', '#050526', '#2D648A', '#4C0391', '#B1CFF3', '#AE709B',
+'#4A14F4', '#A21169', '#BA6CDF', '#D91A91', '#D40549', '#1842D3', '#68579C', '#157715', '#7FF998', '#4EA807');
+declare variable $colors3 := ('#B54D1A', '#EAE5C5', '#4E240A', '#351278', '#B0E9ED', '#EAE5C5', '#848DF1', '#58B94C', '#B15282', '#5B77EE', '#FD2F8D', '#311CE1',
+'#E399DE', '#6A685A', '#D03471', '#6C659D', '#398566', '#74A0D7', '#F20EDA', '#6BA901', '#A38A9E', '#1D8A3E', '#1A2BB0', '#5C647F', '#EFC88C', '#A303DA', '#2F7A9B', '#9A5C61', '#CABFE5',
+'#1C4D5D', '#679DA1', '#B788A4', '#9D9875', '#F45B43', '#050526', '#2D648A', '#4C0391', '#B1CFF3', '#AE709B', '#4A14F4', '#A21169', '#BA6CDF', '#D91A91', '#D40549', '#1842D3',
+'#68579C', '#157715', '#7FF998', '#4EA807');
+
+ All
+ Other witnesses
+ Done
+
+ {
+ let $sorted := for $song in $songs
+ order by $song/*[1]/number(replace(., '-.*', ''))
+ return
+ $song
+ for $song at $position in $sorted
+ let $margin := number('100')
+ let $current := index-of($authors, $song/*[3])
+ return
+ (if ((number($song/*[1]) + 3) mod 4 = 0) then
+
+
+ else
+ (if ((number($song/*[1]) + 2) mod 4 = 0)
+
+ then
+
+
+ else
+ (if ((number($song/*[1]) + 1) mod 4 = 0) then
+
+ else
+
+ ))
+
+ ,
+ if ($song/*[1]/@id = $b/*[1]/@id and (number($song/*[1]) + 3) mod 4 = 0) then
+
+ else
+ (if ($song/*[1]/@id = $b/*[1]/@id and (number($song/*[1]) + 2) mod 4 = 0)
+ then
+
+ else
+ (if ($song/*[1]/@id = $b/*[1]/@id and (number($song/*[1] + 1) mod 4 = 0))
+ then
+
+ else
+ (if ($song/*[1]/@id = $b/*[1]/@id and number($song/*[1] mod 4 = 0)) then
+
+ else
+ ()))),
+
+ if ($collection//tei:head/descendant::tei:rdg[@wit eq '#A']/substring(tei:idno, 2) = $song/*[1]/replace(., '-([a-z])', '$1')
+ and (number($song/*[1]) + 3) mod 4 = 0) then
+
+ else
+ (if ($collection//tei:head/descendant::tei:rdg[@wit eq '#A']/substring(tei:idno, 2) = $song/*[1]/replace(., '-([a-z])', '$1')
+ and (number($song/*[1]) + 2) mod 4 = 0) then
+
+ else
+ (if ($collection//tei:head/descendant::tei:rdg[@wit eq '#A']/substring(tei:idno, 2) = $song/*[1]/replace(., '-([a-z])', '$1')
+ and number($song/*[1] + 1) mod 4 = 0) then
+
+ else
+ (if ($collection//tei:head/descendant::tei:rdg[@wit eq '#A']/substring(tei:idno, 2) = $song/*[1]/replace(., '-([a-z])', '$1')
+ and number($song/*[1]) mod 4 = 0) then
+
+ else
+ ())))
+ )
+ }
+
+ {
+ for $author at $pos in distinct-values($realauthors)
+ let $current := $colors2[$pos]
+ return
+ if (($pos + 5) mod 6 = 0) then
+ ({replace($author, '\(.*?\)', '')} ,
+ )
+ else
+ (if (($pos + 4) mod 6 = 0)
+ then
+ ({replace($author, '\(.*?\)', '')} ,
+ )
+ else
+ (if (($pos + 3) mod 6 = 0) then
+ ({replace($author, '\(.*?\)', '')} ,
+ )
+ else
+ (if (($pos + 2) mod 6 = 0) then
+ ({replace($author, '\(.*?\)', '')} ,
+ )
+ else
+ (if (($pos + 1) mod 6 = 0)
+ then
+ ({replace($author, '\(.*?\)', '')} ,
+ )
+ else
+ (if ($pos mod 6 = 0)
+ then
+ ({replace($author, '\(.*?\)', '')} ,
+ )
+ else
+ ())))))
+ }
+
+
\ No newline at end of file
diff --git a/XQuery/graphs/corpus-comparison-long.xquery b/XQuery/graphs/corpus-comparison-long.xquery
new file mode 100644
index 0000000..97ead8e
--- /dev/null
+++ b/XQuery/graphs/corpus-comparison-long.xquery
@@ -0,0 +1,204 @@
+xquery version "3.0";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+declare variable $songs := //song[@class eq 'A'];
+declare variable $b := //song[@class eq 'B'];
+declare variable $collection := collection('../../edition')//tei:div[@type eq 'poem'];
+declare variable $authors := distinct-values($songs/author);
+declare variable $realauthors := $songs/author[not(. = ' ')];
+declare variable $colors := ('#B54D1A', '#4E240A', '#351278', '#FFFDF0', '#B0E9ED', '#848DF1', '#58B94C', '#B15282', '#5B77EE', '#FD2F8D', '#311CE1',
+'#E399DE', '#6A685A', '#D03471', '#EAE5C5', '#6C659D', '#398566', '#74A0D7', '#F20EDA', '#6BA901', '#A38A9E', '#1D8A3E', '#1A2BB0', '#5C647F', '#EFC88C', '#A303DA', '#2F7A9B', '#9A5C61', '#CABFE5',
+'#1C4D5D', '#679DA1', '#B788A4', '#9D9875', '#F45B43', '#050526', '#2D648A', '#4C0391', '#B1CFF3', '#AE709B', '#4A14F4', '#A21169', '#BA6CDF', '#D91A91', '#D40549', '#1842D3',
+'#68579C', '#157715', '#7FF998', '#4EA807');
+declare variable $colors2 := ('#B54D1A', '#4E240A', '#351278', '#FFFDF0', '#B0E9ED', '#848DF1', '#58B94C', '#B15282', '#5B77EE', '#FD2F8D', '#311CE1',
+'#E399DE', '#6A685A', '#D03471', '#6C659D', '#398566', '#74A0D7', '#F20EDA', '#6BA901', '#A38A9E', '#1D8A3E', '#1A2BB0', '#5C647F', '#EFC88C',
+'#A303DA', '#2F7A9B', '#9A5C61', '#CABFE5', '#1C4D5D', '#679DA1', '#B788A4', '#9D9875', '#F45B43', '#050526', '#2D648A', '#4C0391', '#B1CFF3', '#AE709B',
+'#4A14F4', '#A21169', '#BA6CDF', '#D91A91', '#D40549', '#1842D3', '#68579C', '#157715', '#7FF998', '#4EA807');
+
+ All
+ Other witnesses
+ Done
+
+ {
+ let $sorted := for $song in $songs
+ order by $song/*[1]/number(replace(., '-.*', ''))
+ return
+ $song
+ for $song at $position in $sorted
+ let $margin := number('100')
+ let $current := index-of($authors, $song/*[3])
+ return
+ (if ((number($song/*[1]) + 2) mod 3 = 0) then
+
+
+ else
+ (if ((number($song/*[1]) + 1) mod 3 = 0)
+
+ then
+
+
+ else
+
+ )
+
+ ,
+ if ($song/*[1]/@id = $b/*[1]/@id and (number($song/*[1]) + 2) mod 3 = 0) then
+
+ else
+ (if ($song/*[1]/@id = $b/*[1]/@id and (number($song/*[1]) + 1) mod 3 = 0)
+ then
+
+ else
+ (if ($song/*[1]/@id = $b/*[1]/@id and number($song/*[1] mod 3 = 0))
+ then
+
+ else
+ ())),
+ if ($collection//tei:head/descendant::tei:rdg[@wit eq '#A']/substring(tei:idno, 2) = $song/*[1]/replace(., '-([a-z])', '$1')
+ and (number($song/*[1]) + 2) mod 3 = 0) then
+
+ else
+ (if ($collection//tei:head/descendant::tei:rdg[@wit eq '#A']/substring(tei:idno, 2) = $song/*[1]/replace(., '-([a-z])', '$1')
+ and (number($song/*[1]) + 1) mod 3 = 0) then
+
+ else
+ (if ($collection//tei:head/descendant::tei:rdg[@wit eq '#A']/substring(tei:idno, 2) = $song/*[1]/replace(., '-([a-z])', '$1')
+ and number($song/*[1]) mod 3 = 0) then
+
+ else
+ ()))
+ )
+ }
+
+ {
+ for $author at $pos in distinct-values($realauthors)
+ let $current := $colors2[$pos]
+ return
+ if (($pos + 3) mod 4 = 0) then
+ ({replace($author, '\(.*?\)', '')} ,
+ )
+ else
+ (if (($pos + 2) mod 4 = 0)
+ then
+ ({replace($author, '\(.*?\)', '')} ,
+ )
+ else
+ (if (($pos + 1) mod 4 = 0) then
+ ({replace($author, '\(.*?\)', '')} ,
+ )
+ else
+ (if ($pos mod 4 = 0)
+ then
+ ({replace($author, '\(.*?\)', '')} ,
+ )
+ else
+ ())))
+ }
+
+
\ No newline at end of file
diff --git a/XQuery/graphs/corpus-comparison-tese.xquery b/XQuery/graphs/corpus-comparison-tese.xquery
new file mode 100644
index 0000000..ab6b0cf
--- /dev/null
+++ b/XQuery/graphs/corpus-comparison-tese.xquery
@@ -0,0 +1,264 @@
+xquery version "3.0";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+declare variable $songs := //song[@class eq 'A'];
+declare variable $b := //song[@class eq 'B'];
+declare variable $collection := collection('../../edition')//tei:div[@type eq 'poem'];
+declare variable $authors := distinct-values($songs/author);
+declare variable $realauthors := $songs/author[not(. = ' ')];
+declare variable $colors := ('#B54D1A', '#EAE5C5', '#4E240A', '#351278', '#B0E9ED', '#FFFDF0', '#848DF1', '#58B94C', '#B15282', '#5B77EE', '#FD2F8D', '#311CE1',
+'#E399DE', '#6A685A', '#D03471', '#6C659D', '#398566', '#74A0D7', '#F20EDA', '#6BA901', '#A38A9E', '#1D8A3E', '#1A2BB0', '#5C647F', '#EFC88C', '#A303DA', '#2F7A9B', '#9A5C61', '#CABFE5',
+'#1C4D5D', '#679DA1', '#B788A4', '#9D9875', '#F45B43', '#050526', '#2D648A', '#4C0391', '#B1CFF3', '#AE709B', '#4A14F4', '#A21169', '#BA6CDF', '#D91A91', '#D40549', '#1842D3',
+'#68579C', '#157715', '#7FF998', '#4EA807');
+declare variable $colors2 := ('#B54D1A', '#4E240A', '#351278', '#B0E9ED', '#FFFDF0', '#848DF1', '#58B94C', '#B15282', '#5B77EE', '#FD2F8D', '#311CE1',
+'#E399DE', '#6A685A', '#D03471', '#6C659D', '#398566', '#74A0D7', '#F20EDA', '#6BA901', '#A38A9E', '#1D8A3E', '#1A2BB0', '#5C647F', '#EFC88C',
+'#A303DA', '#2F7A9B', '#9A5C61', '#CABFE5', '#1C4D5D', '#679DA1', '#B788A4', '#9D9875', '#F45B43', '#050526', '#2D648A', '#4C0391', '#B1CFF3', '#AE709B',
+'#4A14F4', '#A21169', '#BA6CDF', '#D91A91', '#D40549', '#1842D3', '#68579C', '#157715', '#7FF998', '#4EA807');
+declare variable $colors3 := ('#B54D1A', '#EAE5C5', '#4E240A', '#351278', '#B0E9ED', '#EAE5C5', '#848DF1', '#58B94C', '#B15282', '#5B77EE', '#FD2F8D', '#311CE1',
+'#E399DE', '#6A685A', '#D03471', '#6C659D', '#398566', '#74A0D7', '#F20EDA', '#6BA901', '#A38A9E', '#1D8A3E', '#1A2BB0', '#5C647F', '#EFC88C', '#A303DA', '#2F7A9B', '#9A5C61', '#CABFE5',
+'#1C4D5D', '#679DA1', '#B788A4', '#9D9875', '#F45B43', '#050526', '#2D648A', '#4C0391', '#B1CFF3', '#AE709B', '#4A14F4', '#A21169', '#BA6CDF', '#D91A91', '#D40549', '#1842D3',
+'#68579C', '#157715', '#7FF998', '#4EA807');
+
+ All
+ Other witnesses
+ Done
+
+ {
+ let $sorted := for $song in $songs
+ order by $song/*[1]/number(replace(., '-.*', ''))
+ return
+ $song
+ for $song at $position in $sorted
+ let $margin := number('100')
+ let $current := index-of($authors, $song/*[3])
+ return
+ (if ((number($song/*[1]) + 3) mod 4 = 0) then
+
+
+ else
+ (if ((number($song/*[1]) + 2) mod 4 = 0)
+
+ then
+
+
+ else
+ (if ((number($song/*[1]) + 1) mod 4 = 0) then
+
+ else
+
+ ))
+
+ ,
+ if ($song/*[1]/@id = $b/*[1]/@id and (number($song/*[1]) + 3) mod 4 = 0) then
+
+ else
+ (if ($song/*[1]/@id = $b/*[1]/@id and (number($song/*[1]) + 2) mod 4 = 0)
+ then
+
+ else
+ (if ($song/*[1]/@id = $b/*[1]/@id and (number($song/*[1] + 1) mod 4 = 0))
+ then
+
+ else
+ (if ($song/*[1]/@id = $b/*[1]/@id and number($song/*[1] mod 4 = 0)) then
+
+ else
+ ()))),
+
+ if ($collection//tei:head/descendant::tei:rdg[@wit eq '#A']/substring(tei:idno, 2) = $song/*[1]/replace(., '-([a-z])', '$1')
+ and (number($song/*[1]) + 3) mod 4 = 0) then
+
+ else
+ (if ($collection//tei:head/descendant::tei:rdg[@wit eq '#A']/substring(tei:idno, 2) = $song/*[1]/replace(., '-([a-z])', '$1')
+ and (number($song/*[1]) + 2) mod 4 = 0) then
+
+ else
+ (if ($collection//tei:head/descendant::tei:rdg[@wit eq '#A']/substring(tei:idno, 2) = $song/*[1]/replace(., '-([a-z])', '$1')
+ and number($song/*[1] + 1) mod 4 = 0) then
+
+ else
+ (if ($collection//tei:head/descendant::tei:rdg[@wit eq '#A']/substring(tei:idno, 2) = $song/*[1]/replace(., '-([a-z])', '$1')
+ and number($song/*[1]) mod 4 = 0) then
+
+ else
+ ())))
+ )
+ }
+
+ {
+ for $author at $pos in distinct-values($realauthors)
+ let $current := $colors2[$pos]
+ return
+ if (($pos + 5) mod 6 = 0) then
+ ({replace($author, '\(.*?\)', '')} ,
+ )
+ else
+ (if (($pos + 4) mod 6 = 0)
+ then
+ ({replace($author, '\(.*?\)', '')} ,
+ )
+ else
+ (if (($pos + 3) mod 6 = 0) then
+ ({replace($author, '\(.*?\)', '')} ,
+ )
+ else
+ (if (($pos + 2) mod 6 = 0) then
+ ({replace($author, '\(.*?\)', '')} ,
+ )
+ else
+ (if (($pos + 1) mod 6 = 0)
+ then
+ ({replace($author, '\(.*?\)', '')} ,
+ )
+ else
+ (if ($pos mod 6 = 0)
+ then
+ ({replace($author, '\(.*?\)', '')} ,
+ )
+ else
+ ())))))
+ }
+
+
\ No newline at end of file
diff --git a/XQuery/graphs/corpus-composition.xquery b/XQuery/graphs/corpus-composition.xquery
new file mode 100644
index 0000000..cac46c6
--- /dev/null
+++ b/XQuery/graphs/corpus-composition.xquery
@@ -0,0 +1,172 @@
+xquery version "3.0";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+declare variable $poets := doc('/db/VTLGP/ancillary/corpus-autores.xml')//tei:person;
+declare variable $songs := collection('/db/VTLGP/edition')//tei:div[@type eq 'poem'];
+declare variable $periods := $poets[@xml:id = $songs//tei:name/substring(@ref, 2)]/tei:floruit/@period;
+declare variable $witnesses := $songs//tei:title//tei:rdg/@wit;
+declare variable $copyists := $songs//tei:title//tei:rdg/@hand;
+declare variable $count := count($songs);
+
+
Cantigas segundo o período Songs by period
+
+
+ {
+
+ for $period at $pos in distinct-values($periods)
+ let $sum := count($songs[.//tei:name/substring(@ref, 2) = $poets[./tei:floruit/@period eq $period]/@xml:id])
+ let $percentage := round-half-to-even((100 * $sum div $count), 2)
+ return
+
+
+ {' (' || $percentage || '%)'}
+ Período {$period}
+ Period {$period}
+
+ }
+
Cantigas por testemunho testemuño Songs by witness
+
+ {
+
+ for $wit at $pos in distinct-values($witnesses)
+ let $sum := count($songs[.//tei:title//tei:rdg/@wit = $wit])
+ let $percentage := round-half-to-even((100 * $sum div $count), 2)
+ return
+
+
+ {' (' || $percentage || '%)'}
+ Ms. {substring($wit, 2)}
+
+
+ {
+ let $hand := $songs/tei:head//tei:rdg[@wit = $wit]/@hand
+ let $distinctHands := for $distinct-hand in distinct-values($hand) order by $distinct-hand return $distinct-hand
+ for $h in 1 to count($distinctHands)
+ let $x := count($songs[.//tei:head//tei:rdg[@wit = $wit][@hand = $distinctHands[position() lt $h]]])
+ let $div := $songs[tei:head//tei:rdg[@wit = $wit][@hand = $distinctHands[$h]]]
+ let $conta := count($div)
+ order by $h
+
+
+ return
+
+ ( ,
+ {substring($distinctHands[$h], 2)} )
+
+
+ }
+
+ }
+
Cantigas segundo o copista Songs by scribe
+
+ {
+ let $variables :=
+ {
+
+ for $hand in distinct-values($copyists)
+ let $sum := count($songs[.//tei:title//tei:rdg/@hand = $hand])
+ let $percentage := round-half-to-even((100 * $sum div $count), 2)
+ order by $sum descending
+ return
+ -
+
{$sum}
+ {$percentage}
+ {$hand}
+
+ }
+ for $thing at $pos in $variables/item
+ return
+
+
+ {' (' || $thing/percentage || '%)'}
+ Copista {substring($thing/hand, 2)}
+ Copyist {substring($thing/hand, 2)}
+
+ }
+
\ No newline at end of file
diff --git a/XQuery/graphs/corpus.svg b/XQuery/graphs/corpus.svg
new file mode 100644
index 0000000..870dbf9
--- /dev/null
+++ b/XQuery/graphs/corpus.svg
@@ -0,0 +1,4467 @@
+
+
+ All
+ Other witnesses
+ Done
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Vasco Praga de Sandin
+
+ Johan Soarez Somesso
+
+ Pai Soarez de Taveirós
+
+ Martin Soarez
+
+ Dubidoso/Anónimo
+
+ Airas Carpancho
+
+ Nuno Rodriguez de Candarei
+
+ Nuno Fernandez Torneol
+
+ Pero Garcia Burgalês
+
+ Johan Nunez Camanez
+
+ Fernan Garcia Esgaravunha
+
+ Roi Queimado
+
+ Vasco Gil
+
+ Johan Soarez Coelho
+
+ Roi Paez de Ribela
+
+ Johan Lopez de Ulhoa
+
+ Fernan Gonçalvez de Seabra
+
+ Pero Gomez Barroso
+
+ Afonso Lopez de Baian
+
+ Johan Garcia de Guilhade
+
+ Estevan Faian
+
+ Johan Vasquiz de Talaveira
+
+ Pai Gomez Charinho
+
+ Fernan Velho
+
+ Bonifaci Calvo
+
+ Pedr' Eanes Solaz
+
+ Fernan Padron
+
+ Pero da Ponte
+
+ Vasco Rodriguez de Calvelo
+
+ Martin Moxa
+
+ Roi Fernandiz, clérigo de Santiago
+
+
+
diff --git a/XQuery/graphs/evol-lingua-arcaismos.xquery b/XQuery/graphs/evol-lingua-arcaismos.xquery
new file mode 100644
index 0000000..31f7d56
--- /dev/null
+++ b/XQuery/graphs/evol-lingua-arcaismos.xquery
@@ -0,0 +1,159 @@
+xquery version "3.0";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+(:declare variable $songs := collection('/db/VTLGP/edition')//tei:div[@type eq 'poem']; (\:corpus of songs:\)
+declare variable $fs := doc('/db/VTLGP/ancillary/feature-library.xml'); (\:variants file:\):)
+declare variable $songs := collection('../../edition')//tei:div[@type eq 'poem'];
+declare variable $names := doc('../../ancillary/corpus-autores.xml')//tei:person;
+declare variable $authors := $songs//tei:name;
+declare variable $fs := doc('../../ancillary/feature-library.xml')//tei:fs[@type];
+declare variable $ling-features := for $i in $fs[@type eq 'arcaico']/@xml:id
+return
+ concat('#', $i);
+declare variable $legendWidth := number('22');
+declare variable $legendHeight := number('22');
+declare variable $increased := number('15');
+declare variable $sep := number('9');
+
+
+
+
+ Número ocorrências
+
+ {
+ for $section at $pos in
+ for $i in $songs
+ order by number($i//tei:title//tei:rdg[@wit eq '#A']/substring(tei:idno, 2)) descending
+ return
+ $i
+ let $ling := $section/descendant::tei:rdg[tokenize(@ana, '\s+') = $ling-features]
+ let $song := $section//tei:title//tei:rdg[@wit eq '#A']/tei:idno/string()
+ let $y := count($ling) * $increased
+ let $dist-ling := count(distinct-values($ling/string())) * $increased
+ let $x := $sep * $pos
+ return
+
+ ( ,
+ ,
+
+ {$song} ,
+
+
+
+ )
+
+ }
+
+
+
+
+
+
+
+ {
+ for $i in 1 to 9
+ return
+
+ }
+
+
+
+
+ {
+ for $poet at $pos in
+ for $i in distinct-values($authors/@ref)
+ order by number($songs[descendant::tei:name/@ref = $i][1]//tei:title//tei:rdg[@wit eq '#A']/substring(tei:idno, 2)) descending
+ return
+ $i
+ let $name := $names[@xml:id = substring($poet, 2)]/tei:persName
+
+ let $x := $sep * count($songs//tei:name/@ref = $poet) * $pos
+ return
+
+ {$name/string()}
+ }
+
+
+
+
diff --git a/XQuery/graphs/evol-lingua.xquery b/XQuery/graphs/evol-lingua.xquery
new file mode 100644
index 0000000..97d11a3
--- /dev/null
+++ b/XQuery/graphs/evol-lingua.xquery
@@ -0,0 +1,171 @@
+xquery version "3.0";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+(:declare variable $songs := collection('/db/VTLGP/edition')//tei:div[@type eq 'poem']; (\:corpus of songs:\)
+declare variable $fs := doc('/db/VTLGP/ancillary/feature-library.xml'); (\:variants file:\):)
+declare variable $songs := collection('../../edition')//tei:div[@type eq 'poem'];
+declare variable $names := doc('../../ancillary/corpus-autores.xml')//tei:person;
+declare variable $authors := $songs//tei:name;
+declare variable $fs := doc('../../ancillary/feature-library.xml');
+declare variable $ling-features := $fs//tei:fs[tei:f/tei:fs[@type eq 'linguistic']]/@xml:id;
+declare variable $legendWidth := number('22');
+declare variable $legendHeight := number('22');
+declare variable $increased := number('12');
+declare variable $sep := number('9');
+
+
+
+
+ Número ocorrências
+
+ Formas únicas
+
+ {
+ for $section at $pos in
+ for $i in $songs
+ order by number($i//tei:title//tei:rdg[@wit eq '#A']/substring(tei:idno, 2)) descending
+ return
+ $i
+ let $ling := $section/descendant::tei:rdg[tokenize(replace(@ana, '#', ''), '\s+') = $ling-features]
+ let $song := $section//tei:title//tei:rdg[@wit eq '#A']/tei:idno/string()
+ let $y := count($ling) * $increased
+ let $dist-ling := count(distinct-values($ling/string())) * $increased
+ let $x := $sep * $pos
+ return
+
+ ( ,
+ ,
+
+ {$song} ,
+
+
+
+ )
+
+ }
+
+
+
+
+
+
+
+ {
+ for $i in 1 to 16
+ return
+
+ }
+
+
+
+
+ {
+ for $poet at $pos in
+ for $i in distinct-values($authors/@ref)
+ order by number($songs[descendant::tei:name/@ref = $i][1]//tei:title//tei:rdg[@wit eq '#A']/substring(tei:idno, 2)) descending
+ return
+ $i
+ let $name := $names[@xml:id = substring($poet, 2)]/tei:persName
+
+ let $x := $sep * count($songs//tei:name/@ref = $poet) * $pos
+ return
+
+ {$name/string()}
+ }
+
+
+
+
diff --git a/XQuery/graphs/grafos-tese.xquery b/XQuery/graphs/grafos-tese.xquery
new file mode 100644
index 0000000..318a606
--- /dev/null
+++ b/XQuery/graphs/grafos-tese.xquery
@@ -0,0 +1,166 @@
+xquery version "3.0";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+declare variable $increase := number('11');
+declare variable $search := request:get-parameter("phenomenon", ("oer"));
+let $values := tokenize($search, ',')
+let $songs := collection('/db/VTLGP/edition')//tei:div[@type eq 'poem']
+let $readings := $songs//tei:rdg
+let $ling-features := doc('/db/VTLGP/ancillary/feature-library.xml')//tei:fs[@xml:id]
+let $poets := doc('/db/VTLGP/ancillary/corpus-autores.xml')//tei:person
+return
+
+ {
+ for $result in $values
+ return
+ ({transform:transform($ling-features[@xml:id = $result]//tei:string[@xml:lang eq 'pt']/text(), 'xmldb:exist:///db/VTLGP/xslt/string.xsl', ())} ,
+ Testemunho ,
+
+ {
+
+ let $fen := $readings[some $ana in tokenize(@ana, '\s+') satisfies $ana = concat('#', $result)]
+ for $wit at $pos in
+ for $i in distinct-values($fen/tokenize(./@wit, '\s+'))
+ order by count($fen[./tokenize(@wit, '\s+') = $i]) descending
+ return
+ $i
+ let $count := count($fen[contains(@wit, $wit)])
+ let $sum := count($fen)
+ let $percentage := round-half-to-even((100 * $count div $sum), 2)
+ order by $count descending
+ return
+
+
+ {' (' || $percentage || '%)'}
+ Ms. {substring($wit, 2)}
+
+ {
+ let $hand := $songs[.//tei:rdg[. intersect $fen[contains(@wit, $wit)]]]/tei:head//tei:rdg[@wit = $wit]/@hand
+ let $distinctHands := distinct-values($hand)
+ for $h in 1 to count($distinctHands)
+ let $x := count($songs[tei:head//tei:rdg[@wit = $wit][@hand = $distinctHands[position() lt $h]]]
+ //tei:rdg[. intersect $fen][contains(@wit, $wit)])
+ let $div := $songs[tei:head//tei:rdg[@wit = $wit][@hand = $distinctHands[$h]]][.//tei:rdg[. intersect $fen]]
+ let $conta := count($div//tei:rdg[. intersect $fen[contains(@wit, $wit)]])
+ order by $h descending
+ return
+
+
+ {substring($distinctHands[$h], 2)}
+
+ }
+
+ } ,
+ Período ,
+
+ {
+
+ let $fen := $readings[some $ana in tokenize(@ana, '\s+') satisfies $ana = concat('#', $result)]
+ for $period at $pos in
+ for $i in distinct-values($poets[@xml:id = $fen/ancestor::tei:div[1]//tei:name/substring(@ref, 2)]/tei:floruit/@period)
+ order by count($fen[ancestor::tei:div[1]//tei:name/substring(@ref, 2) = $poets/tei:floruit[@period = $i]/../@xml:id]) descending
+ return
+ $i
+ let $count := count($fen[ancestor::tei:div[1]//tei:name/substring(@ref, 2) = $poets/tei:floruit[@period = $period]/../@xml:id])
+ let $sum := count($fen)
+ let $percentage := round-half-to-even((100 * $count div $sum), 2)
+ order by $count descending
+ return
+
+
+ {' (' || $percentage || '%)'}
+ P°. {$period}
+
+ } ,
+
+ {
+
+ let $fen := $readings[some $ana in tokenize(@ana, '\s+') satisfies $ana = concat('#', $result)]
+ for $nationality at $pos in
+ for $i in distinct-values($poets[@xml:id = $fen/ancestor::tei:div[1]//tei:name/substring(@ref, 2)]/tei:nationality/@key)
+ order by count($fen[ancestor::tei:div[1]//tei:name/substring(@ref, 2) = $poets/tei:nationality[@key = $i]/../@xml:id]) descending
+ return
+ $i
+ let $count := count($fen[ancestor::tei:div[1]//tei:name/substring(@ref, 2) = $poets/tei:nationality[@key = $nationality]/../@xml:id])
+ let $sum := count($fen)
+ let $percentage := round-half-to-even((100 * $count div $sum), 2)
+ order by $count descending
+ return
+
+
+ {' (' || $percentage || '%)'}
+ {upper-case($nationality)}
+
+ }
+ )
+ }
+
+
diff --git a/XQuery/graphs/image.pdf b/XQuery/graphs/image.pdf
new file mode 100644
index 0000000..e0078ee
Binary files /dev/null and b/XQuery/graphs/image.pdf differ
diff --git a/XQuery/graphs/image.pdf_tex b/XQuery/graphs/image.pdf_tex
new file mode 100644
index 0000000..8bd3335
--- /dev/null
+++ b/XQuery/graphs/image.pdf_tex
@@ -0,0 +1,135 @@
+%% Creator: Inkscape inkscape 0.91, www.inkscape.org
+%% PDF/EPS/PS + LaTeX output extension by Johan Engelen, 2010
+%% Accompanies image file 'image.pdf' (pdf, eps, ps)
+%%
+%% To include the image in your LaTeX document, write
+%% \input{.pdf_tex}
+%% instead of
+%% \includegraphics{.pdf}
+%% To scale the image, write
+%% \def\svgwidth{}
+%% \input{.pdf_tex}
+%% instead of
+%% \includegraphics[width=]{.pdf}
+%%
+%% Images with a different path to the parent latex file can
+%% be accessed with the `import' package (which may need to be
+%% installed) using
+%% \usepackage{import}
+%% in the preamble, and then including the image with
+%% \import{}{.pdf_tex}
+%% Alternatively, one can specify
+%% \graphicspath{{/}}
+%%
+%% For more information, please see info/svg-inkscape on CTAN:
+%% http://tug.ctan.org/tex-archive/info/svg-inkscape
+%%
+\begingroup%
+ \makeatletter%
+ \providecommand\color[2][]{%
+ \errmessage{(Inkscape) Color is used for the text in Inkscape, but the package 'color.sty' is not loaded}%
+ \renewcommand\color[2][]{}%
+ }%
+ \providecommand\transparent[1]{%
+ \errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package 'transparent.sty' is not loaded}%
+ \renewcommand\transparent[1]{}%
+ }%
+ \providecommand\rotatebox[2]{#2}%
+ \ifx\svgwidth\undefined%
+ \setlength{\unitlength}{576.8921875bp}%
+ \ifx\svgscale\undefined%
+ \relax%
+ \else%
+ \setlength{\unitlength}{\unitlength * \real{\svgscale}}%
+ \fi%
+ \else%
+ \setlength{\unitlength}{\svgwidth}%
+ \fi%
+ \global\let\svgwidth\undefined%
+ \global\let\svgscale\undefined%
+ \makeatother%
+ \begin{picture}(1,0.85713589)%
+ \put(0,0){\includegraphics[width=\unitlength,page=1]{image.pdf}}%
+ \put(0.55296023,0.00346144){\color[rgb]{0,0,0}\makebox(0,0)[b]{\smash{Índice de formas únicas por verso}}}%
+ \put(0.01213127,0.46385942){\rotatebox{90}{\makebox(0,0)[b]{\smash{Autores}}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=2]{image.pdf}}%
+ \put(0.9551151,0.4056163){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{Ms. B}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=3]{image.pdf}}%
+ \put(0.9551151,0.44721853){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{Ms. A}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=4]{image.pdf}}%
+ \put(0.26867834,0.12549464){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Afonso Lopez de Baian}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=5]{image.pdf}}%
+ \put(0.26867834,0.09775982){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Airas Carpancho}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=6]{image.pdf}}%
+ \put(0.26867834,0.15322945){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Bonifaci Calvo}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=7]{image.pdf}}%
+ \put(0.26867834,0.18096427){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Estevan Faian}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=8]{image.pdf}}%
+ \put(0.26867834,0.20869909){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Fernan Garcia Esgaravunha}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=9]{image.pdf}}%
+ \put(0.26867834,0.23643391){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Fernan Gonçalvez de Seabra}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=10]{image.pdf}}%
+ \put(0.26867834,0.26416873){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Fernan Padron}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=11]{image.pdf}}%
+ \put(0.26867834,0.29190355){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Fernan Velho}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=12]{image.pdf}}%
+ \put(0.26867834,0.31963836){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Johan Garcia de Guilhade}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=13]{image.pdf}}%
+ \put(0.26867834,0.34737318){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Johan Lopez de Ulhoa}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=14]{image.pdf}}%
+ \put(0.26867834,0.375108){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Johan Nunez Camanez}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=15]{image.pdf}}%
+ \put(0.26867834,0.40284282){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Johan Soarez Coelho}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=16]{image.pdf}}%
+ \put(0.26867834,0.45831246){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Johan Soarez Somesso}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=17]{image.pdf}}%
+ \put(0.26867834,0.48604727){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Johan Vasquiz de Talaveira}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=18]{image.pdf}}%
+ \put(0.26867834,0.51378209){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Martin Soarez}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=19]{image.pdf}}%
+ \put(0.26867834,0.54151691){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Nuno Fernandez Torneol}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=20]{image.pdf}}%
+ \put(0.26867834,0.56925173){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Pai Gomez Charinho}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=21]{image.pdf}}%
+ \put(0.26867834,0.59698655){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Pai Soarez de Taveirós}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=22]{image.pdf}}%
+ \put(0.26867834,0.62472137){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Pedr’ Eanes Solaz}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=23]{image.pdf}}%
+ \put(0.26867834,0.65245618){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Pero Garcia de Burgalês}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=24]{image.pdf}}%
+ \put(0.26867834,0.680191){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Pero Gomez Barroso}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=25]{image.pdf}}%
+ \put(0.26867834,0.70792582){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Pero da Ponte}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=26]{image.pdf}}%
+ \put(0.26867834,0.43057764){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Roi Fernandiz de Santiago}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=27]{image.pdf}}%
+ \put(0.26867834,0.73566064){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Roi Paez de Ribela}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=28]{image.pdf}}%
+ \put(0.26867834,0.76339546){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Roi Queimado}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=29]{image.pdf}}%
+ \put(0.26867834,0.79113028){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Vasco Fernandez Praga de Sandin}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=30]{image.pdf}}%
+ \put(0.26867834,0.81886509){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Vasco Gil}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=31]{image.pdf}}%
+ \put(0.26867834,0.84659991){\color[rgb]{0,0,0}\makebox(0,0)[rb]{\smash{Vasco Rodriguez de Calvelo}}}%
+ \put(0,0){\includegraphics[width=\unitlength,page=32]{image.pdf}}%
+ \put(0.30334687,0.04506366){\color[rgb]{0,0,0}\makebox(0,0)[b]{\smash{1}}}%
+ \put(0.33108168,0.04506366){\color[rgb]{0,0,0}\makebox(0,0)[b]{\smash{2}}}%
+ \put(0.3588165,0.04506366){\color[rgb]{0,0,0}\makebox(0,0)[b]{\smash{3}}}%
+ \put(0.38655132,0.04506366){\color[rgb]{0,0,0}\makebox(0,0)[b]{\smash{4}}}%
+ \put(0.41428614,0.04506366){\color[rgb]{0,0,0}\makebox(0,0)[b]{\smash{5}}}%
+ \put(0.44202096,0.04506366){\color[rgb]{0,0,0}\makebox(0,0)[b]{\smash{6}}}%
+ \put(0.46975578,0.04506366){\color[rgb]{0,0,0}\makebox(0,0)[b]{\smash{7}}}%
+ \put(0.49749059,0.04506366){\color[rgb]{0,0,0}\makebox(0,0)[b]{\smash{8}}}%
+ \put(0.52522541,0.04506366){\color[rgb]{0,0,0}\makebox(0,0)[b]{\smash{9}}}%
+ \put(0.55296023,0.04506366){\color[rgb]{0,0,0}\makebox(0,0)[b]{\smash{10}}}%
+ \put(0.58069505,0.04506366){\color[rgb]{0,0,0}\makebox(0,0)[b]{\smash{11}}}%
+ \put(0.60842987,0.04506366){\color[rgb]{0,0,0}\makebox(0,0)[b]{\smash{12}}}%
+ \put(0.63616469,0.04506366){\color[rgb]{0,0,0}\makebox(0,0)[b]{\smash{13}}}%
+ \put(0.6638995,0.04506366){\color[rgb]{0,0,0}\makebox(0,0)[b]{\smash{14}}}%
+ \put(0.69163432,0.04506366){\color[rgb]{0,0,0}\makebox(0,0)[b]{\smash{15}}}%
+ \put(0.71936914,0.04506366){\color[rgb]{0,0,0}\makebox(0,0)[b]{\smash{16}}}%
+ \put(0.74710396,0.04506366){\color[rgb]{0,0,0}\makebox(0,0)[b]{\smash{17}}}%
+ \put(0.77483878,0.04506366){\color[rgb]{0,0,0}\makebox(0,0)[b]{\smash{18}}}%
+ \end{picture}%
+\endgroup%
diff --git a/XQuery/graphs/ling-evol-prova.xquery b/XQuery/graphs/ling-evol-prova.xquery
new file mode 100644
index 0000000..abd5e36
--- /dev/null
+++ b/XQuery/graphs/ling-evol-prova.xquery
@@ -0,0 +1,512 @@
+xquery version "3.0";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+declare variable $songs := collection('/db/VTLGP/edition')//tei:div[@type eq 'poem']; (:corpus of songs:)
+declare variable $fs := doc('/db/VTLGP/ancillary/feature-library.xml'); (:variants file:)
+declare variable $ling-features := $fs//tei:fs[tei:f/tei:fs[@type eq 'linguistic']]/@xml:id;
+(: Since there is a gap in my edition regarding the location of the songs, I manually create the intervals :)
+declare variable $sections :=
+
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) = 1][descendant::tei:locus/number(replace(@to, 'v|r', '')) = 1]}
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) > 1][descendant::tei:locus/number(replace(@to, 'v|r', '')) <= 5]}
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) > 5][descendant::tei:locus/number(replace(@to, 'v|r', '')) <= 10]}
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) > 10][descendant::tei:locus/number(replace(@to, 'v|r', '')) <= 15]}
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) > 15][descendant::tei:locus/number(replace(@to, 'v|r', '')) <= 20]}
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) > 20][descendant::tei:locus/number(replace(@to, 'v|r', '')) <= 25]}
+ (: Gap in my edition :)
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) >= 51][descendant::tei:locus/number(replace(@to, 'v|r', '')) <= 55]}
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) > 55][descendant::tei:locus/number(replace(@to, 'v|r', '')) <= 60]}
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) > 60][descendant::tei:locus/number(replace(@to, 'v|r', '')) <= 65]}
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) > 65][descendant::tei:locus/number(replace(@to, 'v|r', '')) <= 70]}
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) > 70][descendant::tei:locus/number(replace(@to, 'v|r', '')) <= 75]}
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) > 75][descendant::tei:locus/number(replace(@to, 'v|r', '')) <= 80]}
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) > 80][descendant::tei:locus/number(replace(@to, 'v|r', '')) <= 85]}
+ ;
+declare variable $legendWidth := number('22');
+declare variable $legendHeight := number('22');
+declare variable $increased := number('2');
+
+
+
+
+ Número ocorrências
+ Folio Ms. A
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 20
+ 40
+ 60
+ 80
+ 100
+ 120
+ 140
+ 160
+ 180
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+ 5
+ 10
+ 15
+ 20
+ 25
+ 55
+ 60
+ 65
+ 70
+ 75
+ 80
+ 85
+
+ Variantes de língua
+
+ Número de fenómenos únicos
+
+
+ {
+ for $section at $pos in $sections/*
+ let $ling := $section/descendant::tei:rdg[tokenize(replace(@ana, '#', ''), '\s+') = $ling-features]
+ let $y2 := count($section/following-sibling::*[1]/descendant::tei:rdg[tokenize(replace(@ana, '#', ''), '\s+') = $ling-features]) * $increased
+ let $y := count($ling) * $increased
+ let $dist-ling := count(distinct-values($ling)) * $increased
+ let $yControl := ($y - $y2) div 2 - $y2
+ let $x := 40 * $pos (:40 is the interval between the sections:)
+ return
+
+ (
+ ,
+
+ ,
+
+
+ )
+
+ }
+ {
+ for $section at $pos in $sections/*[position() mod 2 = 1]
+ let $ling := $section/descendant::tei:rdg[tokenize(replace(@ana, '#', ''), '\s+') = $ling-features]
+ let $y2 := count($section/following-sibling::*[2]/descendant::tei:rdg[tokenize(replace(@ana, '#', ''), '\s+') = $ling-features]) * $increased
+ let $y := count($ling) * $increased
+ let $controlY := count($section/following-sibling::*[1]/descendant::tei:rdg[tokenize(replace(@ana, '#', ''), '\s+') = $ling-features]) * $increased
+ let $x := (($pos - 1) + $pos) * 40
+ return
+
+ }
+
+
+
+
+
+
\ No newline at end of file
diff --git a/XQuery/graphs/ling-evol.xquery b/XQuery/graphs/ling-evol.xquery
new file mode 100644
index 0000000..992fe71
--- /dev/null
+++ b/XQuery/graphs/ling-evol.xquery
@@ -0,0 +1,501 @@
+xquery version "3.0";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+declare variable $songs := collection('/db/VTLGP/edition')//tei:div[@type eq 'poem']; (:corpus of songs:)
+declare variable $fs := doc('/db/VTLGP/ancillary/feature-library.xml'); (:variants file:)
+declare variable $ling-features := $fs//tei:fs[tei:f/tei:fs[@type eq 'linguistic']]/@xml:id;
+(: Since there is a gap in my edition regarding the location of the songs, I manually create the intervals :)
+declare variable $sections :=
+
+- {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) = 1][descendant::tei:locus/number(replace(@to, 'v|r', '')) = 1]}
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) > 1][descendant::tei:locus/number(replace(@to, 'v|r', '')) <= 5]}
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) > 5][descendant::tei:locus/number(replace(@to, 'v|r', '')) <= 10]}
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) > 10][descendant::tei:locus/number(replace(@to, 'v|r', '')) <= 15]}
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) > 15][descendant::tei:locus/number(replace(@to, 'v|r', '')) <= 20]}
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) > 20][descendant::tei:locus/number(replace(@to, 'v|r', '')) < 25]}
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) >= 25][descendant::tei:locus/number(replace(@to, 'v|r', '')) <= 30]}
+ (: Gap in my edition :)
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) >= 51][descendant::tei:locus/number(replace(@to, 'v|r', '')) <= 55]}
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) > 55][descendant::tei:locus/number(replace(@to, 'v|r', '')) <= 60]}
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) > 60][descendant::tei:locus/number(replace(@to, 'v|r', '')) <= 65]}
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) > 65][descendant::tei:locus/number(replace(@to, 'v|r', '')) <= 70]}
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) > 70][descendant::tei:locus/number(replace(@to, 'v|r', '')) <= 75]}
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) > 75][descendant::tei:locus/number(replace(@to, 'v|r', '')) <= 80]}
+ - {$songs[descendant::tei:rdg[@wit eq '#A']/tei:locus/number(replace(@from, 'v|r', '')) > 80][descendant::tei:locus/number(replace(@to, 'v|r', '')) <= 85]}
+ ;
+declare variable $legendWidth := number('22');
+declare variable $legendHeight := number('22');
+declare variable $increased := number('2');
+
+
+
+
+ Número ocorrências
+ Folio Ms. A
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 20
+ 40
+ 60
+ 80
+ 100
+ 120
+ 140
+ 160
+ 180
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+ 5
+ 10
+ 15
+ 20
+ 25
+ 30
+ 55
+ 60
+ 65
+ 70
+ 75
+ 80
+ 85
+
+ Variantes de língua
+
+ Número de fenómenos únicos
+
+ {
+ for $section at $pos in $sections/*
+ let $ling := $section/descendant::tei:rdg[tokenize(replace(@ana, '#', ''), '\s+') = $ling-features]
+ let $y := count($ling) * $increased
+ let $dist-ling := count(distinct-values($ling)) * $increased
+ let $x := 40 * $pos (:40 is the interval between the sections:)
+ return
+
+ (
+ ,
+
+
+ )
+
+ }
+
+
+
+
+
+
\ No newline at end of file
diff --git a/XQuery/graphs/radar-plot-initial.svg b/XQuery/graphs/radar-plot-initial.svg
new file mode 100644
index 0000000..88d26d2
--- /dev/null
+++ b/XQuery/graphs/radar-plot-initial.svg
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+ 10
+ 20
+ 40
+ 60
+ 80
+ 30
+ 50
+ 70
+ 90
+ 10
+ 30
+ 50
+ 70
+ 90
+ 20
+ 40
+ 60
+ 80
+ Variantes de língua
+ Erros de cópia
+ Outras
+ Equipolentes
+
+
\ No newline at end of file
diff --git a/XQuery/graphs/radar-plot.xquery b/XQuery/graphs/radar-plot.xquery
new file mode 100644
index 0000000..7b7debc
--- /dev/null
+++ b/XQuery/graphs/radar-plot.xquery
@@ -0,0 +1,298 @@
+xquery version "3.0";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+declare variable $songs := collection('/db/VTLGP/edition')//tei:div[@type eq 'poem'];
+declare variable $fs := doc('/db/VTLGP/ancillary/feature-library.xml');
+declare variable $ling-features := $fs//tei:fvLib[@corresp eq '#linguistic']/tei:fs/@xml:id;
+declare variable $equipolent := $fs//tei:fvLib[@n eq 'equipolent readings']/tei:fs/@xml:id;
+declare variable $scribalError := $fs//tei:fvLib[@corresp eq '#scribal']/tei:fs/@xml:id;
+declare variable $significant := $equipolent | $scribalError | $ling-features;
+declare variable $poets := doc('/db/VTLGP/ancillary/corpus-autores.xml')//tei:person[concat('#', @xml:id) = $songs//tei:name[@role eq 'author']/@ref];
+declare variable $periods := $poets[@xml:id = $songs//tei:name/substring(@ref, 2)]/tei:floruit/@period;
+declare variable $fixedWidth := number('400');
+declare variable $radio := number("3.5");
+declare variable $color := ('#2B3966', '#BD6D03', '#B3A8CC', '#CF4205', '#6C659D', '#009CA2', '#BC9650', '#233310', '#FFC938', '#5C647F',
+'#22461E', '#EDDF81', '#6A643A', '#B0E9ED', '#B788A4', '#889BB7', '#73843A', '#3d4144', '#6A685A', '#2B6273',
+'#73473C', '#490301', '#f2cf95', '#1B0CA2', '#630C03', '#025256', '#E25C05', '#11894A', '#009CA2', '#895F11');
+declare variable $max := number('320');
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+ 10
+ 20
+ 40
+ 60
+ 80
+ 30
+ 50
+ 70
+ 10
+ 30
+ 50
+ 70
+ 20
+ 40
+ 60
+ 80
+ Variantes de língua
+ Erros de cópia
+ Outras
+ Equipolentes
+
+ {
+ for $period at $pos in distinct-values($periods)
+ let $booksong := $songs[.//tei:name/substring(@ref, 2) = $poets[./tei:floruit/@period eq $period]/@xml:id]
+ let $total := sum($booksong/descendant::tei:rdg[tokenize(replace(@ana, '#', ''), '\s+') = $significant]/string-length(.))
+ let $errors := sum($booksong/descendant::tei:rdg[tokenize(replace(@ana, '#', ''), '\s+') = $scribalError]/string-length(.)) * $fixedWidth div $total
+ let $equip := sum($booksong/descendant::tei:rdg[contains(@ana, '#equip')]/string-length(.)) * $fixedWidth div $total
+ let $ling := sum($booksong/descendant::tei:rdg[tokenize(replace(@ana, '#', ''), '\s+') = $ling-features]/string-length(.)) * $fixedWidth div $total
+ let $outras := $total * $fixedWidth div $total - $errors - $equip - $ling
+ return
+
+
+
+
+
+
+
+
+ }
+ {
+
+ let $sortedAuthors := for $author in $poets
+ order by $songs[descendant::tei:name[@role eq 'author']/@ref = concat('#', $author/@xml:id)][1]/descendant::tei:title/descendant::tei:rdg[@wit eq
+ '#A']/tei:locus/number(replace(@from, '(v|r)', ''))
+ return
+ $author
+ for $author at $pos in $sortedAuthors
+ let $booksong := $songs[descendant::tei:name[@role eq 'author']/@ref = concat('#', $author/@xml:id)]
+ let $total := sum($booksong/descendant::tei:rdg[tokenize(replace(@ana, '#', ''), '\s+') = $significant]/string-length(.))
+ let $errors := sum($booksong/descendant::tei:rdg[tokenize(replace(@ana, '#', ''), '\s+') = $scribalError]/string-length(.)) * $fixedWidth div $total
+ let $equip := sum($booksong/descendant::tei:rdg[contains(@ana, '#equip')]/string-length(.)) * $fixedWidth div $total
+ let $ling := sum($booksong/descendant::tei:rdg[tokenize(replace(@ana, '#', ''), '\s+') = $ling-features]/string-length(.)) * $fixedWidth div $total
+ let $outras := $total * $fixedWidth div $total - $errors - $equip - $ling
+ let $no := $pos + 2
+ return
+
+
+
+
+
+
+
+
+ }
+
\ No newline at end of file
diff --git a/XQuery/graphs/resultados-tese-autor.xquery b/XQuery/graphs/resultados-tese-autor.xquery
new file mode 100644
index 0000000..bdeb60f
--- /dev/null
+++ b/XQuery/graphs/resultados-tese-autor.xquery
@@ -0,0 +1,163 @@
+xquery version "3.0";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+(:declare variable $songs := collection('/db/VTLGP/edition')//tei:div[@type eq 'poem']; (\:corpus of songs:\)
+declare variable $fs := doc('/db/VTLGP/ancillary/feature-library.xml'); (\:variants file:\):)
+declare variable $songs := collection('../../edition')//tei:div[@type eq 'poem'];
+declare variable $fs := doc('../../ancillary/feature-library.xml');
+declare variable $ling-features := $fs//tei:fs[tei:f/tei:fs[@type eq 'linguistic']]/@xml:id;
+declare variable $legendWidth := number('22');
+declare variable $legendHeight := number('22');
+declare variable $increased := number('20');
+declare variable $sep := number('20');
+declare variable $authors := doc('../../ancillary/corpus-autores.xml')//tei:person[concat('#', @xml:id) = $songs//tei:name/@ref];
+
+
+
+
+
+
+
+ Índice de formas únicas por verso
+ Autores
+
+ Ms. B
+
+ Ms. A
+
+ { let $orderedAuthors := for $i in $authors order by $i/tei:nationality/@key descending return $i
+ for $author at $pos in $orderedAuthors
+ let $booksong := $songs[descendant::tei:name[substring(@ref, 2) = $author/@xml:id]]
+ let $lines := count($booksong//tei:l)
+ let $ling-A := distinct-values($booksong/descendant::tei:rdg[contains(@wit, '#A')]
+ [tokenize(replace(@ana, '#', ''), '\s+') = $ling-features]/string())
+ let $ling-B := distinct-values($booksong/descendant::tei:rdg[contains(@wit, '#B')]
+ [tokenize(replace(@ana, '#', ''), '\s+') = $ling-features]/string())
+ let $x-A := count($ling-A) * $increased * 100 div $lines
+ let $x-B := count($ling-B) * $increased * 100 div $lines
+ let $y := $sep * $pos
+ return
+
+ ( ,
+
+ ,
+ ,
+ ,
+
+
+ {$author/tei:persName/text()}
+
+ )
+
+ }
+ {
+ for $i in 1 to 36
+ return
+
+ }
+
+ {
+ for $i in 1 to 18
+ return
+ {$i}
+ }
+
+
+
diff --git a/XQuery/graphs/resultados-tese.xquery b/XQuery/graphs/resultados-tese.xquery
new file mode 100644
index 0000000..b3bc093
--- /dev/null
+++ b/XQuery/graphs/resultados-tese.xquery
@@ -0,0 +1,182 @@
+xquery version "3.0";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+(:declare variable $songs := collection('/db/VTLGP/edition')//tei:div[@type eq 'poem']; (\:corpus of songs:\)
+declare variable $fs := doc('/db/VTLGP/ancillary/feature-library.xml'); (\:variants file:\):)
+declare variable $songs := collection('../../edition')//tei:div[@type eq 'poem'];
+declare variable $fs := doc('../../ancillary/feature-library.xml');
+declare variable $ling-features := $fs//tei:fs[tei:f/tei:fs[@type eq 'linguistic']]/@xml:id;
+declare variable $legendWidth := number('22');
+declare variable $legendHeight := number('22');
+declare variable $increased := number('12');
+declare variable $sep := number('9');
+
+
+
+
+ Número ocorrências
+ Cantiga
+
+ Variantes de língua
+
+ Formas únicas
+
+ {
+ for $section at $pos in
+ for $i in $songs
+ order by number($i//tei:title//tei:rdg[@wit eq '#A']/substring(tei:idno, 2)) descending
+ return
+ $i
+ let $ling := $section/descendant::tei:rdg[tokenize(replace(@ana, '#', ''), '\s+') = $ling-features]
+ let $song := $section//tei:title//tei:rdg[@wit eq '#A']/tei:idno/string()
+ let $y := count($ling) * $increased
+ let $dist-ling := count(distinct-values($ling/string())) * $increased
+ let $x := $sep * $pos
+ return
+
+ ( ,
+
+ ,
+ ,
+
+ {$song} ,
+
+
+
+ )
+
+ }
+
+
+ {
+ for $i in 1 to 21
+ return
+
+ }
+
+
+
+ {
+ for $x in 1 to 4
+ return
+ {($x + 4 - $x * 2 + 1) * 5}
+ }
+
+
+ 1
+
+
diff --git a/XQuery/graphs/results-by-author.svg b/XQuery/graphs/results-by-author.svg
new file mode 100644
index 0000000..02010b5
--- /dev/null
+++ b/XQuery/graphs/results-by-author.svg
@@ -0,0 +1,1343 @@
+
+
+
+
+
+
+
+
+ Índice de formas únicas por verso
+ Autores
+
+ Ms. B
+
+ Ms. A
+
+
+
+
+ Afonso Lopez de Baian
+
+
+
+
+ Fernan Garcia Esgaravunha
+
+
+
+
+ Fernan Gonçalvez de Seabra
+
+
+
+
+ Johan Garcia de Guilhade
+
+
+
+
+ Johan Soarez Coelho
+
+
+
+
+ Martin Soarez
+
+
+
+
+ Pero Gomez Barroso
+
+
+
+
+ Roi Queimado
+
+
+
+
+ Vasco Gil
+
+
+
+
+ Vasco Rodriguez de Calvelo
+
+
+
+
+ Bonifaci Calvo
+
+
+
+
+
+ Airas Carpancho
+
+
+
+
+ Fernan Padron
+
+
+
+
+ Fernan Velho
+
+
+
+
+ Johan Lopez de Ulhoa
+
+
+
+
+ Johan Nunez Camanez
+
+
+
+
+ Roi Fernandiz de Santiago
+
+
+
+
+ Johan Soarez Somesso
+
+
+
+
+ Nuno Fernandez Torneol
+
+
+
+
+ Pai Gomez Charinho
+
+
+
+
+ Pai Soarez de Taveirós
+
+
+
+
+ Pero da Ponte
+
+
+
+
+ Roi Paez de Ribela
+
+
+
+
+ Vasco Fernandez Praga de Sandin
+
+
+
+
+ Estevan Faian
+
+
+
+
+ Johan Vasquiz de Talaveira
+
+
+
+
+ Pero Garcia de Burgalês
+
+
+
+
+ Pedr’ Eanes Solaz
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+
+
diff --git a/XQuery/graphs/results-by-line.svg b/XQuery/graphs/results-by-line.svg
new file mode 100644
index 0000000..4e1a53c
--- /dev/null
+++ b/XQuery/graphs/results-by-line.svg
@@ -0,0 +1,1010 @@
+
+
+
+
+
+ Número ocorrências
+
+ Formas únicas
+
+
+ A309
+
+
+
+ A307
+
+
+
+ A297
+
+
+
+ A296
+
+
+
+ A295
+
+
+
+ A294
+
+
+
+ A293
+
+
+
+ A292
+
+
+
+ A290
+
+
+
+ A289
+
+
+
+ A288
+
+
+
+ A286
+
+
+
+ A285
+
+
+
+ A283
+
+
+
+ A266
+
+
+
+ A265
+
+
+
+ A264
+
+
+
+ A263
+
+
+
+ A262
+
+
+
+ A261
+
+
+
+ A260
+
+
+
+ A259
+
+
+
+ A258
+
+
+
+ A257
+
+
+
+ A255
+
+
+
+ A248
+
+
+
+ A246
+
+
+
+ A245
+
+
+
+ A244
+
+
+
+ A243
+
+
+
+ A242
+
+
+
+ A240
+
+
+
+ A234
+
+
+
+ A233
+
+
+
+ A232
+
+
+
+ A231
+
+
+
+ A230
+
+
+
+ A229
+
+
+
+ A225
+
+
+
+ A224
+
+
+
+ A223
+
+
+
+ A222
+
+
+
+ A221
+
+
+
+ A220
+
+
+
+ A219
+
+
+
+ A218
+
+
+
+ A217
+
+
+
+ A205
+
+
+
+ A203
+
+
+
+ A202
+
+
+
+ A201
+
+
+
+ A200
+
+
+
+ A199
+
+
+
+ A192
+
+
+
+ A189
+
+
+
+ A187
+
+
+
+ A179
+
+
+
+ A174
+
+
+
+ A173
+
+
+
+ A171
+
+
+
+ A166
+
+
+
+ A165
+
+
+
+ A149
+
+
+
+ A146
+
+
+
+ A145
+
+
+
+ A144
+
+
+
+ A138
+
+
+
+ A137
+
+
+
+ A136
+
+
+
+ A135
+
+
+
+ A133
+
+
+
+ A132
+
+
+
+ A122
+
+
+
+ A121
+
+
+
+ A120
+
+
+
+ A119
+
+
+
+ A118
+
+
+
+ A117
+
+
+
+ A116
+
+
+
+ A115
+
+
+
+ A113
+
+
+
+ A112
+
+
+
+ A111
+
+
+
+ A101
+
+
+
+ A99
+
+
+
+ A95
+
+
+
+ A93
+
+
+
+ A92
+
+
+
+ A90
+
+
+
+ A89
+
+
+
+ A88
+
+
+
+ A87
+
+
+
+ A86
+
+
+
+ A85
+
+
+
+ A84
+
+
+
+ A83
+
+
+
+ A82
+
+
+
+ A76
+
+
+
+ A75
+
+
+
+ A74
+
+
+
+ A73
+
+
+
+ A72
+
+
+
+ A71
+
+
+
+ A70
+
+
+
+ A67
+
+
+
+ A66
+
+
+
+ A65
+
+
+
+ A64
+
+
+
+ A54
+
+
+
+ A53
+
+
+
+ A52
+
+
+
+ A51
+
+
+
+ A50
+
+
+
+ A49
+
+
+
+ A48
+
+
+
+ A47
+
+
+
+ A46
+
+
+
+ A45
+
+
+
+ A44
+
+
+
+ A43
+
+
+
+ A42
+
+
+
+ A41
+
+
+
+ A40
+
+
+
+ A35
+
+
+
+ A34
+
+
+
+ A33
+
+
+
+ A32
+
+
+
+ A31
+
+
+
+ A25
+
+
+
+ A24
+
+
+
+ A23
+
+
+
+ A22
+
+
+
+ A21
+
+
+
+ A20
+
+
+
+ A19
+
+
+
+ A18
+
+
+
+ A17
+
+
+
+ A16
+
+
+
+ A15
+
+
+
+ A14
+
+
+
+ A10
+
+
+
+ A9
+
+
+
+ A8
+
+
+
+ A7
+
+
+
+ A6
+
+
+
+ A5
+
+
+
+ A4
+
+
+
+ A3
+
+
+
+ A2
+
+
+
+ A1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Roi Fernandiz de Santiago
+ Vasco Rodriguez de Calvelo
+ Pero da Ponte
+ Fernan Padron
+ Pedr’ Eanes Solaz
+ Bonifaci Calvo
+ Fernan Velho
+ Pai Gomez Charinho
+ Johan Vasquiz de Talaveira
+ Estevan Faian
+ Johan Garcia de Guilhade
+ Afonso Lopez de Baian
+ Pero Gomez Barroso
+ Fernan Gonçalvez de Seabra
+ Johan Lopez de Ulhoa
+ Roi Paez de Ribela
+ Johan Soarez Coelho
+ Vasco Gil
+ Roi Queimado
+ Fernan Garcia Esgaravunha
+ Johan Nunez Camanez
+ Pero Garcia de Burgalês
+ Nuno Fernandez Torneol
+ Airas Carpancho
+ Martin Soarez
+ Pai Soarez de Taveirós
+ Johan Soarez Somesso
+ Vasco Fernandez Praga de Sandin
+
+
diff --git a/XQuery/graphs/results-by-song.svg b/XQuery/graphs/results-by-song.svg
new file mode 100644
index 0000000..3ac1a60
--- /dev/null
+++ b/XQuery/graphs/results-by-song.svg
@@ -0,0 +1,1342 @@
+
+
+
+
+
+
+
+
+ Índice de formas únicas por verso
+ Autores
+
+ Ms. B
+
+ Ms. A
+
+
+
+
+ Afonso Lopez de Baian
+
+
+
+
+ Fernan Garcia Esgaravunha
+
+
+
+
+ Fernan Gonçalvez de Seabra
+
+
+
+
+ Johan Garcia de Guilhade
+
+
+
+
+ Johan Soarez Coelho
+
+
+
+
+ Martin Soarez
+
+
+
+
+ Pero Gomez Barroso
+
+
+
+
+ Roi Queimado
+
+
+
+
+ Vasco Gil
+
+
+
+
+ Vasco Rodriguez de Calvelo
+
+
+
+
+ Bonifaci Calvo
+
+
+
+
+
+ Airas Carpancho
+
+
+
+
+ Fernan Padron
+
+
+
+
+ Fernan Velho
+
+
+
+
+ Johan Lopez de Ulhoa
+
+
+
+
+ Johan Nunez Camanez
+
+
+
+
+ Roi Fernandiz de Santiago
+
+
+
+
+ Johan Soarez Somesso
+
+
+
+
+ Nuno Fernandez Torneol
+
+
+
+
+ Pai Gomez Charinho
+
+
+
+
+ Pai Soarez de Taveirós
+
+
+
+
+ Pero da Ponte
+
+
+
+
+ Roi Paez de Ribela
+
+
+
+
+ Vasco Fernandez Praga de Sandin
+
+
+
+
+ Estevan Faian
+
+
+
+
+ Johan Vasquiz de Talaveira
+
+
+
+
+ Pero Garcia de Burgalês
+
+
+
+
+ Pedr’ Eanes Solaz
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+
+
diff --git a/XQuery/graphs/tese.svg b/XQuery/graphs/tese.svg
new file mode 100644
index 0000000..18facb0
--- /dev/null
+++ b/XQuery/graphs/tese.svg
@@ -0,0 +1,4467 @@
+
+
+ All
+ Other witnesses
+ 35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Vasco Praga de Sandin
+
+ Johan Soarez Somesso
+
+ Pai Soarez de Taveirós
+
+ Martin Soarez
+
+ Dubidoso/Anónimo
+
+ Airas Carpancho
+
+ Nuno Rodriguez de Candarei
+
+ Nuno Fernandez Torneol
+
+ Pero Garcia Burgalês
+
+ Johan Nunez Camanez
+
+ Fernan Garcia Esgaravunha
+
+ Roi Queimado
+
+ Vasco Gil
+
+ Johan Soarez Coelho
+
+ Roi Paez de Ribela
+
+ Johan Lopez de Ulhoa
+
+ Fernan Gonçalvez de Seabra
+
+ Pero Gomez Barroso
+
+ Afonso Lopez de Baian
+
+ Johan Garcia de Guilhade
+
+ Estevan Faian
+
+ Johan Vasquiz de Talaveira
+
+ Pai Gomez Charinho
+
+ Fernan Velho
+
+ Bonifaci Calvo
+
+ Pedr' Eanes Solaz
+
+ Fernan Padron
+
+ Pero da Ponte
+
+ Vasco Rodriguez de Calvelo
+
+ Martin Moxa
+
+ Roi Fernandiz, clérigo de Santiago
+
+
+
diff --git a/XQuery/ling.xquery b/XQuery/ling.xquery
new file mode 100644
index 0000000..914c6ee
--- /dev/null
+++ b/XQuery/ling.xquery
@@ -0,0 +1,305 @@
+xquery version "3.0";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+(: Local function written by David J. Birnbaum (www.obdurodon.org) :)
+declare namespace djb = "www.obdurodon.org";
+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 variable $search := request:get-parameter("phenomenon", ());
+let $values := tokenize($search, ',')
+let $songs := collection('/db/VTLGP/edition')//tei:div[@type eq 'poem']
+let $readings := $songs//tei:rdg
+let $ling-features := doc('/db/VTLGP/ancillary/feature-library.xml')//tei:fs[tei:f[@name eq 'taxonomy']/tei:fs[@type eq 'linguistic']]
+let $poets := doc('/db/VTLGP/ancillary/corpus-autores.xml')//tei:person
+return
+
+
+ {
+ for $result in $values
+ return
+ ({transform:transform($ling-features[@xml:id = $result]//tei:string[@xml:lang eq 'pt']/text(), 'xmldb:exist:///db/VTLGP/xslt/string.xsl', ())}
+ {transform:transform($ling-features[@xml:id = $result]//tei:string[@xml:lang eq 'gl']/text(), 'xmldb:exist:///db/VTLGP/xslt/string.xsl', ())} {transform:transform($ling-features[@xml:id = $result]//tei:string[@xml:lang eq 'en']/text(), 'xmldb:exist:///db/VTLGP/xslt/string.xsl', ())} ,
+ Testemunho Testemuño Witness ,
+
+ {
+
+ let $fen := $readings[some $ana in tokenize(@ana, '\s+') satisfies $ana = concat('#', $result)]
+ for $wit at $pos in
+ for $i in distinct-values($fen/tokenize(./@wit, '\s+'))
+ order by count($fen[./tokenize(@wit, '\s+') = $i]) descending
+ return
+ $i
+ let $count := count($fen[contains(@wit, $wit)])
+ let $sum := count($fen)
+ let $percentage := round-half-to-even((100 * $count div $sum), 2)
+ order by $count descending
+ return
+
+
+ {' (' || $percentage || '%)'}
+ Ms. {substring($wit, 2)}
+
+ {
+ let $hand := $songs[.//tei:rdg[. intersect $fen[contains(@wit, $wit)]]]/tei:head//tei:rdg[@wit = $wit]/@hand
+ let $distinctHands := distinct-values($hand)
+ for $h in 1 to count($distinctHands)
+ let $x := count($songs[tei:head//tei:rdg[@wit = $wit][@hand = $distinctHands[position() lt $h]]]
+ //tei:rdg[. intersect $fen][contains(@wit, $wit)])
+ let $div := $songs[tei:head//tei:rdg[@wit = $wit][@hand = $distinctHands[$h]]][.//tei:rdg[. intersect $fen]]
+ let $conta := count($div//tei:rdg[. intersect $fen[contains(@wit, $wit)]])
+ order by $h descending
+ return
+
+
+ {substring($distinctHands[$h], 2)}
+
+ }
+
+ } ,
+ Período Period ,
+
+ {
+
+ let $fen := $readings[some $ana in tokenize(@ana, '\s+') satisfies $ana = concat('#', $result)]
+ for $period at $pos in
+ for $i in distinct-values($poets[@xml:id = $fen/ancestor::tei:div[1]//tei:name/substring(@ref, 2)]/tei:floruit/@period)
+ order by count($fen[ancestor::tei:div[1]//tei:name/substring(@ref, 2) = $poets/tei:floruit[@period = $i]/../@xml:id]) descending
+ return
+ $i
+ let $count := count($fen[ancestor::tei:div[1]//tei:name/substring(@ref, 2) = $poets/tei:floruit[@period = $period]/../@xml:id])
+ let $sum := count($fen)
+ let $percentage := round-half-to-even((100 * $count div $sum), 2)
+ order by $count descending
+ return
+
+
+ {' (' || $percentage || '%)'}
+ Per. {$period}
+
+ } ,
+
+
+
+ Fenómeno Phenomenon
+
+ Testemunho Testemuño Witness
+
+ Localização Localización Location
+
+ Copista Copyist
+
+ Autor Author
+
+ Período Period
+
+ Cantiga Song
+
+ V. L.
+
+
+
+
+ {
+ for $fen in $readings[some $ana in tokenize(@ana, '\s+') satisfies $ana = concat('#', $result)]
+ let $rdg :=
+
+
+
+
+ let $author := $poets[@xml:id = $fen/ancestor::tei:div[1]//tei:name/substring(@ref, 2)]
+ return
+
+ {transform:transform($fen/.., 'xmldb:exist:///db/VTLGP/xslt/ex.xsl', ($rdg))}
+ {
+ (if ($fen/contains(@wit, ' ')) then
+ {
+ for $wit in tokenize($fen/@wit, '\s+')
+ order by $wit
+ return
+ {substring($wit, 2)}
+ }
+ else
+ $fen/substring(@wit, 2)
+ )
+ }
+ {
+ (if (contains($fen/@wit, ' ')) then
+ {
+
+ for $wit in tokenize($fen/@wit, '\s+')
+ order by $wit
+ return
+ {djb:locus($fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $wit]/tei:locus/@from, $fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $wit]/tei:locus/@to)
+ }
+ }
+ else
+ djb:locus($fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $fen/@wit]/tei:locus/@from, $fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $fen/@wit]/tei:locus/@to))
+ }
+ {
+ (if (contains($fen/@wit, ' ')) then
+ {
+
+ for $wit in tokenize($fen/@wit, '\s+')
+ order by $wit
+ return
+ {$fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $wit]/substring(@hand, 2)}
+ }
+ else
+ $fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $fen/@wit]/substring(@hand, 2))
+ }
+ {$author/tei:persName/string()}
+ {$author/tei:floruit/@from || '-' || $author/tei:floruit/@to || ' (' || $author/tei:floruit/@period || ')'}
+ {$fen/ancestor::tei:div[1]/string-join(descendant::tei:title//tei:idno, ', ')}
+ {$fen/ancestor::tei:l/@n/string()}
+
+ }
+
+
)
+ }
+
+
+ Conteúdos Contents Contidos
+
+
+ {
+ for $result in $values
+ return
+ {transform:transform($ling-features[@xml:id = $result]//tei:string[@xml:lang eq 'en']/text(), 'xmldb:exist:///db/VTLGP/xslt/string.xsl', ())}
+
+
+ }
+
+
+
+
+ {
+ for $result in $values
+ return
+ {transform:transform($ling-features[@xml:id = $result]//tei:string[@xml:lang eq 'pt']/text(), 'xmldb:exist:///db/VTLGP/xslt/string.xsl', ())}
+
+
+ }
+
+
+
+
+
+ {
+ for $result in $values
+ return
+ {transform:transform($ling-features[@xml:id = $result]//tei:string[@xml:lang eq 'gl']/text(), 'xmldb:exist:///db/VTLGP/xslt/string.xsl', ())}
+
+
+ }
+
+
+
+
diff --git a/XQuery/other-queries/abbreviations.xquery b/XQuery/other-queries/abbreviations.xquery
new file mode 100644
index 0000000..e95a1b2
--- /dev/null
+++ b/XQuery/other-queries/abbreviations.xquery
@@ -0,0 +1,7 @@
+xquery version "3.0";
+declare namespace tei="http://www.tei-c.org/ns/1.0";
+let $songs := collection('/db/VTLGP')//tei:div[@type='poem']
+let $fenomena := doc('/db/VTLGP/feature_library.xml')//tei:fs[@xml:id eq 'vus']
+let $exemplos := $songs//tei:rdg[contains(tei:ex[preceding-sibling::text()[contains(.,'q')]], 'uan')]
+for $exemplo in $exemplos
+return $exemplo/ancestor::*[name() eq 'div']/@corresp/string() || '-' || $exemplo/@wit
\ No newline at end of file
diff --git a/XQuery/other-queries/latex-tables-2.xquery b/XQuery/other-queries/latex-tables-2.xquery
new file mode 100644
index 0000000..e886909
--- /dev/null
+++ b/XQuery/other-queries/latex-tables-2.xquery
@@ -0,0 +1,76 @@
+xquery version "3.0";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+(: Local function written by David J. Birnbaum (www.obdurodon.org) :)
+declare namespace djb = "www.obdurodon.org";
+declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes";
+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 variable $result := request:get-parameter("phenomenon", ("p1i"));
+let $songs := collection('/db/VTLGP/edition')//tei:div[@type eq 'poem']
+let $readings := $songs//tei:rdg
+let $poets := doc('/db/VTLGP/ancillary/corpus-autores.xml')//tei:person
+for $fen in $readings[some $ana in tokenize(@ana, '\s+')
+ satisfies $ana = concat('#', $result)]
+let $rdg :=
+
+
+
+
+let $author := $poets[@xml:id = $fen/ancestor::tei:div[1]//tei:name/substring(@ref, 2)]
+let $orderedWit := for $wit in tokenize($fen/@wit, '\s+')
+order by $wit
+return
+ $wit
+let $wit1 := $orderedWit[1]
+let $wit2 := $orderedWit[2]
+order by $wit1,
+ number($fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $wit1]/tei:locus/replace(@from, '[rv]+', ''))
+return
+
+ (
+ '\uni{' || string-join(transform:transform($fen/.., 'xmldb:exist:///db/VTLGP/xslt/ex.xsl', ($rdg)), '//') || '} & ' ||
+
+ (if ($fen/contains(@wit, ' ')) then
+ substring($wit1, 2)
+
+ else
+ $fen/substring(@wit, 2))
+ || ' & ' ||
+
+ (if (contains($fen/@wit, ' ')) then
+ djb:locus($fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $wit1]/tei:locus/@from, $fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $wit1]/tei:locus/@to)
+ else
+ djb:locus($fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $fen/@wit]/tei:locus/@from, $fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $fen/@wit]/tei:locus/@to)) || ' & ' ||
+
+ (if (contains($fen/@wit, ' ')) then
+
+ $fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $wit1]/substring(@hand, 2)
+ else
+ $fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $fen/@wit]/substring(@hand, 2)) || ' &' ||
+ $author/tei:persName/string() || ' & ' ||
+(: $author/tei:floruit/@period || ' & ' || :)
+
+ $fen/ancestor::tei:div[1]/string-join(descendant::tei:title//tei:idno, ', ') || ' & ' ||
+ $fen/ancestor::tei:l/@n/string() ||
+ (if (contains($fen/@wit, ' ')) then
+ ' \\ \cline{2-4}
&' || substring($wit2, 2) || ' & ' ||
+ djb:locus($fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $wit2]/tei:locus/@from, $fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $wit2]/tei:locus/@to) || ' & ' || $fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $wit2]/substring(@hand, 2) ||
+ ' & & & \\ \hline
'
+ else
+ ' \\ \hline
'
+ )
+ )
\ No newline at end of file
diff --git a/XQuery/other-queries/latex-tables.xquery b/XQuery/other-queries/latex-tables.xquery
new file mode 100644
index 0000000..e886909
--- /dev/null
+++ b/XQuery/other-queries/latex-tables.xquery
@@ -0,0 +1,76 @@
+xquery version "3.0";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+(: Local function written by David J. Birnbaum (www.obdurodon.org) :)
+declare namespace djb = "www.obdurodon.org";
+declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes";
+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 variable $result := request:get-parameter("phenomenon", ("p1i"));
+let $songs := collection('/db/VTLGP/edition')//tei:div[@type eq 'poem']
+let $readings := $songs//tei:rdg
+let $poets := doc('/db/VTLGP/ancillary/corpus-autores.xml')//tei:person
+for $fen in $readings[some $ana in tokenize(@ana, '\s+')
+ satisfies $ana = concat('#', $result)]
+let $rdg :=
+
+
+
+
+let $author := $poets[@xml:id = $fen/ancestor::tei:div[1]//tei:name/substring(@ref, 2)]
+let $orderedWit := for $wit in tokenize($fen/@wit, '\s+')
+order by $wit
+return
+ $wit
+let $wit1 := $orderedWit[1]
+let $wit2 := $orderedWit[2]
+order by $wit1,
+ number($fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $wit1]/tei:locus/replace(@from, '[rv]+', ''))
+return
+
+ (
+ '\uni{' || string-join(transform:transform($fen/.., 'xmldb:exist:///db/VTLGP/xslt/ex.xsl', ($rdg)), '//') || '} & ' ||
+
+ (if ($fen/contains(@wit, ' ')) then
+ substring($wit1, 2)
+
+ else
+ $fen/substring(@wit, 2))
+ || ' & ' ||
+
+ (if (contains($fen/@wit, ' ')) then
+ djb:locus($fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $wit1]/tei:locus/@from, $fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $wit1]/tei:locus/@to)
+ else
+ djb:locus($fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $fen/@wit]/tei:locus/@from, $fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $fen/@wit]/tei:locus/@to)) || ' & ' ||
+
+ (if (contains($fen/@wit, ' ')) then
+
+ $fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $wit1]/substring(@hand, 2)
+ else
+ $fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $fen/@wit]/substring(@hand, 2)) || ' &' ||
+ $author/tei:persName/string() || ' & ' ||
+(: $author/tei:floruit/@period || ' & ' || :)
+
+ $fen/ancestor::tei:div[1]/string-join(descendant::tei:title//tei:idno, ', ') || ' & ' ||
+ $fen/ancestor::tei:l/@n/string() ||
+ (if (contains($fen/@wit, ' ')) then
+ ' \\ \cline{2-4}
&' || substring($wit2, 2) || ' & ' ||
+ djb:locus($fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $wit2]/tei:locus/@from, $fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $wit2]/tei:locus/@to) || ' & ' || $fen/ancestor::tei:div[1]/tei:head//tei:rdg[@wit = $wit2]/substring(@hand, 2) ||
+ ' & & & \\ \hline
'
+ else
+ ' \\ \hline
'
+ )
+ )
\ No newline at end of file
diff --git a/XQuery/other-queries/line-counting.xquery b/XQuery/other-queries/line-counting.xquery
new file mode 100644
index 0000000..6b724dc
--- /dev/null
+++ b/XQuery/other-queries/line-counting.xquery
@@ -0,0 +1,27 @@
+xquery version "3.0";
+declare namespace tei="http://www.tei-c.org/ns/1.0";
+declare option exist:serialize "method=html5 media-type=text/html omit-xml-declaration=yes indent=yes";
+let $transcriptions := collection('/db/tese/drafts/temporary')
+let $done := collection('/db/tese/drafts/songs')//tei:div//@corresp
+let $A := $transcriptions//div[@wit="#A"][@corresp != $done]
+let $B := $transcriptions//div[@wit="#B"][@corresp != $done]
+let $V := $transcriptions//div[@wit eq '#V'][@corresp != $done]
+return
+
+
+ Line counts
+
+
+ {
+ for $b in $B[@corresp = $A/@corresp]
+ let $corresp := $b/@corresp
+ let $a := $A[@corresp eq $corresp]
+ let $v := $V[@corresp eq $corresp]
+ let $b-count := count($b/l)
+ let $a-count := count($a/l)
+ let $v-count:= count($v/l)
+ where count(distinct-values(($a-count, $b-count, if ($v) then $v-count else ()))) ne 1
+ return {substring($corresp, 2) || ': A ' || $a-count || '; B ' || $b-count || (if ($v-count gt 0) then ('; V ' || $v-count) else ())||' ('|| substring-after(base-uri($b), 'temporary/')||' ' || substring-after(base-uri($a), 'temporary/') || ')' }
+ }
+
+
\ No newline at end of file
diff --git a/XQuery/other-queries/me-status.xquery b/XQuery/other-queries/me-status.xquery
new file mode 100644
index 0000000..9350365
--- /dev/null
+++ b/XQuery/other-queries/me-status.xquery
@@ -0,0 +1,24 @@
+xquery version "3.0";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes";
+let $songs := collection('/db/VTLGP/edition')//tei:div[@type eq 'poem']
+let $me-apps := $songs//tei:rdg[not(contains(@ana, 'dat'))][matches(., '[^\w][mM]e[^\w]') or (tei:supplied[preceding-sibling::node()[1][matches(., '[^\w][mM]$')]]) or (matches(., '[^\w][mM]e$')) or (matches(., '^[mM]e$')) or (matches(., '^[mM]e[^\w]'))]/parent::tei:app[not(tei:rdg[contains(@ana, 'dat')])]
+for $me in $me-apps
+order by number($me/ancestor::tei:div[1]/replace(substring-before(@corresp, 'B'), '#A', ''))
+return
+ '\uni{' || transform:transform($me, 'xmldb:exist:///db/VTLGP/xslt/me.xsl', ()) || '} & ' ||
+
+ (if ($me[count(tei:rdg[not(contains(@ana, 'dat'))][matches(., '[^\w][mM]e[^\w]') or (tei:supplied[preceding-sibling::node()[1]
+ [matches(., '[^\w][mM]$')]]) or (matches(., '[^\w][mM]e$')) or (matches(., '^[mM]e$')) or (matches(., '^[mM]e[^\w]'))]) gt 1])
+ then
+ let $witnesses:= for $rdg in $me/tei:rdg[not(contains(@ana, 'dat'))][matches(., '[^\w][mM]e[^\w]') or (tei:supplied[preceding-sibling::node()[1]
+ [matches(., '[^\w][mM]$')]]) or (matches(., '[^\w][mM]e$')) or (matches(., '^[mM]e$')) or (matches(., '^[mM]e[^\w]'))] return $rdg/replace(replace(@wit, '#', ''), ' ', ', ')
+ return
+ string-join($witnesses, ' / ')
+
+ else
+ $me/tei:rdg[not(contains(@ana, 'dat'))][matches(., '[^\w][mM]e[^\w]') or (tei:supplied[preceding-sibling::node()[1]
+ [matches(., '[^\w][mM]$')]]) or (matches(., '[^\w][mM]e$')) or (matches(., '^[mM]e$')) or (matches(., '^[mM]e[^\w]'))]/replace(replace(@wit, '#', ''), ' ', ', ')
+ )
+ || ' & ' || $me/ancestor::tei:div[1]/string-join(descendant::tei:title//tei:idno, ', ') || ' & ' ||
+ $me/ancestor::tei:l/@n/string() || ' \\ \hline
'
\ No newline at end of file
diff --git a/XQuery/other-queries/mi-status.xquery b/XQuery/other-queries/mi-status.xquery
new file mode 100644
index 0000000..a5229aa
--- /dev/null
+++ b/XQuery/other-queries/mi-status.xquery
@@ -0,0 +1,27 @@
+xquery version "3.0";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes";
+let $songs := collection('/db/VTLGP/edition')//tei:div[@type eq 'poem']
+let $type := 'strong'
+let $tp :=
+
+
+
+let $hits := $songs//tei:app[tei:rdg[@select eq $type]]
+for $wk in $hits
+order by number($wk/ancestor::tei:div[1]/replace(substring-before(@corresp, 'B'), '#A', ''))
+return
+ '\uni{' || transform:transform($wk, 'xmldb:exist:///db/VTLGP/xslt/select.xsl', ($tp)) || '} & ' ||
+
+ (if ($wk[count(tei:rdg[@select eq $type]) gt 1])
+ then
+ let $witnesses:= for $rdg in $wk/tei:rdg[@select = $type] return $rdg/replace(replace(@wit, '#', ''), ' ', ', ')
+ return
+ string-join($witnesses, ' / ')
+
+ else
+ $wk/tei:rdg[@select eq $type]/replace(replace(@wit, '#', ''), ' ', ', ')
+ )
+ || ' & ' || $wk/ancestor::tei:div[1]/string-join(descendant::tei:title//tei:idno, ', ') || ' & ' ||
+ $wk/ancestor::tei:l/@n/string() || ' \\ \hline
'
+
diff --git a/XQuery/tabular.xquery b/XQuery/tabular.xquery
new file mode 100644
index 0000000..5fbe295
--- /dev/null
+++ b/XQuery/tabular.xquery
@@ -0,0 +1,62 @@
+xquery version "3.0";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+(: Local function written by David J. Birnbaum (djbpitt@gmail.com) :)
+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 variable $selection := request:get-parameter("song", 'A82B186b');
+declare variable $cantigas := collection('/db/VTLGP/edition')//tei:div[@type eq 'poem'];
+declare variable $song := $cantigas[substring(@corresp, 2) = $selection];
+declare variable $author := doc('/db/VTLGP/ancillary/corpus-autores.xml')//tei:person[string(@xml:id) = $song//tei:name[@role eq 'author']/substring(@ref, 2)];
+
+(
+
Cantiga Song
+ {': ' || string-join($song//tei:title//tei:idno, ', ')}
+ Autor Author
+ {': ' || $author/tei:persName/string()}
+ Período Period
+ {': ' || $author/tei:floruit/@from/string()}-{$author/tei:floruit/@to/string()}
+ (período period
+ {' ' || $author/tei:floruit/@period/string()})
+,
+
+ {
+ for $line in $song//tei:l
+ return
+ (
{$line/@n/string()}.
,
+
{
+ for $witness in $song/tei:head/descendant::tei:rdg
+ let $parameter :=
+
+
+
+ return
+ {transform:transform($line[ancestor::tei:div/tei:head/descendant::tei:rdg/@wit = $witness/@wit], doc('/db/VTLGP/xslt/table.xsl'), $parameter)}
+
+ }
)
+
+ }
)
+