Commit 37911e67 authored by mrodzis's avatar mrodzis 🌿
Browse files

Sort first, then do the rest of transformation (much better performance)

parent c3f3eb17
......@@ -10,16 +10,21 @@ import module namespace functx="http://www.functx.com";
import module namespace simpleHelpers="http://fontane-nb.dariah.eu/teisimplehelpers" at "teisimplehelpers.xqm";
declare function presort:main($tei as node()*) as element(tei:text) {
let $front := $tei//tei:front/node()
let $back := $tei//tei:back/node()
let $body := $tei//tei:body/node()
let $tei :=
<text xmlns="http://www.tei-c.org/ns/1.0">
<front>{presort:sort($front)}</front>
<body>{presort:sort($body)}</body>
<back>{presort:sort($back)}</back>
</text>
(: let $front := $tei//tei:front/node():)
(: let $back := $tei//tei:back/node():)
(: let $body := $tei//tei:body/node() :)
(::)
(: let $tei :=:)
(: <text xmlns="http://www.tei-c.org/ns/1.0">:)
(: <front>{presort:sort($front)}</front>:)
(: <body>{presort:sort($body)}</body>:)
(: <back>{presort:sort($back)}</back>:)
(: </text>:)
(: :)
(: let $store := xmldb:store("/db/apps/SADE/resources/xml/", "tei-simple-presort.xml", $tei):)
(: return $tei:)
let $tei := presort:sort($tei)
let $store := xmldb:store("/db/apps/SADE/resources/xml/", "tei-simple-presort.xml", $tei)
return $tei
};
......@@ -53,10 +58,6 @@ declare function presort:sort($nodes as node()*) as node()* {
};
declare function presort:keep-node($node as node()*) as node()* {
if($node[self::text()]) then
util:log-system-out("text")
else
(),
element {QName("http://www.tei-c.org/ns/1.0", $node/name())} {
$node/@*,
(: $node/(@* except (@prev, @next)), (: attrs only visible for debugging :):)
......@@ -118,11 +119,8 @@ declare function presort:exclude-copied($node as node()) as element(tei:rs) {
$child
return
(util:log-system-out($processed-children),
element {QName("http://www.tei-c.org/ns/1.0", $node/name())} {
$node/@*,
$processed-children
(: $node/node()[not(@prev)]:)
(: $node/node():)
})
element {QName("http://www.tei-c.org/ns/1.0", $node/name())} {
$node/@*,
$processed-children
}
};
\ No newline at end of file
......@@ -10,7 +10,15 @@ xquery version "3.1";
import module namespace fontaneSimple="http://fontane-nb.dariah.eu/teisimple"
at "tei2teisimple.xqm";
import module namespace presort="http://fontane-nb.dariah.eu/presort" at "presort.xqm";
import module namespace tidySimple ="http://fontane-nb.dariah.eu/tidysimple" at "tidysimple.xqm";
let $tei := fontaneSimple:main("16b00.xml")
return tidySimple:main($tei)
\ No newline at end of file
let $test := doc("/db/sade-projects/textgrid/data/xml/data/16b00.xml")/*
return
presort:main($test)
=> fontaneSimple:main()
=> tidySimple:main()
(:let $tei := fontaneSimple:main("16b00.xml"):)
(:return tidySimple:main($tei):)
\ No newline at end of file
......@@ -28,13 +28,14 @@ import module namespace index-info="http://fontane-nb.dariah.eu/index-info" at "
: TODO: adapt to several input files?
:
: :)
declare function fontaneSimple:main($file as xs:string) as node()? {
let $doc :=
try {
(doc("/db/sade-projects/textgrid/data/xml/data/" || $file))
} catch * {
(console:log("It was not possible to open the requested file " || $file))
}
declare function fontaneSimple:main($doc as node()*) as node()? {
(:declare function fontaneSimple:main($file as xs:string) as node()? {:)
(: let $doc :=:)
(: try {:)
(: (doc("/db/sade-projects/textgrid/data/xml/data/" || $file)):)
(: } catch * {:)
(: (console:log("It was not possible to open the requested file " || $file)):)
(: }:)
let $front-covers := $doc//tei:sourceDoc/tei:surface[contains(@n, "front_cover")]
let $back-covers := $doc//tei:sourceDoc/tei:surface[contains(@n, "back_cover")]
......
......@@ -35,7 +35,7 @@ declare function tidySimple:main($tei as node()*) {
let $tidy := tidySimple:sort-out-invalid-hands($tei//tei:text)
=> tidySimple:sort-out-surplus-elements()
=> tidySimple:whitespaces()
=> tidySimple:sort()
(: => tidySimple:sort():)
(: let $text-with-sections := tidySimple:make-structure($clear-surplus-hands):)
let $header := $tei/tei:teiHeader
return
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment