Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
fontane-notizbuecher
SADE
Commits
ce8cf896
Commit
ce8cf896
authored
Oct 23, 2018
by
MRodz
Committed by
mrodzis
Feb 05, 2019
Browse files
Add first draft for info ingest from indices
parent
4c3bb6b6
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
modules/fontane/teisimpleprint/index-info.xqm
0 → 100644
View file @
ce8cf896
xquery version "3.1";
(:~
: @@@
:
: @author Michelle Rodzis
: @version 0.1
: @since TODO
:)
module namespace index-info="http://fontane-nb.dariah.eu/index-info";
import module namespace config="http://textgrid.de/ns/SADE/config" at "../../config/config.xqm";
import module namespace console="http://exist-db.org/xquery/console";
import module namespace simpleHelpers="http://fontane-nb.dariah.eu/teisimplehelpers" at "teisimplehelpers.xqm";
declare namespace map = "http://www.w3.org/2005/xpath-functions/map";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare variable $index-info:place-map :=
map:merge(for $entry in doc("/db/sade-projects/textgrid/data/xml/data/253t2.xml")//tei:place
return
map:entry(string($entry/@xml:id),
map {
"regular-name" : string-join($entry/tei:placeName, ", "),
"subref-of" : string-join($entry/parent::tei:place/tei:placeName, ", "),
"occs-in-nbs" : ""
}
));
declare function index-info:get-full-place-ref($node as element(tei:rs)) as xs:string {
let $main-entry := local:get-main-entry($node)
return map:get($main-entry, "regular-name")
};
declare function index-info:get-place-sub-ref($node as element(tei:rs)) as xs:string* {
let $main-entry := local:get-main-entry($node)
return map:get($main-entry, "subref-of")
};
declare function index-info:get-place-occs($node as element(tei:rs)) as xs:string* {
let $main-entry := local:get-main-entry($node)
return map:get($main-entry, "occs-in-nbs")
};
declare function index-info:get-full-map() {
$index-info:place-map
};
declare function local:get-main-entry($node as element(tei:rs)) as map()* {
let $key := $node/@ref => substring-after(":")
return map:get($index-info:place-map, $key)
};
\ No newline at end of file
modules/fontane/teisimpleprint/run-transform2teisimple.xql
View file @
ce8cf896
...
...
@@ -2,17 +2,15 @@ xquery version "3.1";
(:~
: This modules runs the first and second process that transforms the Fontane
: TEI subset into
the TEI
simple
Print
encoding.
: TEI subset into
a
simple
r TEI
encoding.
:
: @author Michelle Rodzis
: @version 1.0
:)
import module namespace fontane
-s
imple="http://fontane-nb.dariah.eu/teisimple"
import module namespace fontane
S
imple="http://fontane-nb.dariah.eu/teisimple"
at "tei2teisimple.xqm";
import module namespace tidySimple ="http://fontane-nb.dariah.eu/tidysimple" at "tidysimple.xqm";
let $tei := fontane-simple:main("16b00.xml")
return tidySimple:main($tei)
(:fontane-simple:main("16b00.xml"):)
\ No newline at end of file
let $tei := fontaneSimple:main("16b00.xml")
return tidySimple:main($tei)
\ No newline at end of file
modules/fontane/teisimpleprint/tei2print.xqm
0 → 100644
View file @
ce8cf896
xquery version "3.1";
(:~
: @@@
:
: @author Michelle Rodzis
: @version 0.1
: @since TODO
:)
module namespace tei2print="http://fontane-nb.dariah.eu/tei2print";
import module namespace config="http://textgrid.de/ns/SADE/config" at "../../config/config.xqm";
import module namespace simpleHelpers="http://fontane-nb.dariah.eu/teisimplehelpers" at "teisimplehelpers.xqm";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare option exist:serialize "method=text media-type=text/plain indent=no";
declare function tei2print:main($nodes as node()*) as xs:string {
let $assure-dir := simpleHelpers:assure-dir-available("resources/tex/")
let $transform := element div {tei2print:transform($nodes)}
return xmldb:store($config:app-root || "/resources/tex/", "fontane-print.tex", $transform)
};
declare function tei2print:transform($nodes as node()*) as xs:string* {
for $node in $nodes return
typeswitch($node)
case text() return
$node
case element(tei:pb) return
"[" || (if($node/@n) then $node/@n else $node/@type) || "]"
case element(tei:list) return
"\startitemize " || tei2print:transform($node/node()) || "\stopitemize "
default return
tei2print:transform($node/node())
};
\ No newline at end of file
modules/fontane/teisimpleprint/tei2teisimple.xqm
View file @
ce8cf896
...
...
@@ -18,6 +18,7 @@ declare namespace test="http://exist-db.org/xquery/xqsuite";
import module namespace console="http://exist-db.org/xquery/console";
import module namespace simpleHelpers="http://fontane-nb.dariah.eu/teisimplehelpers" at "teisimplehelpers.xqm";
import module namespace index-info="http://fontane-nb.dariah.eu/index-info" at "index-info.xqm";
(:~
: The main function initiates the transformation of a given notebook.
...
...
@@ -636,7 +637,16 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
fontaneSimple:copy-element($node)
case element(tei:rs) return
fontaneSimple:copy-element($node)
element tei:rs {
$node/@*,
if(matches($node/@ref, "plc")) then
(attribute full-ref {index-info:get-full-place-ref($node)},
attribute subtype-of {index-info:get-place-sub-ref($node)},
attribute occs {index-info:get-place-occs($node)})
else
(),
fontaneSimple:transform($node/node())
}
case element(tei:date) return
element {QName("http://www.tei-c.org/ns/1.0", $node/name())}{
...
...
modules/fontane/teisimpleprint/teisimplehelpers.xqm
View file @
ce8cf896
...
...
@@ -13,6 +13,7 @@ module namespace simpleHelpers="http://fontane-nb.dariah.eu/teisimplehelpers";
declare namespace tei="http://www.tei-c.org/ns/1.0";
import module namespace console="http://exist-db.org/xquery/console";
import module namespace config="http://textgrid.de/ns/SADE/config" at "../../config/config.xqm";
import module namespace functx = "http://www.functx.com";
...
...
@@ -424,3 +425,10 @@ as element(tei:milestone) {
()
}
};
declare function simpleHelpers:assure-dir-available($dir-name as xs:string) {
if(xmldb:collection-available($config:app-root || $dir-name)) then
()
else
xmldb:create-collection($config:app-root, $dir-name)
};
\ No newline at end of file
modules/fontane/teisimpleprint/tests/index-info-test-runner.xql
0 → 100644
View file @
ce8cf896
xquery version "3.1";
(: This main module starts the tests stored in index-info-test.xql. :)
import module namespace index-info-test = "http://fontane-nb.dariah.eu/index-info-test" at "index-info-test.xql";
import module namespace test="http://exist-db.org/xquery/xqsuite" at "resource:org/exist/xquery/lib/xqsuite/xqsuite.xql";
declare namespace tei="http://www.tei-c.org/ns/1.0";
test:suite(
util:list-functions("http://fontane-nb.dariah.eu/index-info-test")
)
modules/fontane/teisimpleprint/tests/index-info-test.xql
0 → 100644
View file @
ce8cf896
xquery version "3.1";
(: This library module contains XQSuite tests for the all modules module stored
: in index-info.xqm :)
module namespace index-info-test = "http://fontane-nb.dariah.eu/index-info-test";
import module namespace index-info ="http://fontane-nb.dariah.eu/index-info" at "../index-info.xqm";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace test="http://exist-db.org/xquery/xqsuite";
declare
%test:name("Test the test")
%test:assertFalse
function index-info-test:a-test-the-test() {
false()
};
declare
%test:name("Full references")
%test:args("<rs xmlns=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""plc:Thueringen"">ein Bundesland</rs>")
%test:assertEquals("Thüringen")
(: entry with several variant names :)
%test:args("<rs xmlns=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""plc:Albaner_Berge"">Berge</rs>")
%test:assertEquals("Albaner Berge (ital.: Colli Albani), Albanergebirge")
function index-info-test:full-reference($node as element(*)) {
index-info:get-full-place-ref($node)
};
declare
%test:name("Subreferences")
%test:args("<rs xmlns=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""plc:Sacro_Convento_Assisi"">ein Ort</rs>")
%test:assertEquals("Assisi")
%test:args("<rs xmlns=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""plc:Thueringen"">ein Bundesland</rs>")
%test:assertEquals("")
function index-info-test:sub-reference($node as element(*)) {
index-info:get-place-sub-ref($node)
};
\ No newline at end of file
modules/fontane/teisimpleprint/tidysimple.xqm
View file @
ce8cf896
...
...
@@ -30,7 +30,7 @@ declare variable $tidySimple:valid-hands :=
$res//tei:handNote[@script = "contemporary"]/@xml:id/string();
declare function tidySimple:main($tei as node()*)
as xs:string*
{
declare function tidySimple:main($tei as node()*) {
let $doc :=
try {
(doc($config:app-root || "/resources/xml/tei-simple-pre.xml"))
...
...
@@ -42,7 +42,7 @@ declare function tidySimple:main($tei as node()*) as xs:string* {
let $clear-surplus-hands := tidySimple:sort-out-surplus-hands($clear-invalid-hands)
let $text-with-sections := tidySimple:make-structure($clear-surplus-hands)
let $store := xmldb:store("/db/apps/SADE/resources/xml/", "tei-simple-tmp.xml", <div>{$text-with-sections}</div>)
return
""
return
element tei:div {$text-with-sections}
(: let $doc := doc($config:app-root || "/resources/xml/tei-simple-tmp.xml"):)
(: let $tidied-text := tidySimple:tidy($doc//tei:text):)
(: let $final-tei:=:)
...
...
resources/xml/tei-simple-pre.xml
View file @
ce8cf896
This diff is collapsed.
Click to expand it.
resources/xml/tei-simple-tmp.xml
View file @
ce8cf896
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment