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

Update surname

parent d4a9adba
......@@ -3,7 +3,7 @@ xquery version "3.1";
(:~
: @@@
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @version 0.1
: @since TODO
:)
......
......@@ -4,7 +4,7 @@ xquery version "3.1";
: This modules runs the first and second process that transforms the Fontane
: TEI subset into a simpler TEI encoding.
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @version 1.0
:)
......
......@@ -6,7 +6,7 @@ xquery version "3.1";
: Text" (edited text) view on the website and the book. It represents the latest
: layer of text.
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @version 0.1
: @since TODO
:)
......@@ -61,7 +61,7 @@ declare function fontaneSimple:main($file as xs:string) as node()? {
: because it is easier to perform these steps after the XML hierarchy has been
: flattened a bit.
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @param $nodes the elements of the book covers and the book content
: @return $node()* a TEI simplePrint element
:)
......@@ -678,7 +678,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
(:~
: Takes a given element over as is since it is compliant to TEI simplePrint.
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @param $node the current text node
: @return node() a copy of the current node
:)
......@@ -696,7 +696,7 @@ declare function fontaneSimple:copy-element($node as node()) as node() {
(:~
: Creates a tei:head with an @rendition and a font-size, if available.
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @param $node the current tei:line, tei:zone or tei:seg node
: @return element(tei:head)
: :)
......@@ -724,7 +724,7 @@ declare function fontaneSimple:make-head($node as node()) as element(tei:head) {
(:~
: Creates a tei:div.
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @param $node the current tei:surface node
: @return element(tei:div)
: :)
......@@ -739,7 +739,7 @@ as element(tei:div) {
(:~
: Creates a new tei:seg with all relevant rendition information.
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @param $node the current tei:zone, tei:line, or tei:seg element
: @return element(tei:seg)
:)
......@@ -760,7 +760,7 @@ as element(tei:seg) {
(:~
: Creates a tei:pb.
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @param $node the current tei:surface node
: @return element(tei:pb)
:)
......@@ -777,7 +777,7 @@ as element(tei:pb) {
: This function is mainly used to separate the inner and outer book covers from
: each other.
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @param $node the current tei:surface node
: @return element(tei:pb)
:)
......
......@@ -4,7 +4,7 @@ xquery version "3.1";
: This module contains a potpourri of functions that are needed to serialize
: the TEI simplePrint version of the Fontane TEI encoding.
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @version 1.0
:)
......@@ -22,7 +22,7 @@ import module namespace functx = "http://www.functx.com";
: Determines whether the passed tei:milestone is contemporary or not.
:
: TODO: check if we reach backside of calendar pages at all
: @author Michelle Rodzis
: @author Michelle Weidling
: @param $hand the tei:milestone/@subtype or tei:mod/@hand to be checked
: @return xs:boolean
:)
......@@ -46,7 +46,7 @@ as xs:boolean {
:
: TODO: doesn't work at the moment
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @param $node the current TEI node to be checked
: @return xs:boolean
:)
......@@ -70,7 +70,7 @@ as xs:boolean {
: 3. the Tironian note is normalized to "etc.""
: 4. inserts an additional whitespace if a line ends with a character (TODO)
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @param $node the current text node
: @return text() the formatted text
: :)
......@@ -82,9 +82,9 @@ declare function simpleHelpers:prepare-text($node as text()) as text()? {
string which leads to problems while preparing the text any further. :)
let $cleared-hyphen :=
if(ends-with($node, "-") and not(simpleHelpers:keep-hyphen($node))) then
text {functx:substring-before-last($node, "-") || "@"}
text {functx:substring-before-last($node, "-") || "@P"}
else if(ends-with($node, "⸗") and not(simpleHelpers:keep-hyphen($node))) then
text {functx:substring-before-last($node, "⸗") || "@"}
text {functx:substring-before-last($node, "⸗") || "@P"}
else
replace($node, "⸗", "-")
let $cleared-round-s := replace($cleared-hyphen, "ſ", "s")
......@@ -102,10 +102,10 @@ declare function simpleHelpers:prepare-text($node as text()) as text()? {
(: in cases where a given $node only consists of a hyphen we don't
return a text node because it's unnecessary and leads to problems
while testing. :)
if(matches($cleared-Tironian, "@")
if(matches($cleared-Tironian, "@P")
and string-length($cleared-Tironian) gt 1
or not(matches($cleared-Tironian, "@"))) then
text {replace($cleared-Tironian, "@", "")}
or not(matches($cleared-Tironian, "@P"))) then
text {$cleared-Tironian}
else
()
else if(normalize-space($node) = "" and matches($node, " ")) then
......@@ -118,7 +118,7 @@ declare function simpleHelpers:prepare-text($node as text()) as text()? {
(:~
: Checks if a hyphen should be kept for the edited text or not.
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @param $node the current text node
: @return xs:boolean
:)
......@@ -134,7 +134,7 @@ declare function simpleHelpers:keep-hyphen($node as text()) as xs:boolean {
(:~
: Checks if the current node has valid text.
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @param $node
: @return xs:boolean
:)
......@@ -158,7 +158,7 @@ declare function simpleHelpers:has-valid-text($node as node()) as xs:boolean {
: on a calendar (TODO)). The same holds for notes of the modern editors which
: are marked by @type = "edited_text".
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @node a text node
: @return xs:boolean
:)
......@@ -180,7 +180,7 @@ declare function simpleHelpers:is-valid-text($node as text()) as xs:boolean {
: Checks if the current tei:surface is a page. Pages can be recognized by their
: pagination (e.g. 4v) in the node's @n.
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @node element(tei:surface)
: @return xs:boolean
:)
......@@ -193,7 +193,7 @@ as xs:boolean {
(:~
: Retrieves the font size from the @style of a tei:seg.
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @param $node the current tei:line, tei:zone or tei:seg node with @type = heading
: @return xs:string the font size value
: :)
......@@ -207,7 +207,7 @@ declare function simpleHelpers:get-font-size($node as node()) as xs:string {
(:~
: Checks if a node's @style attribute contains any relevant information.
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @param $node the current tei:zone, tei:line, or tei:seg node
: @return xs:boolean
:)
......@@ -238,7 +238,7 @@ as xs:boolean {
: into one element for convenience reasons.
: TODO: check if @rendition is the right attribute for that
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @param $node the current tei:zone, tei:line, or tei:seg element
: @return a string of all relevant information
:)
......@@ -281,7 +281,7 @@ declare function simpleHelpers:filter-rendition($node as node()) as xs:string* {
: occur on labels and on the backside of calendar pages.
:
: TODO check if we reach calendar pages
: @author Michelle Rodzis
: @author Michelle Weidling
: @param $hands a string sequence containing all contemporary hands that are
: declared in tei:handNotes
: @param $node the current tei:milestone[@unit = "handshift"] element
......@@ -330,7 +330,7 @@ $node as element(tei:milestone)) as element(tei:milestone){
: current milestone[@unit = "handshift"]. They are the same if they have the
: same attributes.
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @param $node the current tei:milestone[@unit = "handshift"] element
: @return xs:boolean
:)
......@@ -355,7 +355,7 @@ $node as element(tei:milestone)) as xs:boolean {
: current milestone[@unit = "handshift"]. They are the same if they have the
: same attributes.
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @param $node the current tei:milestone[@unit = "handshift"] element
: @return xs:boolean
:)
......
......@@ -6,7 +6,7 @@ xquery version "3.1";
: Text" (edited text) view on the website and the book. It represents the latest
: layer of text.
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @version 0.1
: @since TODO
:)
......@@ -31,15 +31,13 @@ declare variable $tidySimple:valid-hands :=
declare function tidySimple:main($tei as node()*) {
let $text := $tei//tei:text
let $clear-invalid-hands := tidySimple:sort-out-invalid-hands($text)
let $clear-surplus-hands := tidySimple:sort-out-surplus-elements($clear-invalid-hands)
(: let $correct-namespace := tidySimple:correct-namespace($clear-surplus-hands):)
let $tidy := tidySimple:sort-out-invalid-hands($tei//tei:text)
=> tidySimple:sort-out-surplus-elements()
=> tidySimple:whitespaces()
(: let $text-with-sections := tidySimple:make-structure($clear-surplus-hands):)
let $header := $tei/tei:teiHeader
let $store := xmldb:store("/db/apps/SADE/resources/xml/", "tei-simple-tmp.xml", <TEI xmlns="http://www.tei-c.org/ns/1.0">{$header}{$clear-surplus-hands}</TEI>)
(: let $store := xmldb:store("/db/apps/SADE/resources/xml/", "tei-simple-tmp.xml", <div>{$clear-surplus-hands}</div>):)
return "done"
return
xmldb:store("/db/apps/SADE/resources/xml/", "tei-simple-tmp.xml", <TEI xmlns="http://www.tei-c.org/ns/1.0">{$header}{$tidy}</TEI>)
(: let $doc := doc($config:app-root || "/resources/xml/tei-simple-tmp.xml"):)
(: let $tidied-text := tidySimple:tidy($doc//tei:text):)
(: let $final-tei:=:)
......@@ -185,13 +183,13 @@ declare function tidySimple:copy-element($node as node(), $flag as xs:string)
(:~
: Purges surplus attributes from tei:milestone[@unit = "handshift"].
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @param $node the current tei:milestone[@unit = "handshift"]
: @return the purged tei:milestone[@unit = "handshift"]
: :)
declare function tidySimple:clear-handshift($node as element(tei:milestone))
as element(tei:milestone) {
element {QName("http://www.tei-c.org/ns/1.0", $node/name())} {
element tei:milestone {
attribute unit {"handshift"},
if($node/@subtype = "") then
()
......@@ -249,7 +247,7 @@ declare function tidySimple:make-structure($nodes as node()*) as node()* {
: Checks if a given node is between a tei:milestone[@unit = "section"] and its
: corresponing tei:anchor.
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @param the current node
: @return xs:boolean
: :)
......@@ -274,13 +272,13 @@ declare function tidySimple:is-in-section($node as node()) as xs:boolean {
: structural information (e.g. tei:milestone[@unit = "paragraph"]), these nodes
: cannot simply be copied but have to be transformed as well.
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @param $node the current tei:milestone[@unit = "section"]
: @return element(tei:div)
: :)
declare function tidySimple:make-section($node as element(tei:milestone))
as element(tei:div) {
element {QName("http://www.tei-c.org/ns/1.0", "div")} {
element tei:div {
attribute type {"section"},
tidySimple:get-section-chunk($node)
}
......@@ -291,7 +289,7 @@ as element(tei:div) {
: Returns all nodes between a tei:milestone[@unit = "section"] and its
: corresponding tei:anchor.
:
: @author Michelle Rodzis
: @author Michelle Weidling
: @param the current tei:milestone element
: @return all nodes between the current element and the respective tei:anchor
:)
......@@ -308,11 +306,41 @@ declare function tidySimple:tidy($nodes as node()*) as node()* {
()
};
declare function tidySimple:correct-namespace($nodes as node()*) as node()* {
declare function tidySimple:whitespaces($nodes as node()*) as node()* {
for $node in $nodes return
typeswitch($node)
case text() return
$node
default return ()
default return
element {QName("http://www.tei-c.org/ns/1.0", $node/name())} {
$node/@*,
if($node/@next) then
let $target-id := replace($node/@next, "#", "")
let $target := $node/ancestor::tei:text//*[@xml:id = $target-id]
return
(if(not(ends-with($node//text()[last()], "@P"))
and ($node/following::*[. << $target][self::tei:milestone[@unit = "line"]]
or $target/following::*[. << $node][self::tei:milestone[@unit = "line"]])) then
attribute break {"true"}
else
(),
if($node/following::text()[. << $target][not(normalize-space(.) = "")]
or $target/following::text()[. << $node][not(normalize-space(.) = "")]) then
attribute text-inbetween {"true"}
else
())
else if($node/@prev) then
let $target-id := replace($node/@prev, "#", "")
let $target := $node/ancestor::tei:text//*[@xml:id = $target-id]
return
if($node/following::text()[. << $target][not(normalize-space(.) = "")]
or $target/following::text()[. << $node][not(normalize-space(.) = "")]) then
attribute text-inbetween {"true"}
else
()
else
(),
tidySimple:whitespaces($node/node())
}
};
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
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