Commit a3c5066e authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

Merge branch 'release/4.7.0'

parents 1197fa06 b0140ce1
project.name=http://textgrid.de/ns/SADE-fontane-develop project.name=http://textgrid.de/ns/SADE-fontane-develop
project.version=4.6.0 project.version=4.7.0
project.title=[Fontane] SADE project.title=[Fontane] SADE
project.abbrev=SADE-fontane-develop project.abbrev=SADE-fontane-develop
project.processorversion=4.7.0 project.processorversion=4.7.0
......
xquery version "3.1";
(:~
: This module is responsible for getting an XML version of the abbreviations
: index which can be converted to TeX. This XML version is appended to
: fontane-full.xml during the creation of the intermediate format in etTransfo.xmq.
:
: @author Michelle Weidling
: @version 0.1
: @since v4.0.
:)
module namespace abbrev-index="http://fontane-nb.dariah.eu/abbrev-index";
import module namespace config="http://textgrid.de/ns/SADE/config" at "../../config/config.xqm";
declare namespace map = "http://www.w3.org/2005/xpath-functions/map";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace xhtml="http://www.w3.org/1999/xhtml";
declare function abbrev-index:main() as element(tei:div) {
let $docs-coll := collection("/db/sade-projects/textgrid/data/xml/doku/")
let $file := $docs-coll[matches(base-uri(.), "verzeichnis_der_abkuerzungen")]/*
let $transformed :=
abbrev-index:transform($file)
=> abbrev-index:tidy()
return
element tei:div {
attribute type {"abbrev-index"},
$transformed
}
};
(:~
: Handles the transformation from XHTML to XML.
:
: @param $nodes The nodes currently processed
: @return The transformed nodes
:)
declare function abbrev-index:transform($nodes as node()*) as node()* {
for $node in $nodes return
typeswitch ($node)
case text() return
if(matches($node, "important")
or matches($node, "Gesamtdokumentation")) then
()
else
text {
replace($node, "ſ", "s")
=> replace("m̄", "mm")
=> replace("n̄", "nn")
}
case element(xhtml:h2) return
()
case element(xhtml:h3) return
element tei:head {
attribute type {"table-head"},
abbrev-index:transform($node/node())
}
case element(xhtml:tr) return
element tei:row {
if($node/ancestor::xhtml:thead
or $node/child::xhtml:th) then
attribute role {"head"}
else
(),
abbrev-index:transform($node/node())
}
case element(xhtml:td) return
element tei:cell {
abbrev-index:transform($node/node())
}
case element(xhtml:th) return
element tei:cell {
abbrev-index:transform($node/node())
}
case element(xhtml:thead) return
abbrev-index:transform($node/node())
case element(xhtml:br) return
element tei:lb {
abbrev-index:transform($node/node())
}
case element(xhtml:i) return
()
case element(xhtml:a) return
if($node/text()) then
abbrev-index:transform($node/node())
else
()
case element(xhtml:span) return
abbrev-index:transform($node/node())
default return
element {QName("http://www.tei-c.org/ns/1.0", $node/local-name())} {
abbrev-index:transform($node/node())
}
};
(:~
: Removes empty elements.
:
: @param $nodes The nodes currently processed
: @return The transformed nodes
:)
declare function abbrev-index:tidy($nodes as node()*) as node()* {
for $node in $nodes return
typeswitch ($node)
case text() return
$node
default return
if($node//text()[matches(., "[\w\d]") and not(normalize-space(.) = "")]
or $node[self::tei:lb]) then
element {QName("http://www.tei-c.org/ns/1.0", $node/local-name())} {
$node/@*,
abbrev-index:tidy($node/node())
}
else
()
};
...@@ -16,10 +16,12 @@ module namespace etTransfo="http://fontane-nb.dariah.eu/etTransfo"; ...@@ -16,10 +16,12 @@ module namespace etTransfo="http://fontane-nb.dariah.eu/etTransfo";
declare namespace tei="http://www.tei-c.org/ns/1.0"; declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace xi="http://www.w3.org/2001/XInclude"; declare namespace xi="http://www.w3.org/2001/XInclude";
import module namespace abbrev-index="http://fontane-nb.dariah.eu/abbrev-index" at "abbrev-index.xqm";
import module namespace config="http://textgrid.de/ns/SADE/config" at "../../config/config.xqm"; import module namespace config="http://textgrid.de/ns/SADE/config" at "../../config/config.xqm";
import module namespace fontaneSimple="http://fontane-nb.dariah.eu/teisimple" at "tei2teisimple.xqm"; import module namespace fontaneSimple="http://fontane-nb.dariah.eu/teisimple" at "tei2teisimple.xqm";
import module namespace fsort="http://fontane-nb.dariah.eu/sort" at "sort.xqm"; import module namespace fsort="http://fontane-nb.dariah.eu/sort" at "sort.xqm";
import module namespace functx = "http://www.functx.com"; import module namespace functx = "http://www.functx.com";
import module namespace macro-sort="http://fontane-nb.dariah.eu/macro-sort" at "macro-sort.xqm";
import module namespace prepCom="http://fontane-nb.dariah.eu/prepCom" at "prepcom.xqm"; import module namespace prepCom="http://fontane-nb.dariah.eu/prepCom" at "prepcom.xqm";
import module namespace presort="http://fontane-nb.dariah.eu/presort" at "presort.xqm"; import module namespace presort="http://fontane-nb.dariah.eu/presort" at "presort.xqm";
import module namespace simple2xhtml="http://fontane-nb.dariah.eu/simple2xhtml" at "simple2xhtml.xqm"; import module namespace simple2xhtml="http://fontane-nb.dariah.eu/simple2xhtml" at "simple2xhtml.xqm";
...@@ -27,13 +29,15 @@ import module namespace tidySimple ="http://fontane-nb.dariah.eu/tidysimple" at ...@@ -27,13 +29,15 @@ import module namespace tidySimple ="http://fontane-nb.dariah.eu/tidysimple" at
declare variable $etTransfo:cases := declare variable $etTransfo:cases :=
( (
"3qtcz.xml", (: case C :) (: "3qtcz.xml", (: case C :):)
"3qtqv.xml" (: case A :) "3qtqv.xml" (: case A :)
(: "3qtqw.xml" (: case B :) :) (: "3qtqw.xml" (: case B :) :)
(: "3qtqx.xml" (: case D :):) (: "3qtqx.xml" (: case D :):)
(: "3qtqz.xml" (: case E :):) (: "3qtqz.xml" (: case E :):)
); );
declare variable $etTransfo:dir := "/db/apps/SADE/modules/fontane/edited-text/";
(:~ (:~
: The main function : The main function
...@@ -51,18 +55,11 @@ declare function etTransfo:complete() { ...@@ -51,18 +55,11 @@ declare function etTransfo:complete() {
etTransfo:create-print-tei() etTransfo:create-print-tei()
} catch * { } catch * {
error(QName("error", "ETTRANSFO02"), "An error occured while creating the whole TEI base for print.") error(QName("error", "ETTRANSFO02"), "An error occured while creating the whole TEI base for print.")
} },
etTransfo:tidy-logs()
}; };
declare function etTransfo:transform-on-publish($notebook) {
try {
etTransfo:transform-tei($notebook//tei:TEI)
} catch * {
error(QName("error", "ETTRANSFO05"), "Could not transform " || $notebook//tei:title[1]/string() || " to XHTML.")
}
};
(:~ (:~
: Resolves all XIncludes in a given case file and copies all notebooks belonging to a case into one file. : Resolves all XIncludes in a given case file and copies all notebooks belonging to a case into one file.
: :
...@@ -99,11 +96,11 @@ declare function etTransfo:create-case($showcase as xs:string) as xs:string { ...@@ -99,11 +96,11 @@ declare function etTransfo:create-case($showcase as xs:string) as xs:string {
error(QName("error", "ETTRANSFO04"), "Couldn't find the node tei:TEI of " || $uri || ".") error(QName("error", "ETTRANSFO04"), "Couldn't find the node tei:TEI of " || $uri || ".")
} }
let $updated-notebook := let $updated-notebook :=
element {QName("http://www.tei-c.org/ns/1.0", "TEI")} { element tei:TEI {
attribute id {$uri}, attribute id {$uri},
$tei-referred-to/@*, $tei-referred-to/@*,
$tei-referred-to/* $tei-referred-to/*
} }
return update replace $xi with $updated-notebook return update replace $xi with $updated-notebook
return return
...@@ -144,20 +141,32 @@ declare function etTransfo:create-htmls($showcase as xs:string) as xs:string+ { ...@@ -144,20 +141,32 @@ declare function etTransfo:create-htmls($showcase as xs:string) as xs:string+ {
let $teis := etTransfo:get-teis($showcase) let $teis := etTransfo:get-teis($showcase)
for $tei in $teis return for $tei in $teis return
etTransfo:transform-tei($tei) let $log := etTransfo:create-log(substring-after($tei//tei:idno[@type = "TextGrid"], "textgrid:"))
return
etTransfo:transform-tei($tei, $log)
}; };
declare function etTransfo:transform-tei($tei as element(tei:TEI)) {
fsort:main($tei) (:~
: Handles the transformation to the intermediate format and the XHTML
: representation.
:
: @param $tei The current notebook as element(tei:TEI)
:)
declare function etTransfo:transform-tei($tei as element(tei:TEI), $log as xs:string) {
(: macro-sort:main($tei, $tei/@id):)
(: => fsort:main():)
fsort:main($tei, $log)
=> prepCom:main($tei/@id) => prepCom:main($tei/@id)
=> fontaneSimple:main($tei/@id) => fontaneSimple:main($tei/@id, $log)
=> tidySimple:main($tei/@id) => tidySimple:main($tei/@id)
(: => simple2xhtml:main($tei/@id):) => simple2xhtml:main($tei/@id)
}; };
(:~ (:~
: Assembles the intermediate format version of each notebook and copies them into one file called "fontane-full.xml". : Assembles the intermediate format version of each notebook and copies them into one file called "fontane-full.xml".
: Furthermore, additional data needed for the print is appended.
: :
: @author Michelle Weidling : @author Michelle Weidling
: @return A string indicating the location where the full TEI/XML of the edition was stored to. : @return A string indicating the location where the full TEI/XML of the edition was stored to.
...@@ -171,6 +180,12 @@ declare function etTransfo:create-print-tei() as xs:string { ...@@ -171,6 +180,12 @@ declare function etTransfo:create-print-tei() as xs:string {
etTransfo:get-literature() etTransfo:get-literature()
} catch * { } catch * {
error(QName("error", "ETTRANSFO06"), "An error occured while creating the bibliography.") error(QName("error", "ETTRANSFO06"), "An error occured while creating the bibliography.")
},
try {
abbrev-index:main()
} catch * {
error(QName("error", "ETTRANSFO07"), "An error occured while creating the index of abbreviations.")
} }
} }
return return
...@@ -183,16 +198,10 @@ declare function etTransfo:create-print-tei() as xs:string { ...@@ -183,16 +198,10 @@ declare function etTransfo:create-print-tei() as xs:string {
: @author Michelle Weidling : @author Michelle Weidling
: @return All available final intermediate format TEI/XML files as opened documents : @return All available final intermediate format TEI/XML files as opened documents
:) :)
declare function etTransfo:get-all-xmls() { declare function etTransfo:get-all-xmls() as node()+ {
for $res in collection($config:data-root || "/print/xml/") for $res in collection($config:data-root || "/print/xml/")
[contains(base-uri(.), ".xml") [contains(base-uri(.), ".xml")
and not(contains(base-uri(.), "tmp")) and not(contains(substring-after(base-uri(.), "/print/xml/"), "-"))]
and not(contains(base-uri(.), "presort"))
and not(contains(base-uri(.), "prepared"))
and not(contains(base-uri(.), "prepcom"))
and not(contains(base-uri(.), "fontane"))
and not(contains(base-uri(.), "all-headers"))
and not(contains(base-uri(.), "Kasten"))]
order by $res/tei:TEI/@key1, number($res/tei:TEI/@key2) order by $res/tei:TEI/@key1, number($res/tei:TEI/@key2)
return return
$res $res
...@@ -210,52 +219,38 @@ declare function etTransfo:get-literature() as element(tei:div) { ...@@ -210,52 +219,38 @@ declare function etTransfo:get-literature() as element(tei:div) {
element {QName("http://www.tei-c.org/ns/1.0", "text")} { element {QName("http://www.tei-c.org/ns/1.0", "text")} {
attribute type {"bibliography"}, attribute type {"bibliography"},
element {QName("http://www.tei-c.org/ns/1.0", "div")} { element tei:div {
attribute n {"Fontanes_Werke"}, attribute n {"Fontanes_Werke"},
element {QName("http://www.tei-c.org/ns/1.0", "div")} { local:make-bib-div("Erstausgaben"),
attribute n {"Erstausgaben"}, local:make-bib-div("Werkausgaben"),
etTransfo:make-bib-entries("Erstausgaben") local:make-bib-div("Briefausgaben"),
}, local:make-bib-div("Postume_Einzelausgaben"),
element {QName("http://www.tei-c.org/ns/1.0", "div")} { local:make-bib-div("Populaere_postume_Einzelausgaben")
attribute n {"Werkausgaben"},
etTransfo:make-bib-entries("Werkausgaben")
},
element {QName("http://www.tei-c.org/ns/1.0", "div")} {
attribute n {"Briefausgaben"},
etTransfo:make-bib-entries("Briefausgaben")
},
element {QName("http://www.tei-c.org/ns/1.0", "div")} {
attribute n {"Postume_Einzelausgaben"},
etTransfo:make-bib-entries("Postume_Einzelausgaben")
},
element {QName("http://www.tei-c.org/ns/1.0", "div")} {
attribute n {"Populaere_postume_Einzelausgaben"},
etTransfo:make-bib-entries("Populaere_postume_Einzelausgaben")
}
},
element {QName("http://www.tei-c.org/ns/1.0", "div")} {
attribute n {"Fontanes_Quellen"},
etTransfo:make-bib-entries("Fontanes_Quellen")
},
element {QName("http://www.tei-c.org/ns/1.0", "div")} {
attribute n {"Allgemeine_Nachschlagewerke"},
etTransfo:make-bib-entries("Allgemeine_Nachschlagewerke")
}, },
local:make-bib-div("Fontanes_Quellen"),
local:make-bib-div("Allgemeine_Nachschlagewerke"),
local:make-bib-div("Nachschlagewerke_der_Fontane-Forschung"),
local:make-bib-div("Forschungsliteratur")
}
};
element {QName("http://www.tei-c.org/ns/1.0", "div")} {
attribute n {"Nachschlagewerke_der_Fontane-Forschung"},
etTransfo:make-bib-entries("Nachschlagewerke_der_Fontane-Forschung")
},
element {QName("http://www.tei-c.org/ns/1.0", "div")} { (:~
attribute n {"Forschungsliteratur"}, : An auxiliary function to create the tei:div elements in the bibliography.
etTransfo:make-bib-entries("Forschungsliteratur") :
} : @author Michelle Weidling
: @param $identifier An identifier for a subtype of scholarly literature
: @return a tei:div containing all bibliographic information of the literatur's subtype
:)
declare function local:make-bib-div($identifier as xs:string) as element(tei:div) {
element tei:div {
attribute n {$identifier},
etTransfo:make-bib-entries($identifier)
} }
}; };
(:~ (:~
: Creates a div containing all the scholarly literature ("Forschungsliteratur") : Creates a div containing all the scholarly literature ("Forschungsliteratur")
: of a kind that's listed in the respective index. Examples for this are : of a kind that's listed in the respective index. Examples for this are
...@@ -277,14 +272,14 @@ declare function etTransfo:make-bib-entries($type as xs:string) as element(tei:d ...@@ -277,14 +272,14 @@ declare function etTransfo:make-bib-entries($type as xs:string) as element(tei:d
let $bib-no := count($entry/ancestor::tei:bibl) let $bib-no := count($entry/ancestor::tei:bibl)
return return
element {QName("http://www.tei-c.org/ns/1.0", "div")} { element tei:div {
attribute type {"entry"}, attribute type {"entry"},
element {QName("http://www.tei-c.org/ns/1.0", "seg")} { element tei:seg {
attribute type {"abbr"}, attribute type {"abbr"},
$abbr $abbr
}, },
if($full-ref) then if($full-ref) then
element {QName("http://www.tei-c.org/ns/1.0", "seg")} { element tei:seg {
attribute type {"full"}, attribute type {"full"},
$full-ref $full-ref
} }
...@@ -296,11 +291,11 @@ declare function etTransfo:make-bib-entries($type as xs:string) as element(tei:d ...@@ -296,11 +291,11 @@ declare function etTransfo:make-bib-entries($type as xs:string) as element(tei:d
let $same-as-loc := $referenced-entry/ancestor::tei:listBibl[1]/@type/string() let $same-as-loc := $referenced-entry/ancestor::tei:listBibl[1]/@type/string()
return return
(element {QName("http://www.tei-c.org/ns/1.0", "seg")} { (element tei:seg {
attribute type {"same-as"}, attribute type {"same-as"},
$same-as $same-as
}, },
element {QName("http://www.tei-c.org/ns/1.0", "seg")} { element tei:seg {
attribute type {"same-as-loc"}, attribute type {"same-as-loc"},
$same-as-loc $same-as-loc
}) })
...@@ -308,7 +303,7 @@ declare function etTransfo:make-bib-entries($type as xs:string) as element(tei:d ...@@ -308,7 +303,7 @@ declare function etTransfo:make-bib-entries($type as xs:string) as element(tei:d
else else
(), (),
if($bib-no gt 0) then if($bib-no gt 0) then
element {QName("http://www.tei-c.org/ns/1.0", "seg")} { element tei:seg {
attribute type {"sub-entry"}, attribute type {"sub-entry"},
$bib-no $bib-no
} }
...@@ -316,3 +311,34 @@ declare function etTransfo:make-bib-entries($type as xs:string) as element(tei:d ...@@ -316,3 +311,34 @@ declare function etTransfo:make-bib-entries($type as xs:string) as element(tei:d
() ()
} }
}; };
declare function etTransfo:create-log($uri as xs:string) as xs:string {
let $assure-dir-available := etTransfo:assure-dir-available("logs")
let $log-name := $uri || "-log.xml"
return xmldb:store($etTransfo:dir || "logs", $log-name, <log/>)
};
declare function etTransfo:assure-dir-available($dir-name as xs:string) {
if(xmldb:collection-available($etTransfo:dir || "logs")) then
$etTransfo:dir || "logs"
else
xmldb:create-collection($etTransfo:dir, "logs")
};
(:~
: Only the logs which acutally contain info should be kept.
:
:)
declare function etTransfo:tidy-logs() {
for $log in collection($etTransfo:dir || "logs/") return
if($log//LogEntry) then
()
else
let $uri := substring-after(base-uri($log), "logs/")
return
xmldb:remove($etTransfo:dir || "logs/", $uri)
};
...@@ -49,7 +49,7 @@ declare variable $index-info:place-map := ...@@ -49,7 +49,7 @@ declare variable $index-info:place-map :=
declare variable $index-info:psn-map := declare variable $index-info:psn-map :=
map:merge(for $entry in doc($config:data-root ||"/data/253sx.xml")//*[self::tei:person or self::tei:personGrp] map:merge(for $entry in doc($config:data-root ||"/data/253sx.xml")//*[self::tei:person or self::tei:personGrp]
let $same-as := $entry/ancestor::tei:listPerson//tei:person[not(@xml:id)][descendant::tei:ptr[contains(@target, $entry/@xml:id)]]/tei:persName let $same-as := $entry/ancestor::tei:listPerson//tei:person[not(@xml:id)][descendant::tei:ptr[@target = concat("#", $entry/@xml:id)]]/tei:persName
return return
map:entry(string($entry/@xml:id), map:entry(string($entry/@xml:id),
...@@ -85,50 +85,54 @@ declare variable $index-info:wrk-map := ...@@ -85,50 +85,54 @@ declare variable $index-info:wrk-map :=
else else
"false" "false"
let $same-as :=
if($periodical) then
$entry/ancestor::tei:list[@type = "periodicals"]//tei:item[not(@xml:id)][descendant::tei:ptr[@target = concat("#", $entry/@xml:id)]]/tei:name
else
()
let $same-as :=
if(count($same-as) gt 1) then
string-join($same-as/string(), ", ")
else if(count($same-as) = 1) then
$same-as/string()
else
()
let $general-map :=
map {
"regular-name" : string-join($entry/tei:name[not(@type)], ", "),
"periodical" : $is-periodical,
"type" : "work"
}
return return
if($creators and $periodical) then if($creators and $periodical
map:entry(string($entry/@xml:id), or $creators) then
map { let $updated-map := map:put($general-map, "creator-ids", string-join($creator-ids, " "))
"regular-name" : string-join($entry/tei:name[not(@type)], ", "),
"creator-ids" : string-join($creator-ids, " "), return
"periodical" : $is-periodical, map:entry(string($entry/@xml:id),
"type" : "work" if($same-as) then
} map:put($updated-map, "same-as", $same-as)
) else
else if($creators) then $updated-map
map:entry(string($entry/@xml:id), )
map {
"regular-name" : string-join($entry/tei:name[not(@type)], ", "),
"creator-ids" : string-join($creator-ids, " "),
"periodical" : $is-periodical,
"type" : "work"
}
)
else if($created-by-fontane) then else if($created-by-fontane) then
map:entry(string($entry/@xml:id), map:entry(string($entry/@xml:id),
map { map:put($general-map, "creator", "Fontane")
"regular-name" : string-join($entry/tei:name[not(@type)], ", "),
"creator" : "Fontane",
"periodical" : $is-periodical,
"type" : "work"
}
) )
else if($periodical) then else if($periodical) then
map:entry(string($entry/@xml:id), map:entry(string($entry/@xml:id),
map { if($same-as) then
"regular-name" : string-join($entry/tei:name[not(@type)], ", "), map:put($general-map, "same-as", $same-as)
"periodical" : $is-periodical, else
"type" : "work" $general-map
}
) )
else else
map:entry(string($entry/@xml:id), map:entry(string($entry/@xml:id),
map { map:put($general-map, "creator", "Anonym/nicht ermittelt")
"regular-name" : string-join($entry/tei:name[not(@type)], ", "),
"creator" : "Anonym/nicht ermittelt",
"periodical" : $is-periodical,
"type" : "work"
}
), ),
(: (fictional) characters mentioned/depicted in works :) (: (fictional) characters mentioned/depicted in works :)
for $person in doc($config:data-root || "/data/253t3.xml")//tei:person for $person in doc($config:data-root || "/data/253t3.xml")//tei:person
......
xquery version "3.1";
module namespace macro-sort="http://fontane-nb.dariah.eu/macro-sort";
import module namespace config="http://textgrid.de/ns/SADE/config" at "../../config/config.xqm";
declare namespace tei="http://www.tei-c.org/ns/1.0";