Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
fontane-notizbuecher
SADE
Commits
c7183e3e
Commit
c7183e3e
authored
Jul 16, 2018
by
Michelle Rodzis
Committed by
mrodzis
Feb 05, 2019
Browse files
Add first draft for removal of tei:handShift cleaning
parent
4af78568
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
modules/fontane/teisimpleprint/teisimplehelpers.xqm
View file @
c7183e3e
...
...
@@ -336,6 +336,29 @@ $node as element(tei:handShift)) as xs:boolean {
false()
};
(:~
: Checks if the previous handShift is the same as the current handShift. Two
: handShifts are the same if they have the same attributes.
:
: @author Michelle Rodzis
: @param $node the current tei:handShift element
: @return xs:boolean
:)
declare function simpleHelpers:is-prev-hand-same($node as element(tei:handShift))
as xs:boolean {
let $prev-hand := $node/preceding::tei:handShift[1]
return
(: since we can't take the order of the attributes for granted we can't
use functx:sequence-deep-equal :)
if($prev-hand
and $node/@new = $prev-hand/@new
and $node/@script = $prev-hand/@script
and $node/@medium = $prev-hand/@medium) then
true()
else
false()
};
(: TODO :)
(:declare function simpleHelpers:make-section($node as element(tei:milestone))
...
...
modules/fontane/teisimpleprint/tidysimple.xqm
View file @
c7183e3e
...
...
@@ -23,7 +23,8 @@ import module namespace simpleHelpers="http://fontane-nb.dariah.eu/teisimplehelp
declare variable $tidySimple:valid-hands :=
for $res in collection("/db/sade-projects/textgrid/data/xml/data")
(: for $res in collection("/db/sade-projects/textgrid/data/xml/data"):)
for $res in collection("/db/apps/SADE/resources/xml")
return
$res//tei:handNote[@script = "contemporary"]/@xml:id/string();
...
...
@@ -36,7 +37,9 @@ declare function tidySimple:main($tei as node()*) as xs:string* {
(console:log("It was not possible to open the requested file tei-simple-pre.xml."))
}
let $text := $doc//tei:text
let $text-with-sections := tidySimple:make-structure($text)
let $clear-invalid-hands := tidySimple:sort-out-invalid-hands($text)
let $clear-surplus-hands := tidySimple:sort-out-surplus-hands($clear-invalid-hands)
let $text-with-sections := tidySimple:make-structure($clear-surplus-hands)
let $store := xmldb:store("/db/apps/SADE/resources/xml/", "tei-simple-tmp.xml", <div>{$text-with-sections}</div>)
return ""
(: let $doc := doc($config:app-root || "/resources/xml/tei-simple-tmp.xml"):)
...
...
@@ -50,6 +53,41 @@ declare function tidySimple:main($tei as node()*) as xs:string* {
(: return xmldb:store("/db/apps/SADE/resources/xml/", "tei-simple.xml", $final-tei):)
};
declare function tidySimple:sort-out-invalid-hands($nodes as node()*)
as node()* {
for $node in $nodes return
typeswitch ($node)
case text() return
$node
case element(tei:handShift) return
if(simpleHelpers:is-hand-valid($tidySimple:valid-hands, $node)) then
tidySimple:copy-element($node, "post")
else
()
default return
tidySimple:copy-element($node, "post")
};
declare function tidySimple:sort-out-surplus-hands($nodes as node()*)
as node()* {
for $node in $nodes return
typeswitch ($node)
case text() return
$node
case element(tei:handShift) return
if(simpleHelpers:is-prev-hand-same($node)) then
()
else
tidySimple:copy-element($node, "surplus")
default return
tidySimple:copy-element($node, "surplus")
};
declare function tidySimple:tidy($nodes as node()*) as node()* {
for $node in $nodes return
...
...
@@ -97,6 +135,10 @@ as node() {
$node/@*,
if($flag = "structure") then
tidySimple:make-structure($node/node())
else if($flag = "post") then
tidySimple:sort-out-invalid-hands($node/node())
else if($flag = "surplus") then
tidySimple:sort-out-invalid-hands($node/node())
else
tidySimple:tidy($node/node())
}
...
...
resources/xml/tei-simple-pre.xml
View file @
c7183e3e
...
...
@@ -540,27 +540,29 @@
</tei:date>
.
</tei:seg>
</tei:seg>
</tei:head>
<item
rend=
"align(center)"
>
<tei:milestone
unit=
"line"
/>
<tei:seg
rendition=
"letter-spacing:0.2cm; font-size:large"
>
(
<tei:rs
type=
"direct"
ref=
"plc:Thueringen"
>
<tei:ref
target=
"#xpath(//surface[@n='6r'])"
>
Thüringen
</tei:ref>
</tei:rs>
.)
</tei:seg>
<tei:lb
type=
"edited_text"
/>
<tei:handShift
script=
"Latf standard"
new=
"#Fontane"
medium=
""
/>
<tei:milestone
unit=
"line"
/>
Historisches. Auch
<tei:lb
type=
"edited_text"
/>
<tei:milestone
unit=
"line"
/>
einiges über
<tei:rs
type=
"direct"
ref=
"psn:Luther"
>
<tei:ref
target=
"#xpath(//surface[@n='1r'])"
>
Luther
</tei:ref>
</tei:rs>
,
<tei:lb
type=
"edited_text"
/>
<tei:milestone
unit=
"line"
/>
<tei:rs
type=
"direct"
ref=
"plc:Luther-Plaetze"
>
<tei:ref
target=
"#xpath(//surface[@n='1r'])"
>
Lutherplätze
</tei:ref>
</tei:rs>
<tei:handShift
script=
"Latn"
new=
"#Fontane"
medium=
""
/>
<tei:choice>
<tei:abbr>
etc
</tei:abbr>
<tei:expan>
et cetera
</tei:expan>
</tei:choice>
etc.
<tei:handShift
medium=
"pencil"
script=
"Latf"
new=
"#Fontane"
/>
</item>
<tei:list
type=
"toc"
>
<item
rend=
"align(center)"
>
<tei:milestone
unit=
"line"
/>
<tei:seg
rendition=
"letter-spacing:0.2cm; font-size:large"
>
(
<tei:rs
type=
"direct"
ref=
"plc:Thueringen"
>
<tei:ref
target=
"#xpath(//surface[@n='6r'])"
>
Thüringen
</tei:ref>
</tei:rs>
.)
</tei:seg>
<tei:lb
type=
"edited_text"
/>
<tei:handShift
script=
"Latf standard"
new=
"#Fontane"
medium=
""
/>
<tei:milestone
unit=
"line"
/>
Historisches. Auch
<tei:lb
type=
"edited_text"
/>
<tei:milestone
unit=
"line"
/>
einiges über
<tei:rs
type=
"direct"
ref=
"psn:Luther"
>
<tei:ref
target=
"#xpath(//surface[@n='1r'])"
>
Luther
</tei:ref>
</tei:rs>
,
<tei:lb
type=
"edited_text"
/>
<tei:milestone
unit=
"line"
/>
<tei:rs
type=
"direct"
ref=
"plc:Luther-Plaetze"
>
<tei:ref
target=
"#xpath(//surface[@n='1r'])"
>
Lutherplätze
</tei:ref>
</tei:rs>
<tei:handShift
script=
"Latn"
new=
"#Fontane"
medium=
""
/>
<tei:choice>
<tei:abbr>
etc
</tei:abbr>
<tei:expan>
et cetera
</tei:expan>
</tei:choice>
etc.
<tei:handShift
medium=
"pencil"
script=
"Latf"
new=
"#Fontane"
/>
</item>
</tei:list>
</tei:div>
<pb
type=
"inner_front_cover"
/>
<tei:handShift
xmlns:tei=
"http://www.tei-c.org/ns/1.0"
new=
"#fremde_Hand2"
script=
""
medium=
""
/>
...
...
resources/xml/tei-simple-tmp.xml
View file @
c7183e3e
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment