Commit ae780d2e authored by Michelle Rodzis's avatar Michelle Rodzis Committed by mrodzis
Browse files

Add documentation

parent ac82a71c
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 and represent the latest layer of text.
:
: 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).
: This modules handles the conversion of the Fontante-TEI/XML into TEI simplePrint
: for the edited text. The resulting TEI simplePrint is the basis for the "Editerter
: Text" (edited text) view on the website and the book and represent the latest
: layer of text.
:
: @author Michelle Rodzis
: @version 0.1
: @since TODO
:)
module namespace fontane-simple="http://fontane-nb.dariah.eu/teisimple";
......@@ -60,11 +58,9 @@ declare function fontane-simple:main($file as xs:string) as xs:string? {
: The requirements are part of the encoding documentation, c.f.
: https://fontane-nb.dariah.eu/doku.html.
:
:
: @author Michelle Rodzis
: @param $nodes
: @return $node()* a TEISimple element
:
: @return $node()* a TEI simplePrint element
:)
declare function fontane-simple:transform($nodes as node()*) as node()* {
for $node in $nodes
......@@ -77,13 +73,13 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
if($node[@break = "keepHyphen"]) then
()
else
local:keep-element($node)
local:copy-element($node)
case element(tei:g) return
if($node[@ref = "#vds"]) then
()
else if($node/@ref ="#rth" or $node/@ref ="#hb") then
local:keep-element($node)
local:copy-element($node)
else
fontane-simple:transform($node/node())
......@@ -114,7 +110,7 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
case element(tei:add) return
if($node/@type = "edited_text"
or $node/child::tei:seg[@type = "multiphrase"]) then
local:keep-element($node)
local:copy-element($node)
else if($node/@cause ="catchword" or $node/@cause ="unclear") then
()
else if($node/@rend ="|") then
......@@ -131,7 +127,7 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
case element(tei:addSpan) return
if($node/@type = "edited_text") then
local:keep-element($node)
local:copy-element($node)
else
()
......@@ -142,7 +138,7 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
if(count($node/*) = 1 and $node/child::tei:fw) then
()
else if($node/@type = "heading") then
local:make-heading($node)
local:make-head($node)
else if(not($node/@type = "item")) then
fontane-simple:transform($node/node())
else if($node/@type = "item" and not($node/@xml:id)) then
......@@ -156,12 +152,12 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
fontane-simple:transform($node/node())
case element(tei:handShift) return
(: tei:handShift without @new denote the duct of the current
(: tei:local:copy-element($node)ft 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
local:keep-element($node)
local:copy-element($node)
else
()
......@@ -170,7 +166,7 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
(: then:)
(: ():)
(: else:)
(: element tei:handShift {:)
(: element tei:local:copy-element($node)ft {:)
(: $node/@*:)
(: }:)
case element(tei:stamp) return
......@@ -182,7 +178,7 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
then
()
else if($node/@type = "heading") then
local:make-heading($node)
local:make-head($node)
else if(matches($node/@style, "underline")
and not(matches($node/@style, "vertical-align"))) then
fontane-simple:transform($node/node())
......@@ -195,7 +191,7 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
else if($node/@type = "initials" or $node/@type = "monogram"
or $node/@type = "multiphrase")
then
local:keep-element($node)
local:copy-element($node)
else if($node/@type = "auction_number"
or $node/@type = "cancel"
or $node/@type = "abort"
......@@ -206,10 +202,10 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
fontane-simple:transform($node/node())
case element(tei:hi) return
local:keep-element($node)
local:copy-element($node)
case element(tei:anchor) return
local:keep-element($node)
local:copy-element($node)
case element(tei:surface) return
if(matches($node/@n, "cover")) then
......@@ -270,7 +266,7 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
fontane-simple:transform($node/node())
case element(tei:gap) return
local:keep-element($node)
local:copy-element($node)
case element(tei:metamark) return
if($node/@function = "integrate"
......@@ -350,7 +346,7 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
fontane-simple:transform($node/node())
}
else if($node/@type = "heading") then
local:make-heading($node)
local:make-head($node)
else if($node/@type = "list" or $node/@type = "item") then
element {QName("http://www.tei-c.org/ns/1.0", $node/@type)}{
$node/(@* except (@type, @ulx, @uly, @lrx, @lry, @rotate)),
......@@ -413,14 +409,14 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
else
()
else
local:keep-element($node)
local:copy-element($node)
case element(tei:note) return
if($node/@type = "authorial"
and not($node/@subtype = "footnote")) then
()
else
local:keep-element($node)
local:copy-element($node)
case element(tei:certainty) return
element {QName("http://www.tei-c.org/ns/1.0", "note")}{
......@@ -432,25 +428,25 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
}
case element(tei:figDesc) return
local:keep-element($node)
local:copy-element($node)
case element(tei:ref) return
local:keep-element($node)
local:copy-element($node)
case element(tei:space) return
local:keep-element($node)
local:copy-element($node)
case element(tei:choice) return
local:keep-element($node)
local:copy-element($node)
case element(tei:abbr) return
local:keep-element($node)
local:copy-element($node)
case element(tei:expan) return
local:keep-element($node)
local:copy-element($node)
case element(tei:rs) return
local:keep-element($node)
local:copy-element($node)
case element(tei:date) return
element {QName("http://www.tei-c.org/ns/1.0", $node/name())}{
......@@ -481,6 +477,17 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
};
(: TODO: adapt to general XML :)
(:~
: Determines whether the passed tei:handShift is contemporary or not. For the
: edited text we only need to consider contemporary hands or additions of
: Friedrich Fontane if they occur on labels and on the backside of calendar
: pages.
:
: TODO: check if we reach backside of calendar pages at all
: @author Michelle Rodzis
: @param $hand the tei:handShift/@new to be checked
: @return xs:boolean
: :)
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")
......@@ -493,6 +500,8 @@ declare function fontane-simple:is-hand-contemporary($hand as xs:string) as xs:b
false()
};
declare function fontane-simple:is-transposed($node as node()) as xs:boolean {
let $root := $node/ancestor::tei:TEI
return
......@@ -509,7 +518,19 @@ declare function fontane-simple:strip-element($node as node()) {
}
};
declare function local:prepare-text($node as text()) as text()? {
(:~
: Performs a couple of processing steps on a text node:
:
: 1. for the edited text only hyphens that are marked with
: <tei:lb break="keepHyphen"/> should be displayed
: 2. round s (ſ) is normalized to s
:
: @author Michelle Rodzis
: @param $node the current text node
: @return text() the formatted text
: :)
declare function local:prepare-text($node as text()) as text() {
let $cleared-hyphen :=
if(ends-with($node, "-") and not(local:keep-hyphen($node))) then
text {functx:substring-before-last($node, "-")}
......@@ -521,6 +542,14 @@ declare function local:prepare-text($node as text()) as text()? {
return text {$cleared-round-s}
};
(:~
: Checks if a hyphen should be kept for the edited text or not.
:
: @author Michelle Rodzis
: @param $node the current text node
: @return xs:boolean
: :)
declare function local:keep-hyphen($node as text()) as xs:boolean {
if($node/parent::tei:line/following-sibling::*[1][self::tei:lb[@break = "keepHyphen"]])
then
......@@ -529,7 +558,14 @@ declare function local:keep-hyphen($node as text()) as xs:boolean {
false()
};
declare function local:keep-element($node as node()) as node() {
(:~
: Takes a given element over as is since it is compliant to TEI simplePrint.
:
: @author Michelle Rodzis
: @param $node the current text node
: @return node() a copy of the current node
: :)
declare function local:copy-element($node as node()) as node() {
element {QName("http://www.tei-c.org/ns/1.0", $node/name())}{
$node/@*,
fontane-simple:transform($node/node())
......@@ -541,16 +577,32 @@ declare function local:has-valid-text($node as node()) as xs:boolean {
true()
};
(:~
: Creates a tei:pb.
:
: @author Michelle Rodzis
: @param $node the current tei:surface node
: @return element(tei:pb)
: :)
declare function local:make-pb($node as node()) as element(tei:pb) {
element {QName("http://www.tei-c.org/ns/1.0", "pb")}{
$node/@n
}
};
declare function local:make-heading($node as node()) as element(tei:head) {
(:~
: Creates a tei:head.
:
: @author Michelle Rodzis
: @param $node the current tei:line, tei:zone or tei:seg node
: @return element(tei:head)
: :)
declare function local:make-head($node as node()) as element(tei:head) {
element tei:head {
(if($node/descendant::tei:seg[matches(@style, "font-size")]) then
attribute type {local:get-fontsize($node)}
attribute type {local:get-font-size($node)}
else
attribute type {"default"}
),
......@@ -559,6 +611,14 @@ declare function local:make-heading($node as node()) as element(tei:head) {
}
};
(:~
: Creates a tei:div.
:
: @author Michelle Rodzis
: @param $node the current tei:surface node
: @return element(tei:div)
: :)
declare function local:make-div($node as node()) as element(tei:div) {
element tei:div{
$node/(@* except (@facs, @n, @attachment, @subtype, @ulx, @uly, @lrx, @lry, @points)),
......@@ -566,7 +626,15 @@ declare function local:make-div($node as node()) as element(tei:div) {
}
};
declare function local:get-fontsize($node as node()) as xs:string {
(:~
: Retrieves the font size from the @style of a tei:seg.
:
: @author Michelle Rodzis
: @param $node the current tei:line, tei:zone or tei:seg node with @type = heading
: @return xs:string the font size value
: :)
declare function local:get-font-size($node as node()) as xs:string {
(: example for style: "font-size:large; letter-spacing:0.2cm; text-decoration:underline" :)
let $tmp := substring-after($node/descendant-or-self::tei:seg[matches(@style, "font-size")]/@style, "font-size:")
return substring-before($tmp, ";")
......
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