Commit 330b26f4 authored by MRodz's avatar MRodz Committed by mrodzis
Browse files

Add first draft for headings

parent 347968a3
......@@ -103,7 +103,6 @@ declare
fontane-simple:transform($node)
};
(: BOOK COVERS :)
declare
......@@ -179,6 +178,22 @@ declare
fontane-simple:transform($node)
};
(: HEADINGS :)
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)""><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""><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"">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"">4. <rs xmlns=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""plc:Luetzen"">Lützen</rs><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("<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"">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>")
%test:assertEquals("<head xmlns=""http://www.tei-c.org/ns/1.0"" type=""xx-large""><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-iso=""1873""><hi xmlns=""http://www.tei-c.org/ns/1.0"">1873</hi></date>.</seg></seg></head>")
function teisimple-test:analyze-headings($node as element(*)) {
fontane-simple:transform($node)
};
(: GENETIC INFORMATION :)
(: 3.21.11. DELETIONS :)
......
......@@ -141,6 +141,8 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
case element(tei:line) return
if(count($node/*) = 1 and $node/child::tei:fw) then
()
else if($node/@type = "heading") then
local:make-heading($node)
else if(not($node/@type = "item")) then
fontane-simple:transform($node/node())
else if($node/@type = "item" and not($node/@xml:id)) then
......@@ -149,7 +151,7 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
}
else if($node/@type = "item"
and fontane-simple:is-transposed($node)) then
()
()
else
fontane-simple:transform($node/node())
......@@ -179,6 +181,8 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
($node/child::tei:stamp or $node/child::tei:metamark[@function = "caret"]))
then
()
else if($node/@type = "heading") then
local:make-heading($node)
else if(matches($node/@style, "underline")
and not(matches($node/@style, "vertical-align"))) then
fontane-simple:transform($node/node())
......@@ -354,6 +358,8 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
|| "margin-top:" || $node/@uly || "cm"},
fontane-simple:transform($node/node())
}
else if($node/@type = "heading") then
local:make-heading($node)
else if($node/@type = "list" or $node/@type = "item") then
element {QName("http://www.tei-c.org/ns/1.0", $node/@type)}{
$node/(@* except @type),
......@@ -450,6 +456,12 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
local:keep-element($node)
case element(tei:expan) return
local:keep-element($node)
case element(tei:rs) return
local:keep-element($node)
case element(tei:date) return
local:keep-element($node)
case element(tei:ptr) return
......@@ -527,4 +539,22 @@ declare function local:make-pb($node as node()) as element(tei:pb) {
element {QName("http://www.tei-c.org/ns/1.0", "pb")}{
$node/@n
}
};
declare function local:make-heading($node as node()) as element(tei:head) {
element tei:head {
(if($node/descendant::tei:seg[matches(@style, "font-size")]) then
attribute type {local:get-fontsize($node)}
else
attribute type {"default"}
),
$node/@subtype,
fontane-simple:transform($node/node())
}
};
declare function local:get-fontsize($node as node()) as xs:string {
(: example for style: "font-size:large; letter-spacing:0.2cm; text-decoration:underline" :)
let $tmp := substring-after($node/descendant-or-self::tei:seg[matches(@style, "font-size")]/@style, "font-size:")
return substring-before($tmp, ";")
};
\ No newline at end of file
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