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

Adapt to TEI simplePrint schema

parent 85765a77
......@@ -121,7 +121,7 @@ declare
(: restoring text :)
%test:args("<restore xmlns=""http://www.tei-c.org/ns/1.0""><del xmlns=""http://www.tei-c.org/ns/1.0""><seg xmlns=""http://www.tei-c.org/ns/1.0"" xml:id=""C12_48r_b"" prev=""#C12_48r_a"" style=""text-decoration:line-through"" rend=""line-through-style:double"">z. B.</seg></del></restore>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" xml:id=""C12_48r_b"" prev=""#C12_48r_a"" style=""text-decoration:line-through"" rend=""line-through-style:double"">z. B.</seg>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" xml:id=""C12_48r_b"" prev=""#C12_48r_a"" rendition=""text-decoration:line-through"" rend=""line-through-style:double"">z. B.</seg>")
(: restored deletion that was again deleted :)
%test:args("<del xmlns=""http://www.tei-c.org/ns/1.0""><seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""text-decoration:line-through"" rend=""line-through-style:single_oblique(45deg)""><restore xmlns=""http://www.tei-c.org/ns/1.0""><del xmlns=""http://www.tei-c.org/ns/1.0""><seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""text-decoration:line-through"">ſich</seg></del></restore></seg></del>")
......@@ -283,7 +283,7 @@ declare
declare
%test:name("Spacing")
%test:args("<seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""letter-spacing:0.2cm;"">1</seg>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""letter-spacing:0.2cm;"">1</seg>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""letter-spacing:0.2cm;"">1</seg>")
function teisimple-test:analyze-spacing($node as element(*)) {
fontane-simple:transform($node)
};
......@@ -581,13 +581,13 @@ declare
declare
%test:name("Special cases (superscript and subscript)")
%test:args("<zone xmlns=""http://www.tei-c.org/ns/1.0""><seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""vertical-align:super; text-decoration:underline"">r</seg></zone>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""vertical-align:super; text-decoration:underline"">r</seg>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""vertical-align:super; text-decoration:underline"">r</seg>")
%test:args("<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:underline"">Dinstag d. 20</seg>.</hi><seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""text-decoration:underline; vertical-align:super"">ten</seg></line>")
%test:assertEquals("<hi xmlns=""http://www.tei-c.org/ns/1.0"">Dinstag d. 20.</hi>","<seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""text-decoration:underline; vertical-align:super"">ten</seg>")
%test:assertEquals("<hi xmlns=""http://www.tei-c.org/ns/1.0"">Dinstag d. 20.</hi>","<seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""text-decoration:underline; vertical-align:super"">ten</seg>")
%test:args("<zone xmlns=""http://www.tei-c.org/ns/1.0""><seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""vertical-align:sub; text-decoration:underline"">r</seg></zone>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""vertical-align:sub; text-decoration:underline"">r</seg>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""vertical-align:sub; text-decoration:underline"">r</seg>")
function teisimple-test:analyze-superscript($node as element(*)) {
fontane-simple:transform($node)
......@@ -639,7 +639,7 @@ declare
%test:assertEquals("<ab xmlns=""http://www.tei-c.org/ns/1.0"" type=""etc."">...</ab>")
%test:args("<line xmlns=""http://www.tei-c.org/ns/1.0"">ſind bedeutend. 1 <seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""font-size:small""><seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""vertical-align:super"">1</seg><g xmlns=""http://www.tei-c.org/ns/1.0"" ref=""#hb"">/</g><seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""vertical-align:sub"">2</seg></seg> Sgr</line>")
%test:assertEquals("sind bedeutend. 1 ", "<seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""font-size:small""><seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""vertical-align:super"">1</seg><g xmlns=""http://www.tei-c.org/ns/1.0"" ref=""#hb"">/</g><seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""vertical-align:sub"">2</seg></seg>", " Sgr")
%test:assertEquals("sind bedeutend. 1 ", "<seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""font-size:small""><seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""vertical-align:super"">1</seg><g xmlns=""http://www.tei-c.org/ns/1.0"" ref=""#hb"">/</g><seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""vertical-align:sub"">2</seg></seg>", " Sgr")
function teisimple-test:analyze-abbreviations($node as element(*)) {
fontane-simple:transform($node)
......
......@@ -185,10 +185,14 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
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/@style) then
element{QName("http://www.tei-c.org/ns/1.0", $node/name())}{
attribute rendition {$node/@style},
$node/(@* except @style),
fontane-simple:transform($node/node())
}
else if($node/@type = "initials" or $node/@type = "monogram"
or $node/@style or $node/@type = "multiphrase")
or $node/@type = "multiphrase")
then
local:keep-element($node)
else if($node/@type = "auction_number"
......@@ -222,26 +226,36 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
else
(),
element tei:div {
attribute facs {$node/@facs},
attribute xml:id {$node/@xml:id},
attribute type {$node/@n},
$node/@*,
fontane-simple:transform($node/node())
})
else if(matches($node/@n, "[0-9]{1,4}[rv]{1}"))
else if(matches($node/@n, "[0-9]{1,4}[rv]{1}")
and not($node/@type = "fragment"))
then
(element tei:pb{
attribute n {$node/@n},
if($node/@facs)
then
attribute facs {$node/@facs}
else
()
attribute n {$node/@n}
},
(: 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"},
$node/(@* except @facs),
fontane-simple:transform($node/node())
}
else
())
else if(matches($node/@n, "[0-9]{1,4}[rv]{1}")
and $node/@type = "fragment")
then
(element tei:pb{
attribute n {$node/@n}
},
(: if all descendant text nodes shoudln't be serialized, z.g. parent::fw or parent::stamp :)
if($node)
then
element tei:div{
$node/(@* except @facs),
fontane-simple:transform($node/node())
}
else
......@@ -255,12 +269,8 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
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
fontane-simple:transform($node/node())
else
()
else
()
case element(tei:gap) return
local:keep-element($node)
......@@ -402,6 +412,24 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
fontane-simple:transform($node/node())
};
declare function fontane-simple:transform-header($nodes as node()*) as node()* {
for $node in $nodes return
typeswitch ($node)
case text() return
$node
case element(tei:persName) return
element {QName("http://www.tei-c.org/ns/1.0", "rs")}{
attribute type {"person"},
$node/@*,
fontane-simple:transform-header($node/node())
}
default return
local:keep-header-element($node)
};
(: TODO: adapt to general XML :)
declare function fontane-simple:is-hand-contemporary($hand as xs:string) as xs:boolean {
let $hand := replace($hand, "#", "")
......@@ -456,4 +484,11 @@ declare function local:keep-element($node as node()) as node() {
$node/@*,
fontane-simple:transform($node/node())
}
};
declare function local:keep-header-element($node as node()) as node() {
element {QName("http://www.tei-c.org/ns/1.0", $node/name())}{
$node/@*,
fontane-simple:transform-header($node/node())
}
};
\ 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