Commit 1185cce3 authored by MRodz's avatar MRodz Committed by mrodzis
Browse files

Adapt to styleguide and add local:keep-element

parent 260b4e1e
xquery version "3.1";
import module namespace fontane-simple="http://fontane-nb.dariah.eu/teisimple" at "/db/apps/SADE/modules/fontane/transform2teisimple.xqm";
fontane-simple:main("16b00.xml")
\ No newline at end of file
......@@ -535,7 +535,7 @@ declare
%test:assertEquals("<hi xmlns=""http://www.tei-c.org/ns/1.0"" type=""vertical-mark"">Aber alles mehr</hi>")
%test:args("<zone xmlns=""http://www.tei-c.org/ns/1.0"" type=""highlighted"" style=""border-left-style:double""><zone xmlns=""http://www.tei-c.org/ns/1.0"" type=""highlighted"" style=""border-left-style:double""><line xmlns=""http://www.tei-c.org/ns/1.0"" style=""margin-left:0.2cm""><hi xmlns=""http://www.tei-c.org/ns/1.0"" xml:id=""B11_49v_a"" next=""#B11_41v_b"">Ein<seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""text-decoration:underline"">e koloſſa</seg>le</hi></line></zone></zone>")
%test:assertEquals("<hi xmlns=""http://www.tei-c.org/ns/1.0"" type=""vertical-mark""><hi xmlns=""http://www.tei-c.org/ns/1.0"">Eine kolossale</hi></hi>")
%test:assertEquals("<hi xmlns=""http://www.tei-c.org/ns/1.0"" type=""vertical-mark""><hi xmlns=""http://www.tei-c.org/ns/1.0"" xml:id=""B11_49v_a"" next=""#B11_41v_b"">Eine kolossale</hi></hi>")
function teisimple-test:analyze-vertical-marks($node as element(*)) {
fontane-simple:transform($node)
......
......@@ -77,21 +77,18 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
if($node[@break = "keepHyphen"]) then
()
else
$node
local:keep-element($node)
case element(tei:g) return
if($node[@ref = "#vds"]) then
()
else if($node/@ref ="#rth" or $node/@ref ="#hb") then
$node
local:keep-element($node)
else
fontane-simple:transform($node/node())
case element(tei:graphic)
return
element tei:graphic {
$node/@*
}
case element(tei:graphic) return
local:keep-element($node)
case element(tei:del) return
if($node/parent::tei:restore) then
......@@ -120,10 +117,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
element tei:add {
$node/@*,
fontane-simple:transform($node/node())
}
local:keep-element($node)
else if($node/@cause ="catchword" or $node/@cause ="unclear") then
()
else if(not($node/@xml:id)) then
......@@ -138,42 +132,37 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
case element(tei:addSpan) return
if($node/@type = "edited_text") then
$node
local:keep-element($node)
else
()
case element(tei:fw)
return
()
case element(tei:fw) return
()
case element(tei:line)
return
if(count($node/*) = 1 and $node/child::tei:fw) then
()
else if(not($node/@type = "item")) then
fontane-simple:transform($node/node())
else if($node/@type = "item" and not($node/@xml:id)) then
element tei:item {
fontane-simple:transform($node/node())
}
else if($node/@type = "item"
and fontane-simple:is-transposed($node)) then
()
else
case element(tei:line) return
if(count($node/*) = 1 and $node/child::tei:fw) then
()
else if(not($node/@type = "item")) then
fontane-simple:transform($node/node())
else if($node/@type = "item" and not($node/@xml:id)) then
element tei:item {
fontane-simple:transform($node/node())
}
else if($node/@type = "item"
and fontane-simple:is-transposed($node)) 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
()
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
local:keep-element($node)
else
()
(: if($node/following-sibling::*[1][count(./*) = 1 :)
(: and child::tei:fw or child::tei:stamp]):)
......@@ -183,109 +172,95 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
(: element tei:handShift {:)
(: $node/@*:)
(: }:)
case element(tei:stamp)
return
()
case element(tei:stamp) return
()
case element(tei:seg)
return
if(count($node/*) = 1 and
($node/child::tei:stamp or $node/child::tei:metamark[@function = "caret"]))
then
()
else if(matches($node/@style, "underline")
and not(matches($node/@style, "vertical-align"))) then
fontane-simple:transform($node/node())
else if(contains($node/@style, "vertical-align")) then
element tei:seg {
$node/@*,
fontane-simple:transform($node/node())
}
else if($node/@type = "initials" or $node/@type = "monogram"
or $node/@style or $node/@type = "multiphrase")
then
element tei:seg {
$node/@*,
fontane-simple:transform($node/node())
}
else if($node/@type = "auction_number"
or $node/@type = "cancel"
or $node/@type = "abort")
then
()
else
fontane-simple:transform($node/node())
case element(tei:seg) return
if(count($node/*) = 1 and
($node/child::tei:stamp or $node/child::tei:metamark[@function = "caret"]))
then
()
else if(matches($node/@style, "underline")
and not(matches($node/@style, "vertical-align"))) then
fontane-simple:transform($node/node())
else if(contains($node/@style, "vertical-align")) then
local:keep-element($node)
else if($node/@type = "initials" or $node/@type = "monogram"
or $node/@style or $node/@type = "multiphrase")
then
local:keep-element($node)
else if($node/@type = "auction_number"
or $node/@type = "cancel"
or $node/@type = "abort")
then
()
else
fontane-simple:transform($node/node())
case element(tei:hi) return
element tei:hi {
fontane-simple:transform($node/node())
}
local:keep-element($node)
case element(tei:anchor) return
$node
local:keep-element($node)
case element(tei:surface)
return
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)
case element(tei:surface) return
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
element tei:div{
attribute type {"page"},
fontane-simple:transform($node/node())
}
attribute facs {$node/@facs}
else
())
else if($node/@type = "label" and
(contains($node/@subtype, "Fontane")
or contains($node/@subtype, "Hersteller"))
()
},
(: 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"))
)
then
element tei:div {
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
then
element tei:div {
attribute type {"label"},
fontane-simple:transform($node/node())
else
()
case element(tei:gap)
return
element tei:gap {
$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
()
case element(tei:gap) return
local:keep-element($node)
case element(tei:metamark) return
if($node/@function = "integrate"
......@@ -387,16 +362,16 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
else
()
else
$node
local:keep-element($node)
case element(tei:figDesc) return
$node
local:keep-element($node)
case element(tei:ref) return
$node
local:keep-element($node)
case element(tei:space) return
$node
local:keep-element($node)
case element(tei:choice) return
local:keep-element($node)
......
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