Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
fontane-notizbuecher
SADE
Commits
6e11f94c
Commit
6e11f94c
authored
Jun 08, 2018
by
MRodz
Committed by
mrodzis
Feb 05, 2019
Browse files
Fix bugs in test setup and start TDD
parent
35d665c6
Changes
3
Hide whitespace changes
Inline
Side-by-side
modules/fontane/teisimple-test-runner.xq
View file @
6e11f94c
...
...
@@ -6,6 +6,8 @@ import module namespace teisimple-test = "http://fontane-nb.dariah.eu/teisimple-
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"
;
declare
namespace
tei
=
"http://www.tei-c.org/ns/1.0"
;
test:suite
(
util:list-functions
(
"http://fontane-nb.dariah.eu/teisimple-test"
)
)
...
...
modules/fontane/teisimple-test.xql
View file @
6e11f94c
...
...
@@ -7,10 +7,34 @@ module namespace teisimple-test = "http://fontane-nb.dariah.eu/teisimple-test";
import module namespace fontane-simple="http://fontane-nb.dariah.eu/teisimple" at "transform2teisimple.xqm";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace test="http://exist-db.org/xquery/xqsuite";
declare
%test:name("Meant to succeed")
%test:args("Testtext")
%test:assertEquals("Testtext")
function teisimple-test:meant-to-succeed($node as text()) {
fontane-simple:transform($node)
};
declare
%test:name("Meant to fail")
%test:args("Testtext")
%test:assertEquals("a wrong output")
function teisimple-test:meant-to-fail($node as text()) {
fontane-simple:transform($node)
};
function teisimple-test:analyze-transformation($node as node()) {
fontane-simple:transform($node)
declare
%test:name("Labels on Covers")
%test:args("<surface xmlns=""http://www.tei-c.org/ns/1.0"" type=""label"" subtype=""Signaturen-Klebchen_Archivar_alt""/>")
%test:assertEmpty
%test:args("<surface xmlns=""http://www.tei-c.org/ns/1.0"" type=""label"" subtype=""Etikett_vom_Notizbuch-Hersteller_angefertigt""/>")
%test:assertEquals("<div xmlns=""http://www.tei-c.org/ns/1.0"" type=""label""/>")
%test:args("<surface xmlns=""http://www.tei-c.org/ns/1.0"" type=""label"" subtype=""Etikett_von_Fontane_angefertigt_-_Aufgeklebtes_Blatt""/>")
%test:assertEquals("<div xmlns=""http://www.tei-c.org/ns/1.0"" type=""label""/>")
function teisimple-test:analyze-labels($node as element(*)) {
fontane-simple:transform($node)
};
\ No newline at end of file
modules/fontane/transform2teisimple.xqm
View file @
6e11f94c
...
...
@@ -33,16 +33,21 @@ declare function fontane-simple:main($file as xs:string) as element(tei:TEI) {
} 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">
let $front-covers := $doc//tei:sourceDoc/tei:surface[contains(@n, "front_cover")]/*
let $back-covers := $doc//tei:sourceDoc/tei:surface[contains(@n, "back_cover")]/*
let $content := $doc//tei:sourceDoc/tei:surface[not(contains(@n, "cover")
and matches(@n, "spine"))]
return
<TEI xmlns="http://www.tei-c.org/ns/1.0">
{$doc//tei:teiHeader}
{$transform}
<text>
<front>{fontane-simple:transform($front-covers)}</front>
<body>{fontane-simple:transform($content)}</body>
<back>{fontane-simple:transform($back-covers)}</back>
</text>
</TEI>
return $tei-simple
};
...
...
@@ -53,39 +58,19 @@ declare function fontane-simple:transform($nodes as node()*) as item()* {
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
()
return
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
(
)
fontane-simple:transform($node/node()
)
};
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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