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

Add 3.8.2.2 verses and dialogues

parent be762692
......@@ -180,17 +180,33 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
simpleHelpers:trim-first-char($node))
else if($node/@type = "verse") then
(if(not($node/preceding-sibling::tei:line[@type = "verse"])) then
fontaneSimple:mark-linegroup-beginning()
else
(),
element tei:l {
fontaneSimple:transform($node/node())
},
if(not($node/following-sibling::tei:line[@type = "verse"])) then
fontaneSimple:mark-linegroup-end()
if(not($node/@next)) then
(if(not($node/preceding-sibling::tei:line[@type = "verse"])) then
fontaneSimple:mark-linegroup-beginning()
else
(),
element tei:l {
fontaneSimple:transform($node/node())
},
if(not($node/following-sibling::tei:line[@type = "verse"])) then
fontaneSimple:mark-linegroup-end()
else
())
(: 3.8.2.2.1.3 Vers mit anderer Beschriftung in einer Zeile :)
else
())
let $corresp := $node/following::tei:seg[@type = "verse"
and matches($node/@next, @xml:id)]
return
(fontaneSimple:mark-linegroup-beginning(),
element tei:l {
fontaneSimple:transform($node/node()),
simpleHelpers:start-line($node),
fontaneSimple:transform($corresp/node())
},
fontaneSimple:mark-linegroup-end())
else if($node/parent::tei:zone[@type = "verse"]/child::*[1] = $node) then
fontaneSimple:transform($node/node())
(: with opting for a tei:milestone we try to meet the project's
requirements on the one hand while avoiding to run into hierarchical
......@@ -252,6 +268,29 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
else if($node/parent::tei:add and $node/@copyOf) then
fontaneSimple:mark-intervention($node)
else if($node/@type = "verse" and $node/@prev) then
()
else if($node/@type = "said") then
if($node/@next) then
(: let $corresp := console:log($node/following::*[matches($node/@next, @xml:id)]):)
let $next := replace($node/@next, "#", "")
let $corresp := $node/following::*[@xml:id = $next]
return
(element tei:seg {
$node/@type,
fontaneSimple:transform($node/node()),
fontaneSimple:transform($corresp/node())
},
element tei:lb {
attribute type {"edited_text"}
})
else
element tei:seg {
$node/@type,
fontaneSimple:transform($node/node())
}
else
fontaneSimple:transform($node/node())
......@@ -406,6 +445,28 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
fontaneSimple:transform($node/node())
}
else if($node/@type = "dialogue") then
element tei:div {
$node/@type,
fontaneSimple:transform($node/node())
}
else if($node/@type = "verse") then
(fontaneSimple:mark-linegroup-beginning(),
element tei:l {
fontaneSimple:transform($node/node())
},
fontaneSimple:mark-linegroup-end())
else if($node/@type = "said" and $node/@prev) then
()
else if($node/@type = "said") then
element tei:seg {
$node/@type,
fontaneSimple:transform($node/node())
}
else if($node/@type = "toc") then
element tei:list {
attribute type {"toc"},
......@@ -436,6 +497,18 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
else
fontaneSimple:transform($node/node())
case element(tei:said) return
(element tei:seg {
attribute type {"said"},
fontaneSimple:transform($node/node())
},
if($node/ancestor::tei:zone[@type = "dialogue"]/descendant::tei:said[position() != last()] = $node) then
element tei:lb {
attribute type {"edited_text"}
}
else
())
case element(tei:figure) return
if(count($node/child::*) = 1 and $node/child::tei:figDesc) then
......
......@@ -401,7 +401,7 @@ as text() {
return text{$trim-first-char}
};
declare function simpleHelpers:start-line($node as element(tei:line))
declare function simpleHelpers:start-line($node as element())
as element(tei:milestone) {
element tei:milestone {
attribute unit {"line"},
......
......@@ -158,6 +158,38 @@ declare
fontaneSimple:transform($node)
};
(: 3.8.2.2.1 Verses :)
declare
%test:name("Verses")
%test:args("<zone xmlns=""http://www.tei-c.org/ns/1.0"" rend=""indent""><line xmlns=""http://www.tei-c.org/ns/1.0"" style=""margin-left:1.3cm"" type=""verse"">Für König und für Vaterland,</line><line xmlns=""http://www.tei-c.org/ns/1.0"" style=""margin-left:1.3cm"" type=""verse"">Mit Gott, im blutgen Krieg,</line></zone>")
%test:assertEquals("<milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""start-lg""/>", "<l xmlns=""http://www.tei-c.org/ns/1.0"">Für König und für Vaterland,</l>", "<l xmlns=""http://www.tei-c.org/ns/1.0"">Mit Gott, im blutgen Krieg,</l>", "<milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""end-lg""/>")
%test:args("<zone xmlns=""http://www.tei-c.org/ns/1.0""><zone xmlns=""http://www.tei-c.org/ns/1.0"" type=""verse"" rend=""indent""><line xmlns=""http://www.tei-c.org/ns/1.0"" style=""margin-left:1.8cm"">Ein leiſes Wölkchen ſteigt</line><line xmlns=""http://www.tei-c.org/ns/1.0"" style=""margin-left:2.0cm"">Ein Knall rollt herüber</line></zone></zone>")
%test:assertEquals("<milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""start-lg""/>", "<l xmlns=""http://www.tei-c.org/ns/1.0"">Ein leises Wölkchen steigt<milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/>Ein Knall rollt herüber</l>", "<milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""end-lg""/>")
%test:args("<zone xmlns=""http://www.tei-c.org/ns/1.0""><zone xmlns=""http://www.tei-c.org/ns/1.0""><line xmlns=""http://www.tei-c.org/ns/1.0"" xml:id=""C05_52v_a"" next=""#C05_52v_b"" type=""verse"">Denkt an</line></zone><zone xmlns=""http://www.tei-c.org/ns/1.0""><line xmlns=""http://www.tei-c.org/ns/1.0""><seg xmlns=""http://www.tei-c.org/ns/1.0"" type=""verse"" xml:id=""C05_52v_b"" prev=""#C05_52v_a"">Luther.</seg> Zum</line><line xmlns=""http://www.tei-c.org/ns/1.0"">Andenken</line></zone></zone>")
%test:assertEquals("<milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""start-lg""/>", "<l xmlns=""http://www.tei-c.org/ns/1.0"">Denkt an<milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/>Luther.</l>", "<milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""end-lg""/>", "<milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/>", " Zum", "<milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/>", "Andenken")
function teisimple-test:analyze-verse($node as element(*)) {
fontaneSimple:transform($node)
};
(: 3.8.2.2.2 Dialogues :)
declare
%test:name("Dialogues")
%test:args("<zone xmlns=""http://www.tei-c.org/ns/1.0"" type=""dialogue""><line xmlns=""http://www.tei-c.org/ns/1.0""><hi xmlns=""http://www.tei-c.org/ns/1.0""><seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""text-decoration:underlinie"">Er</seg></hi>. <seg><said xmlns=""http://www.tei-c.org/ns/1.0"">Nun kommt der Däne nicht wieder.</said></seg></line><line xmlns=""http://www.tei-c.org/ns/1.0""><hi xmlns=""http://www.tei-c.org/ns/1.0""><seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""text-decoration:underlinie"">Ich</seg></hi>. <seg><said xmlns=""http://www.tei-c.org/ns/1.0"">Wer weiß.</said></seg></line></zone>")
%test:assertEquals("<div xmlns=""http://www.tei-c.org/ns/1.0"" type=""dialogue""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><hi xmlns=""http://www.tei-c.org/ns/1.0"">Er</hi>. <seg xmlns=""http://www.tei-c.org/ns/1.0"" type =""said"">Nun kommt der Däne nicht wieder.</seg><lb xmlns=""http://www.tei-c.org/ns/1.0"" type=""edited_text""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><hi>Ich</hi>. <seg xmlns=""http://www.tei-c.org/ns/1.0"" type =""said"">Wer weiß.</seg></div>")
%test:args("<zone xmlns=""http://www.tei-c.org/ns/1.0"" type=""dialogue""><line xmlns=""http://www.tei-c.org/ns/1.0""><seg xmlns=""http://www.tei-c.org/ns/1.0"" xml:id=""D07_69v_a"" next=""#D07_69v_1"" type=""said"">Hören Se, </seg></line><zone xmlns=""http://www.tei-c.org/ns/1.0"" xml:id=""D07_69v_1"" prev=""#D07_69v_a"" type=""said""><line xmlns=""http://www.tei-c.org/ns/1.0"">der ganze Krieg war nich</line><line xmlns=""http://www.tei-c.org/ns/1.0"">nöthig.</line></zone><zone xmlns=""http://www.tei-c.org/ns/1.0"" type=""said""><line xmlns=""http://www.tei-c.org/ns/1.0"" rend=""indent"">Nich?</line></zone></zone>")
%test:assertEquals("<div xmlns=""http://www.tei-c.org/ns/1.0"" type=""dialogue""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><seg xmlns=""http://www.tei-c.org/ns/1.0"" type =""said"">Hören Se, <milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/>der ganze Krieg war nich<milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/>nöthig.</seg><lb xmlns=""http://www.tei-c.org/ns/1.0"" type=""edited_text""/><seg xmlns=""http://www.tei-c.org/ns/1.0"" type =""said""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line"" rend=""indent""/>Nich?</seg></div>")
function teisimple-test:analyze-dialogues($node as element(*)) {
fontaneSimple:transform($node)
};
(: BOOK COVERS :)
declare
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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