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

Add elements

parent b589ad7b
......@@ -10,6 +10,7 @@ import module namespace fontane-simple="http://fontane-nb.dariah.eu/teisimple" a
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace test="http://exist-db.org/xquery/xqsuite";
(: GENERAL :)
declare
%test:name("Meant to succeed")
......@@ -27,6 +28,54 @@ declare
fontane-simple:transform($node)
};
(: BOOK COVERS :)
declare
%test:name("Book covers: outer_front_cover")
%test:args("<surface xmlns=""http://www.tei-c.org/ns/1.0"" n=""outer_front_cover""
facs=""http://textgridrep.org/textgrid:164g9"" xml:id=""a5""/>")
%test:assertEquals("<div xmlns=""http://www.tei-c.org/ns/1.0"" type=""outer_front_cover""
facs=""http://textgridrep.org/textgrid:164g9"" xml:id=""a5""/>")
function teisimple-test:analyze-outer-front-covers($node as element(*)) {
fontane-simple:transform($node)
};
declare
%test:name("Book covers: inner_front_cover")
%test:args("<surface xmlns=""http://www.tei-c.org/ns/1.0"" n=""inner_front_cover""
facs=""http://textgridrep.org/textgrid:164g9"" xml:id=""a5""/>")
%test:assertEquals("<pb xmlns=""http://www.tei-c.org/ns/1.0"" type=""flyleaf""/>",
"<div xmlns=""http://www.tei-c.org/ns/1.0""
type=""inner_front_cover"" facs=""http://textgridrep.org/textgrid:164g9""
xml:id=""a5""/>")
function teisimple-test:analyze-inner-front-covers($node as element(*)) {
fontane-simple:transform($node)
};
declare
%test:name("Book covers: outer_back_cover")
%test:args("<surface xmlns=""http://www.tei-c.org/ns/1.0"" n=""outer_back_cover""
facs=""http://textgridrep.org/textgrid:164g9"" xml:id=""a5""/>")
%test:assertEquals("<pb xmlns=""http://www.tei-c.org/ns/1.0"" type=""flyleaf""/>",
"<div xmlns=""http://www.tei-c.org/ns/1.0""
type=""outer_back_cover"" facs=""http://textgridrep.org/textgrid:164g9""
xml:id=""a5""/>")
function teisimple-test:analyze-outer-back-covers($node as element(*)) {
fontane-simple:transform($node)
};
declare
%test:name("Book covers: inner_back_cover")
%test:args("<surface xmlns=""http://www.tei-c.org/ns/1.0"" n=""inner_back_cover""
facs=""http://textgridrep.org/textgrid:164g9"" xml:id=""a5""/>")
%test:assertEquals("<pb xmlns=""http://www.tei-c.org/ns/1.0"" type=""cover""/>",
"<div xmlns=""http://www.tei-c.org/ns/1.0"" type=""inner_back_cover""
facs=""http://textgridrep.org/textgrid:164g9"" xml:id=""a5""/>")
function teisimple-test:analyze-inner-back-covers($node as element(*)) {
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""/>")
......@@ -37,4 +86,181 @@ declare
%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
};
(: PAGES :)
declare
%test:name("Pages")
%test:args("<surface xmlns=""http://www.tei-c.org/ns/1.0"" n=""1r"" facs=""http://textgridrep.org/textgrid:164h2""/>")
%test:assertEquals("<pb xmlns=""http://www.tei-c.org/ns/1.0"" n=""1r"" facs=""http://textgridrep.org/textgrid:164h2""/>", "<div xmlns=""http://www.tei-c.org/ns/1.0"" type=""page""/>")
function teisimple-test:analyze-pages($node as element(*)) {
fontane-simple:transform($node)
};
(: GRAPHICS :)
declare
%test:name("Graphics")
%test:args("<graphic xmlns=""http://www.tei-c.org/ns/1.0"" n=""C07_001"" url=""http://textgridrep.org/textgrid:164g9"" mimeType=""image/jpeg""/>")
%test:assertEquals("<graphic xmlns=""http://www.tei-c.org/ns/1.0"" n=""C07_001"" url=""http://textgridrep.org/textgrid:164g9"" mimeType=""image/jpeg""/>")
function teisimple-test:analyze-graphics($node as element(*)) {
fontane-simple:transform($node)
};
(: GENETIC INFORMATION :)
declare
%test:name("Deletions")
%test:args("<del xmlns=""http://www.tei-c.org/ns/1.0"">(Dann folgen wohl Reiſe</del>")
%test:assertEmpty
function teisimple-test:analyze-del($node as element(*)) {
fontane-simple:transform($node)
};
(: PAGINATION AND STAMPS, AUCTIONS :)
declare
%test:name("Pagination alone")
%test:args("<fw xmlns=""http://www.tei-c.org/ns/1.0"" type=""pageNum"">5</fw>")
%test:assertEmpty
function teisimple-test:analyze-pag-so($node as element(*)) {
fontane-simple:transform($node)
};
declare
%test:name("Pagination with lines")
%test:args("<line xmlns=""http://www.tei-c.org/ns/1.0""><fw xmlns=""http://www.tei-c.org/ns/1.0"" type=""pageNum"">5</fw></line>")
%test:assertEmpty
function teisimple-test:analyze-pag-lines($node as element(*)) {
fontane-simple:transform($node)
};
declare
%test:name("Pagination with handschift before")
%test:args("<zone xmlns=""http://www.tei-c.org/ns/1.0""><handShift new=""#Archivar1""/><line xmlns=""http://www.tei-c.org/ns/1.0""><fw xmlns=""http://www.tei-c.org/ns/1.0"" type=""pageNum"">5</fw></line></zone>")
%test:assertEmpty
function teisimple-test:analyze-pag-hs($node as element(*)) {
fontane-simple:transform($node)
};
declare
%test:name("Stamp alone")
%test:args("<stamp xmlns=""http://www.tei-c.org/ns/1.0"">STAATSBIBLIOTHEK •BERLIN•</stamp>")
%test:assertEmpty
function teisimple-test:analyze-stamp($node as element(*)) {
fontane-simple:transform($node)
};
declare
%test:name("Stamp in seg")
%test:args("<seg xmlns=""http://www.tei-c.org/ns/1.0""><stamp xmlns=""http://www.tei-c.org/ns/1.0"">STAATSBIBLIOTHEK •BERLIN•</stamp></seg>")
%test:assertEmpty
function teisimple-test:analyze-stamp-seg($node as element(*)) {
fontane-simple:transform($node)
};
declare
%test:name("Stamp with handschift before")
%test:args("<zone xmlns=""http://www.tei-c.org/ns/1.0""><handShift new=""#Stempel1""/><seg xmlns=""http://www.tei-c.org/ns/1.0""><stamp xmlns=""http://www.tei-c.org/ns/1.0"">STAATSBIBLIOTHEK •BERLIN•</stamp></seg></zone>")
%test:assertEmpty
function teisimple-test:analyze-stamp-hs($node as element(*)) {
fontane-simple:transform($node)
};
declare
%test:name("Auction numbers")
%test:args("<seg xmlns=""http://www.tei-c.org/ns/1.0"" type=""auction_number"">5<mod xmlns=""http://www.tei-c.org/ns/1.0"" type=""subst""><del xmlns=""http://www.tei-c.org/ns/1.0"" rend=""overwritten"">10</del><add place=""superimposed"">09</add></mod>-7</seg>")
%test:assertEmpty
function teisimple-test:analyze-auction($node as element(*)) {
fontane-simple:transform($node)
};
(: PAGE FRAGMENTS AND EMPTY PAGES :)
declare
%test:name("Empty pages")
%test:args("<surface xmlns=""http://www.tei-c.org/ns/1.0"" n=""26r"" type=""fragment"" attachment=""torn""><zone xmlns=""http://www.tei-c.org/ns/1.0""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Archivar1""/><line xmlns=""http://www.tei-c.org/ns/1.0"" style=""margin-left:0.5cm""><fw xmlns=""http://www.tei-c.org/ns/1.0"" type=""pageNum"">26</fw></line><handShift new=""#Fontane""/></zone></surface>")
%test:assertEquals("<pb xmlns=""http://www.tei-c.org/ns/1.0"" n=""26r""/>", "<div xmlns=""http://www.tei-c.org/ns/1.0"" type=""page""/>")
(: adapt when further pages are implemented :)
%test:args("<surface xmlns=""http://www.tei-c.org/ns/1.0"" n=""26r"" type=""fragment"" attachment=""torn""><zone xmlns=""http://www.tei-c.org/ns/1.0""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Archivar1""/><line xmlns=""http://www.tei-c.org/ns/1.0"" style=""margin-left:0.5cm""><fw xmlns=""http://www.tei-c.org/ns/1.0"" type=""pageNum"">26</fw></line><handShift new=""#Fontane""/><line>Gewöhnliches Briefpapier.</line></zone></surface>")
%test:assertEquals("<pb xmlns=""http://www.tei-c.org/ns/1.0"" n=""26r""/>", "<div xmlns=""http://www.tei-c.org/ns/1.0"" type=""page""><handShift new=""#Fontane""/>Gewöhnliches Briefpapier.</div>")
function teisimple-test:analyze-page-fragment($node as element(*)) {
fontane-simple:transform($node)
};
(: GEMINATION :)
declare
%test:name("Gemination")
%test:args("<g xmlns=""http://www.tei-c.org/ns/1.0"" ref=""#mgem"">mm</g>")
%test:assertEquals("mm")
%test:args("<g xmlns=""http://www.tei-c.org/ns/1.0"" ref=""#ngem"">nn</g>")
%test:assertEquals("nn")
function teisimple-test:analyze-gemination($node as element(*)) {
fontane-simple:transform($node)
};
(: HANDSHIFTS :)
(: Friedrich Fontane, hier noch Besonderheiten beachten! :)
declare
%test:name("Handshifts")
%test:args("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>")
%test:assertEquals("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>")
%test:args("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Friedrich_Fontane""/>")
%test:assertEquals("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Friedrich_Fontane""/>")
%test:args("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Archivar1""/>")
%test:assertEmpty
%test:args("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#fremde_Hand1""/>")
%test:assertEmpty
%test:args("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Stempel2""/>")
%test:assertEmpty
%test:args("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" script=""Latn clean""/>")
%test:assertEquals("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" script=""Latn clean""/>")
%test:args("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" script=""Latn clean""/>")
%test:assertEquals("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" script=""Latn clean""/>")
%test:args("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Archivar_1"" script=""Latn clean""/>")
%test:assertEmpty
function teisimple-test:analyze-handshift($node as element(*)) {
fontane-simple:transform($node)
};
(: FONTS :)
declare
%test:name("Fonts")
%test:args("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" script=""Latn""/>")
%test:assertEquals("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" script=""Latn""/>")
%test:args("<seg xmlns=""http://www.tei-c.org/ns/1.0"" type=""initials"">LVNGiS</seg>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" type=""initials"">LVNGiS</seg>")
%test:args("<seg xmlns=""http://www.tei-c.org/ns/1.0"" type=""monogram"">LC</seg>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" type=""monogram"">LC</seg>")
function teisimple-test:analyze-fonts($node as element(*)) {
fontane-simple:transform($node)
};
(: WRITING MEDIUM :)
declare
%test:name("Writing medium")
%test:args("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" medium=""black_ink thin_pen""/>")
%test:assertEquals("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" medium=""black_ink thin_pen""/>")
%test:args("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" medium=""pencil""/>")
%test:assertEquals("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" medium=""pencil""/>")
function teisimple-test:analyze-medium($node as element(*)) {
fontane-simple:transform($node)
};
(: WORD, LETTER AND CHARACTER SPACING :)
declare
%test:name("Spacing")
%test:args("<seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""letter-spacing:0.2cm;"">1</seg>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""letter-spacing:0.2cm;"">1</seg>")
function teisimple-test:analyze-spacing($node as element(*)) {
fontane-simple:transform($node)
};
(: ILLEGIBLE CHARACTERS :)
......@@ -70,9 +70,107 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
case text()
return
$node
case element(tei:graphic)
return
element{"tei:graphic"}{
$node/@*
}
case element(tei:del)
return
()
case element(tei:fw)
return
()
case element(tei:line)
return
if(count($node/*) = 1 and $node/child::tei:fw)
then
()
else
fontane-simple:transform($node/node())
case element(tei:handShift)
return
(: tei:handShift without @new denote the duct of the current
writer or a change of writing medium :)
if($node/@new and (fontane-simple:is-hand-contemporary($node/@new) or
$node/@new = "#Friedrich_Fontane") or not($node/@new))
then
element{"tei:handShift"}{
$node/@*
}
else
()
(: if($node/following-sibling::*[1][count(./*) = 1 :)
(: and child::tei:fw or child::tei:stamp]):)
(: then:)
(: ():)
(: else:)
(: element{"tei:handShift"}{:)
(: $node/@*:)
(: }:)
case element(tei:stamp)
return
()
case element(tei:seg)
return
if(count($node/*) = 1 and $node/child::tei:stamp)
then
()
else if($node/@type = "initials" or $node/@type = "monogram" or
$node/@style)
then
element{"tei:seg"}{
$node/@*,
fontane-simple:transform($node/node())
}
else if($node/@type = "auction_number")
then
()
else
fontane-simple:transform($node/node())
case element(tei:surface)
return
if($node/@type = "label" and
if(matches($node/@n, "cover"))
then
(if(not($node/@n = "outer_front_cover"))
then
element{"tei:pb"}{
if($node/@n = "inner_front_cover"
or $node/@n = "outer_back_cover")
then
attribute{"type"}{"flyleaf"}
else
attribute{"type"}{"cover"}
}
else
(),
element{"tei:div"}{
attribute{"facs"}{$node/@facs},
attribute{"xml:id"}{$node/@xml:id},
attribute{"type"}{$node/@n},
fontane-simple:transform($node/node())
})
else if(matches($node/@n, "[0-9]{1,4}[rv]{1}"))
then
(element{"tei:pb"}{
attribute{"n"}{$node/@n},
if($node/@facs)
then
attribute{"facs"}{$node/@facs}
else
()
},
(: if all descendant text nodes shoudln't be serialized, z.g. parent::fw or parent::stamp :)
if($node)
then
element{"tei:div"}{
attribute{"type"}{"page"},
fontane-simple:transform($node/node())
}
else
())
else if($node/@type = "label" and
(contains($node/@subtype, "Fontane")
or contains($node/@subtype, "Hersteller"))
)
......@@ -81,8 +179,25 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
attribute{"type"}{"label"},
fontane-simple:transform($node/node())
}
else if($node/@type = "fragment"
and $node/descendant::text()[not(ancestor::tei:fw or ancestor::tei:stamp)])
then
fontane-simple:transform($node/node())
else
()
default return
fontane-simple:transform($node/node())
};
(: TODO: adapt to general XML :)
declare function fontane-simple:is-hand-contemporary($hand as xs:string) as xs:boolean {
let $hand := replace($hand, "#", "")
let $file := doc("/db/sade-projects/textgrid/data/xml/data/16b00.xml")
let $handNote := $file//tei:handNote[@xml:id = $hand]
return
if($handNote/@script = "contemporary")
then
true()
else
false()
};
\ No newline at end of file
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