Commit 6d53940f authored by MRodz's avatar MRodz
Browse files

Change whitespace handling

parent 946d34da
......@@ -111,7 +111,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
case element(tei:retrace) return
if($node/@rend) then
element tei:seg {
element {QName("http://www.tei-c.org/ns/1.0", "seg")} {
attribute rendition {$node/@rend},
fontaneSimple:transform($node/node())
}
......@@ -184,7 +184,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
fontaneSimple:mark-linegroup-beginning()
else
(),
element tei:l {
element {QName("http://www.tei-c.org/ns/1.0", "l")} {
fontaneSimple:transform($node/node())
},
if(not($node/following-sibling::tei:line[@type = "verse"])) then
......@@ -197,7 +197,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
and matches($node/@next, @xml:id)]
return
(fontaneSimple:mark-linegroup-beginning(),
element tei:l {
element {QName("http://www.tei-c.org/ns/1.0", "l")} {
fontaneSimple:transform($node/node()),
simpleHelpers:start-line($node),
fontaneSimple:transform($corresp/node())
......@@ -215,7 +215,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
fontaneSimple:transform($node/node()))
else if($node/@type = "item") then
element tei:item {
element {QName("http://www.tei-c.org/ns/1.0", "item")} {
$node/(@* except (@rend, @type, @style)),
if($node/@rend) then
attribute rendition {$node/@rend}
......@@ -282,16 +282,16 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
let $next := replace($node/@next, "#", "")
let $corresp := $node/following::*[@xml:id = $next]
return
(element tei:seg {
(element {QName("http://www.tei-c.org/ns/1.0", "seg")} {
$node/@type,
fontaneSimple:transform($node/node()),
fontaneSimple:transform($corresp/node())
},
element tei:lb {
element {QName("http://www.tei-c.org/ns/1.0", "lb")} {
attribute type {"edited_text"}
})
else
element tei:seg {
element {QName("http://www.tei-c.org/ns/1.0", "seg")} {
$node/@type,
fontaneSimple:transform($node/node())
}
......@@ -321,14 +321,14 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
fontaneSimple:transform($node/node()))
else if(matches($node/@n, "Beilage")) then
element tei:div {
element {QName("http://www.tei-c.org/ns/1.0", "div")} {
$node/@*,
fontaneSimple:transform($node/node())
}
else if($node/@type = "pocket") then
(fontaneSimple:make-pb($node),
element tei:div {
element {QName("http://www.tei-c.org/ns/1.0", "div")}{
$node/(@* except (@n, @ulx, @uly, @lry, @lrx)),
fontaneSimple:transform($node/node())
})
......@@ -338,7 +338,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
(fontaneSimple:make-pb($node),
(if(not($node/@subtype = "Kalenderblatt"
or $node/@subtype = "Zeitungsausschnitt_Fragment")) then
element tei:div {
element {QName("http://www.tei-c.org/ns/1.0", "div")} {
$node/(@* except (@n, @ulx, @uly, @lry, @lrx)),
fontaneSimple:transform($node/node())
}
......@@ -370,7 +370,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
case element(tei:metamark) return
if($node/@function = "integrate"
or $node/@function = "authorial_note") then
element tei:ab {
element {QName("http://www.tei-c.org/ns/1.0", "ab")} {
$node/@*
}
else if($node/@function = "placeholder"
......@@ -380,7 +380,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
or $node/@function ="footnotes"
or $node/@function ="ellipsis"
or $node/@function = "paragraph") then
element tei:ab {
element {QName("http://www.tei-c.org/ns/1.0", "ab")} {
attribute type {$node/@function},
fontaneSimple:transform($node/node())
}
......@@ -394,14 +394,14 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
if(matches($node/@style, "border-style:solid")
and not(matches($node/@style, "border-radius"))
and not($node/@rend = "border-style:house")) then
element tei:div {
element {QName("http://www.tei-c.org/ns/1.0", "div")} {
attribute type {"frame"},
fontaneSimple:transform($node/node())
}
else if(matches($node/@rend, "border-bottom-style:brace")) then
(fontaneSimple:transform($node/node()),
element tei:ab {
element {QName("http://www.tei-c.org/ns/1.0", "ab")} {
attribute type {"bottom-brace"}
})
......@@ -409,7 +409,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
()
else if($node/@type = "marked_off") then
element tei:seg {
element {QName("http://www.tei-c.org/ns/1.0", "seg")} {
$node/@type,
$node/@xml:id,
fontaneSimple:transform($node/node())
......@@ -419,7 +419,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
if($node/child::tei:zone[@type = "highlighted"]) then
fontaneSimple:transform($node/node())
else
element tei:hi {
element {QName("http://www.tei-c.org/ns/1.0", "hi")} {
attribute type {"vertical-mark"},
fontaneSimple:transform($node/node())
}
......@@ -427,7 +427,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
else if($node/@type = "illustration"
or $node/@type = "printed_illustration") then
if(not($node//tei:figure/parent::tei:del)) then
element {QName("http://www.tei-c.org/ns/1.0", "ab")}{
element {QName("http://www.tei-c.org/ns/1.0", "ab")} {
(if($node/child::tei:zone[@type = "illustration"]) then
attribute type {"composed-sketch"}
else
......@@ -446,7 +446,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
else if($node/parent::tei:zone/@type = "illustration"
or $node/parent::tei:zone/@type = "printed_illustration") then
element {QName("http://www.tei-c.org/ns/1.0", "seg")}{
element {QName("http://www.tei-c.org/ns/1.0", "seg")} {
attribute type {"caption"},
attribute rendition {"margin-left:" || $node/@ulx || "cm; "
|| "margin-top:" || $node/@uly || "cm"},
......@@ -468,14 +468,14 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
}
else if($node/@type = "dialogue") then
element tei:div {
element {QName("http://www.tei-c.org/ns/1.0", "div")} {
$node/@type,
fontaneSimple:transform($node/node())
}
else if($node/@type = "verse") then
(fontaneSimple:mark-linegroup-beginning(),
element tei:l {
element {QName("http://www.tei-c.org/ns/1.0", "l")} {
fontaneSimple:transform($node/node())
},
fontaneSimple:mark-linegroup-end())
......@@ -484,7 +484,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
()
else if($node/@type = "said") then
element tei:seg {
element {QName("http://www.tei-c.org/ns/1.0", "seg")} {
$node/@type,
fontaneSimple:transform($node/node())
}
......@@ -494,13 +494,13 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
()
else if($node/@type = "toc") then
element tei:list {
element {QName("http://www.tei-c.org/ns/1.0", "list")} {
$node/(@type, @subtype),
fontaneSimple:transform($node/node())
}
else if($node/@type = "legend") then
element {QName("http://www.tei-c.org/ns/1.0", "div")}{
element {QName("http://www.tei-c.org/ns/1.0", "div")} {
(if($node/@style
or $node/@rendition) then
attribute rendition {simpleHelpers:filter-rendition($node)}
......@@ -511,7 +511,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
}
else if($node/@type = "additional") then
element tei:ab {
element {QName("http://www.tei-c.org/ns/1.0", "ab")} {
$node/(@* except (@ulx, @uly, @lry, @lrx)),
fontaneSimple:transform($node/node())
}
......@@ -526,7 +526,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
fontaneSimple:transform($node/node())
else if($node/@xml:id) then
element tei:seg {
element {QName("http://www.tei-c.org/ns/1.0", "seg")} {
$node/@xml:id,
$node/@prev,
$node/@next,
......@@ -538,12 +538,12 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
fontaneSimple:transform($node/node())
case element(tei:said) return
(element tei:seg {
(element {QName("http://www.tei-c.org/ns/1.0", "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 {
element {QName("http://www.tei-c.org/ns/1.0", "lb")} {
attribute type {"edited_text"}
}
else
......@@ -554,14 +554,14 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
(: genealogy lines probably shouldn't be displayed, but I still have to
check that. in case they should be serialized, I leave the code :)
(: if(matches($node/descendant::tei:ref, "Stammbaumverbindungslinie")) then:)
(: element tei:seg {:)
(: element {QName("http://www.tei-c.org/ns/1.0", "seg")} {:)
(: $node/@*,:)
(: fontaneSimple:transform($node/node()):)
(: }:)
(: else if(matches($node/descendant::tei:ref, "Schlusslinie")):)
if(matches($node/descendant::tei:ref, "Schlusslinie"))
then
element tei:ab {
element {QName("http://www.tei-c.org/ns/1.0", "ab")} {
switch ($node/descendant::tei:ref)
case "horizontale einfache Schlusslinie" return
attribute type {"long-end-line"}
......@@ -580,7 +580,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
serialize the encoding for the upper line :)
and not(matches($node/descendant::tei:ref, "unterer Teil"))
and not(matches($node/descendant::tei:figDesc, "unsicher"))) then
element tei:ab {
element {QName("http://www.tei-c.org/ns/1.0", "ab")} {
if(matches($node/descendant::tei:ref, "doppelt"))
then
attribute type {"short-paragraph-line-double"}
......@@ -605,7 +605,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
fontaneSimple:copy-element($node)
case element(tei:certainty) return
element {QName("http://www.tei-c.org/ns/1.0", "note")}{
element {QName("http://www.tei-c.org/ns/1.0", "note")} {
attribute type {"editorial"},
attribute subtype {"certainty"},
$node/@cert,
......@@ -640,14 +640,14 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
case element(tei:rs) return
let $index-type := substring-before($node/@ref, ":")
return
element tei:rs {
element {QName("http://www.tei-c.org/ns/1.0", $node/name())} {
$node/@*,
fontaneSimple:make-index-infos($node, $index-type),
fontaneSimple:transform($node/node())
}
case element(tei:date) return
element {QName("http://www.tei-c.org/ns/1.0", $node/name())}{
element {QName("http://www.tei-c.org/ns/1.0", $node/name())} {
(if($node/@when-iso) then
attribute when {$node/@when-iso}
else
......@@ -701,7 +701,7 @@ declare function fontaneSimple:copy-element($node as node()) as node() {
: @return element(tei:head)
: :)
declare function fontaneSimple:make-head($node as node()) as element(tei:head) {
element tei:head {
element {QName("http://www.tei-c.org/ns/1.0", "head")} {
(if($node/descendant::tei:seg[matches(@style, "font-size")]) then
attribute style {simpleHelpers:get-font-size($node)}
else
......@@ -730,7 +730,7 @@ declare function fontaneSimple:make-head($node as node()) as element(tei:head) {
: :)
declare function fontaneSimple:make-div($node as element(tei:surface))
as element(tei:div) {
element tei:div{
element {QName("http://www.tei-c.org/ns/1.0", "div")} {
$node/(@* except (@facs, @n, @attachment, @subtype, @ulx, @uly, @lrx, @lry, @points)),
fontaneSimple:transform($node/node())
}
......@@ -745,7 +745,7 @@ as element(tei:div) {
:)
declare function fontaneSimple:make-seg-with-rendition($node as element(*))
as element(tei:seg) {
element tei:seg {
element {QName("http://www.tei-c.org/ns/1.0", "seg")} {
attribute rendition {simpleHelpers:filter-rendition($node)},
$node/(@* except (@style, @rendition)),
(if($node[self::tei:line or self::tei:zone]) then
......@@ -766,7 +766,7 @@ as element(tei:seg) {
:)
declare function fontaneSimple:make-pb($node as element(tei:surface))
as element(tei:pb) {
element {QName("http://www.tei-c.org/ns/1.0", "pb")}{
element {QName("http://www.tei-c.org/ns/1.0", "pb")} {
$node/@n
}
};
......@@ -792,7 +792,7 @@ declare function fontaneSimple:enhance-handshift($node as element(tei:handShift)
as element(tei:milestone) {
let $prev-hand := $node/preceding::tei:handShift[@new][1]
return
element tei:milestone {
element {QName("http://www.tei-c.org/ns/1.0", "milestone")} {
attribute unit {"handshift"},
attribute subtype {if($node/@new) then $node/@new else $prev-hand/@new},
attribute rend {concat("script(", (if($node/@script) then $node/@script else ""), ") ",
......@@ -804,7 +804,7 @@ as element(tei:milestone) {
declare function fontaneSimple:mark-intervention($node as element(*))
as element(tei:seg) {
element tei:seg {
element {QName("http://www.tei-c.org/ns/1.0", "seg")} {
if($node[self::tei:lb]) then
attribute type {"missing-hyphen"}
else if($node[self::tei:surplus]) then
......@@ -826,7 +826,7 @@ as element(tei:seg) {
declare function fontaneSimple:mark-missing-hyphen($node as element(tei:lb)) as
element(tei:seg) {
element tei:seg {
element {QName("http://www.tei-c.org/ns/1.0", "seg")} {
attribute type {"missing-hyphen"},
<tei:hi xmlns="http://www.tei-c.org/ns/1.0">‹</tei:hi>,
simpleHelpers:find-chars($node),
......@@ -840,14 +840,14 @@ element(tei:seg) {
: second serialization step. :)
declare function fontaneSimple:mark-linegroup-beginning() as
element(tei:milestone) {
element tei:milestone {
element {QName("http://www.tei-c.org/ns/1.0", "milestone")} {
attribute unit {"start-lg"}
}
};
declare function fontaneSimple:mark-linegroup-end() as
element(tei:milestone) {
element tei:milestone {
element {QName("http://www.tei-c.org/ns/1.0", "milestone")} {
attribute unit {"end-lg"}
}
};
......@@ -875,9 +875,9 @@ $index-type as xs:string) as element()* {
for $iii in 1 to $no-of-refs
let $ref := $refs[$iii]
return
element tei:index {
element {QName("http://www.tei-c.org/ns/1.0", "index")} {
attribute indexName {$index-type},
element tei:term {
element {QName("http://www.tei-c.org/ns/1.0", "term")} {
attribute type {"main"},
index-info:get-info-about($index-type, $ref, "regular-name")
},
......@@ -914,7 +914,7 @@ $index-type as xs:string) as element()* {
declare function fontaneSimple:make-term($type as xs:string, $info as xs:string)
as element(tei:term)* {
if($info != "") then
element tei:term {
element {QName("http://www.tei-c.org/ns/1.0", "term")} {
attribute type {$type},
$info
}
......
......@@ -31,18 +31,13 @@ declare variable $tidySimple:valid-hands :=
declare function tidySimple:main($tei as node()*) {
let $doc :=
try {
(doc($config:app-root || "/resources/xml/tei-simple-pre.xml"))
} catch * {
(console:log("It was not possible to open the requested file tei-simple-pre.xml."))
}
let $text := $tei//tei:text
let $clear-invalid-hands := tidySimple:sort-out-invalid-hands($text)
let $clear-surplus-hands := tidySimple:sort-out-surplus-elements($clear-invalid-hands)
let $text-with-sections := tidySimple:make-structure($clear-surplus-hands)
(: let $correct-namespace := tidySimple:correct-namespace($clear-surplus-hands):)
(: let $text-with-sections := tidySimple:make-structure($clear-surplus-hands):)
let $header := $tei/tei:teiHeader
let $store := xmldb:store("/db/apps/SADE/resources/xml/", "tei-simple-tmp.xml", <TEI xmlns="http://www.tei-c.org/ns/1.0">{$header}{$text-with-sections}</TEI>)
let $store := xmldb:store("/db/apps/SADE/resources/xml/", "tei-simple-tmp.xml", <TEI xmlns="http://www.tei-c.org/ns/1.0">{$header}{$clear-surplus-hands}</TEI>)
(: let $store := xmldb:store("/db/apps/SADE/resources/xml/", "tei-simple-tmp.xml", <div>{$clear-surplus-hands}</div>):)
return "done"
(: let $doc := doc($config:app-root || "/resources/xml/tei-simple-tmp.xml"):)
......@@ -196,7 +191,7 @@ declare function tidySimple:copy-element($node as node(), $flag as xs:string)
: :)
declare function tidySimple:clear-handshift($node as element(tei:milestone))
as element(tei:milestone) {
element tei:milestone {
element {QName("http://www.tei-c.org/ns/1.0", $node/name())} {
attribute unit {"handshift"},
if($node/@subtype = "") then
()
......@@ -285,7 +280,7 @@ declare function tidySimple:is-in-section($node as node()) as xs:boolean {
: :)
declare function tidySimple:make-section($node as element(tei:milestone))
as element(tei:div) {
element tei:div {
element {QName("http://www.tei-c.org/ns/1.0", "div")} {
attribute type {"section"},
tidySimple:get-section-chunk($node)
}
......@@ -311,4 +306,13 @@ as node()* {
declare function tidySimple:tidy($nodes as node()*) as node()* {
()
};
declare function tidySimple:correct-namespace($nodes as node()*) as node()* {
for $node in $nodes return
typeswitch($node)
case text() return
$node
default return ()
};
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
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