Commit 93b1f42c authored by MRodz's avatar MRodz Committed by mrodzis
Browse files

Refactor headings

All possible ways to describe a heading in the original data now produce a
tei:head. In order to discern which headings had originally been tei:segs we
changed the tei:head's attributes: @type now specifies which element has
originally been encoded while @style denotes the size of the heading.
parent 645d256b
......@@ -245,19 +245,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
()
else if($node/@type = "heading") then
element tei:seg {
$node/@type,
$node/@subtype,
(if($node/@rendition) then
$node/@rendition
else
()),
(if($node/@rend) then
$node/@rend
else
()),
fontaneSimple:transform($node/node())
}
fontaneSimple:make-head($node)
else if(matches($node/@style, "underline")
and not(matches($node/@style, "vertical-align"))) then
......@@ -706,10 +694,11 @@ declare function fontaneSimple:copy-element($node as node()) as node() {
declare function fontaneSimple:make-head($node as node()) as element(tei:head) {
element tei:head {
(if($node/descendant::tei:seg[matches(@style, "font-size")]) then
attribute type {simpleHelpers:get-font-size($node)}
attribute style {simpleHelpers:get-font-size($node)}
else
attribute type {"default"}
attribute style {"default"}
),
attribute type {"former-" || $node/name()},
$node/@subtype,
(if($node/@rendition) then
$node/@rendition
......
......@@ -196,29 +196,29 @@ declare
declare
%test:name("Headings")
%test:args("<line xmlns=""http://www.tei-c.org/ns/1.0"" style=""margin-left:3.1cm"" type=""heading"" subtype=""chapter"" rend=""align(center)""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/><hi xmlns=""http://www.tei-c.org/ns/1.0""><seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""font-size:large; letter-spacing:0.2cm; text-decoration:underline"">Luther</seg></hi></line>")
%test:assertEquals("<head xmlns=""http://www.tei-c.org/ns/1.0"" type=""large"" subtype=""chapter"" rend=""align(center)""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" script="""" medium=""""/><hi xmlns=""http://www.tei-c.org/ns/1.0"">Luther</hi></head>")
%test:assertEquals("<head xmlns=""http://www.tei-c.org/ns/1.0"" style=""large"" type=""former-line"" subtype=""chapter"" rend=""align(center)""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" script="""" medium=""""/><hi xmlns=""http://www.tei-c.org/ns/1.0"">Luther</hi></head>")
%test:args("<zone xmlns=""http://www.tei-c.org/ns/1.0"" type=""heading"" subtype=""chapter""><line xmlns=""http://www.tei-c.org/ns/1.0"" style=""margin-left:1.5cm""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>4. <seg xmlns=""http://www.tei-c.org/ns/1.0""><rs xmlns=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""plc:Luetzen"">Lützen</rs></seg></line><line xmlns=""http://www.tei-c.org/ns/1.0"" style=""margin-left:3.7cm""><seg xmlns=""http://www.tei-c.org/ns/1.0""><rs xmlns=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""psn:Gustav_Adolf"">Guſtav <retrace xmlns=""http://www.tei-c.org/ns/1.0"">Ad</retrace>olf</rs></seg>. <seg xmlns=""http://www.tei-c.org/ns/1.0""><rs xmlns=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""plc:Weissenfels"">Weißenfels</rs></seg>.</line></zone>")
%test:assertEquals("<head xmlns=""http://www.tei-c.org/ns/1.0"" type=""default"" subtype=""chapter""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" script="""" medium=""""/>4. <rs xmlns=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""plc:Luetzen"">Lützen</rs><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><rs xmlns=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""psn:Gustav_Adolf"">Gustav Adolf</rs>. <rs xmlns=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""plc:Weissenfels"">Weißenfels</rs>.</head>")
%test:assertEquals("<head xmlns=""http://www.tei-c.org/ns/1.0"" style=""default"" type=""former-zone"" subtype=""chapter""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" script="""" medium=""""/>4. <rs xmlns=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""plc:Luetzen"">Lützen</rs><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><rs xmlns=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""psn:Gustav_Adolf"">Gustav Adolf</rs>. <rs xmlns=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""plc:Weissenfels"">Weißenfels</rs>.</head>")
%test:args("<line xmlns=""http://www.tei-c.org/ns/1.0""><seg xmlns=""http://www.tei-c.org/ns/1.0"" type=""heading""><seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""font-size:xx-large; font-weight:bold""><seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""letter-spacing:0.2cm""><seg xmlns=""http://www.tei-c.org/ns/1.0""><date xmlns=""http://www.tei-c.org/ns/1.0"" type=""synchronous"" when-iso=""1873""><hi xmlns=""http://www.tei-c.org/ns/1.0""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>1<seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""text-decoration:underline"" rend=""underline-style:wavy"">873</seg></hi></date></seg>.</seg></seg></seg></line>")
%test:assertEquals("<milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/>", "<seg xmlns=""http://www.tei-c.org/ns/1.0"" type=""heading""><seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""font-size:xx-large; font-weight:bold""><seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""letter-spacing:0.2cm""><date xmlns=""http://www.tei-c.org/ns/1.0"" type=""synchronous"" when=""1873""><hi xmlns=""http://www.tei-c.org/ns/1.0""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" script="""" medium=""""/>1873</hi></date>.</seg></seg></seg>")
%test:assertEquals("<milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/>", "<head xmlns=""http://www.tei-c.org/ns/1.0"" style=""xx-large"" type=""former-seg""><seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""font-size:xx-large; font-weight:bold""><seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""letter-spacing:0.2cm""><date xmlns=""http://www.tei-c.org/ns/1.0"" type=""synchronous"" when=""1873""><hi xmlns=""http://www.tei-c.org/ns/1.0""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" script="""" medium=""""/>1873</hi></date>.</seg></seg></head>")
(:examples from here on from 3.8.2.3. :)
%test:args("<line xmlns=""http://www.tei-c.org/ns/1.0"" style=""margin-left:3.1cm"" type=""heading"" rend=""align(center)""><hi xmlns=""http://www.tei-c.org/ns/1.0""><seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""text-decoration:underline"">Luther</seg></hi></line>")
%test:assertEquals("<head xmlns=""http://www.tei-c.org/ns/1.0"" type=""default"" rend=""align(center)""><hi xmlns=""http://www.tei-c.org/ns/1.0"">Luther</hi></head>")
%test:assertEquals("<head xmlns=""http://www.tei-c.org/ns/1.0"" style=""default"" type=""former-line"" rend=""align(center)""><hi xmlns=""http://www.tei-c.org/ns/1.0"">Luther</hi></head>")
%test:args("<line xmlns=""http://www.tei-c.org/ns/1.0""><seg xmlns=""http://www.tei-c.org/ns/1.0"" type=""heading""><hi xmlns=""http://www.tei-c.org/ns/1.0"">E<seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""text-decoration:underline"">lfter Brief.</seg></hi></seg></line>")
%test:assertEquals("<milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/>", "<seg xmlns=""http://www.tei-c.org/ns/1.0"" type=""heading""><hi xmlns=""http://www.tei-c.org/ns/1.0"">Elfter Brief.</hi></seg>")
%test:assertEquals("<milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/>", "<head xmlns=""http://www.tei-c.org/ns/1.0"" style=""default"" type=""former-seg""><hi xmlns=""http://www.tei-c.org/ns/1.0"">Elfter Brief.</hi></head>")
%test:args("<line xmlns=""http://www.tei-c.org/ns/1.0"" type=""heading"" subtype=""section"" rend=""align(right)""><hi xmlns=""http://www.tei-c.org/ns/1.0""><seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""text-decoration:underline"">Riva d. 15. A</seg>ugust</hi></line>")
%test:assertEquals("<head xmlns=""http://www.tei-c.org/ns/1.0"" type=""default"" subtype=""section"" rend=""align(right)""><hi xmlns=""http://www.tei-c.org/ns/1.0"">Riva d. 15. August</hi></head>")
%test:assertEquals("<head xmlns=""http://www.tei-c.org/ns/1.0"" style=""default"" type=""former-line"" subtype=""section"" rend=""align(right)""><hi xmlns=""http://www.tei-c.org/ns/1.0"">Riva d. 15. August</hi></head>")
%test:args("<zone xmlns=""http://www.tei-c.org/ns/1.0"" type=""heading"" rend=""align(center)""><line xmlns=""http://www.tei-c.org/ns/1.0""><hi>O<seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""text-decoration:underline"">ertlichkeite</seg>n</hi></line><line xmlns=""http://www.tei-c.org/ns/1.0""><hi>d<seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""text-decoration:underline"">eutſcher Sage und Geſ</seg>chichte</hi>.</line></zone>")
%test:assertEquals("<head xmlns=""http://www.tei-c.org/ns/1.0"" type=""default"" rend=""align(center)""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><hi xmlns=""http://www.tei-c.org/ns/1.0"">Oertlichkeiten</hi><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><hi>deutscher Sage und Geschichte</hi>.</head>")
%test:assertEquals("<head xmlns=""http://www.tei-c.org/ns/1.0"" style=""default"" type=""former-zone"" rend=""align(center)""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><hi xmlns=""http://www.tei-c.org/ns/1.0"">Oertlichkeiten</hi><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><hi>deutscher Sage und Geschichte</hi>.</head>")
%test:args("<zone xmlns=""http://www.tei-c.org/ns/1.0"" type=""heading"" subtype=""section"" rend=""align(center)""><line xmlns=""http://www.tei-c.org/ns/1.0""><hi>O<seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""text-decoration:underline"">ertlichkeite</seg>n</hi></line><line xmlns=""http://www.tei-c.org/ns/1.0""><hi>d<seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""text-decoration:underline"">eutſcher Sage und Geſ</seg>chichte</hi>.</line></zone>")
%test:assertEquals("<head xmlns=""http://www.tei-c.org/ns/1.0"" type=""default"" subtype=""section"" rend=""align(center)""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><hi xmlns=""http://www.tei-c.org/ns/1.0"">Oertlichkeiten</hi><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><hi>deutscher Sage und Geschichte</hi>.</head>")
%test:assertEquals("<head xmlns=""http://www.tei-c.org/ns/1.0"" style=""default"" type=""former-zone"" subtype=""section"" rend=""align(center)""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><hi xmlns=""http://www.tei-c.org/ns/1.0"">Oertlichkeiten</hi><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><hi>deutscher Sage und Geschichte</hi>.</head>")
function teisimple-test:analyze-headings($node as element(*)) {
fontaneSimple:transform($node)
......
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