Commit aba01773 authored by MRodz's avatar MRodz Committed by mrodzis
Browse files

Start conversion to TEISimple

The Fontane-TEI is far too complex to display all information in the planned
book or edition view on the website. Therefore we break it down into a simpler
format. We chose TEISimple in order to be able to re-use TEISimple's
processing models and to display the edition view in the DFG Viewer.

This is just the initial commit for the module with non-working tests -- for
some reason inspect:module-functions doesn't find any functions. Even the
examples provided on exist-db.org don't seem to work in exist-db 4.2.0.
parent 3991ec6d
xquery version "3.1";
(:~
: This modules handles the conversion of the Fontante-TEI/XML into TEISimple
: for the edited text. The resulting TEISimple is the basis for the "Editerter
: Text" view on the website and the book.
:
: The resulting TEISimple orientates itself toward the so-called "SUB-Schema"
: which is a subset for TEISimple that is recommended for future projects that
: are held by the Göttingen State and University Library (SUB).
:
: @author Michelle Rodzis
: @version 0.1
:)
module namespace fontane-simple="http://fontane-nb.dariah.eu/teisimple";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace test="http://exist-db.org/xquery/xqsuite";
import module namespace console="http://exist-db.org/xquery/console";
(:~
: The main function initiates the transformation of a given notebook.
:
: TODO: adapt to several input files?
:
: :)
declare function fontane-simple:main($file as xs:string) as element(tei:TEI) {
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 $content := $doc//tei:sourceDoc
let $transform := fontane-simple:transform($content)
let $tei-simple :=
<TEI xmlns="http://www.tei-c.org/ns/1.0">
{$doc//tei:teiHeader}
{$transform}
</TEI>
return $tei-simple
};
declare
%test:args("<tei:sourceDoc/>") %test:assertEquals("<tei:text/>")
function fontane-simple:transform($nodes as node()*) as item()* {
for $node in $nodes
return
typeswitch ($node)
case text()
return
$node
case element(tei:sourceDoc)
return
element{"tei:text"}{
fontane-simple:transform($node/node())
}
case element(tei:surface)
return
(: book covers :)
if(contains($node/@n, "cover")
and
(: all covers with a label ... :)
(contains($node/tei:surface/@subtype, "Fontane")
or contains($node/tei:surface/@subtype, "Hersteller")
(: or text directly written on it :)
or not($node/tei:surface))
)
then
element{"tei:front"}{
fontane-simple:transform($node/node())
}
(: labels on book covers and spine :)
else if($node/@type = "label"
and
(contains($node/@subtype, "Fontane")
or contains($node/@subtype, "Hersteller"))
)
then
element{"tei:div"}{
attribute{"type"}{"label"},
fontane-simple:transform($node/node())
}
else
()
default return
()
};
\ No newline at end of file
xquery version "3.1";
import module namespace fontane-simple="http://fontane-nb.dariah.eu/teisimple" at "/db/apps/SADE/modules/fontane/transform2teisimple.xqm";
import module namespace test="http://exist-db.org/xquery/xqsuite" at "resource:org/exist/xquery/lib/xqsuite/xqsuite.xql";
import module namespace console="http://exist-db.org/xquery/console";
test:suite(
inspect:module-functions(xs:anyURI("transform2teisimple.xqm"))
)
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