Commit 80030262 authored by Wolfgang's avatar Wolfgang

Support parsing MS Word comments into e.g. notes

parent 4bf141ae
......@@ -38,6 +38,7 @@ declare function docx:process($path as xs:string, $dataRoot as xs:string, $trans
let $numbering := doc($unzipped || "/word/numbering.xml")/w:numbering
let $endnotes := docx:normalize-ranges(doc($unzipped || "/word/endnotes.xml")/w:endnotes)
let $footnotes := docx:normalize-ranges(doc($unzipped || "/word/footnotes.xml")/w:footnotes)
let $comments := docx:normalize-ranges(doc($unzipped || "/word/comments.xml")/w:comments)
let $properties := doc($unzipped || "/docProps/core.xml")/cp:coreProperties
let $rels := doc($unzipped || "/word/_rels/document.xml.rels")/rel:Relationships
let $params := map {
......@@ -48,6 +49,7 @@ declare function docx:process($path as xs:string, $dataRoot as xs:string, $trans
"nstyle": docx:nstyle($numbering, $styles, ?),
"endnote": docx:endnote($endnotes, ?),
"footnote": docx:footnote($footnotes, ?),
"comment": docx:comment($comments, ?),
"link": docx:external-link($rels, ?),
"rels": $rels,
"properties": $properties
......@@ -117,6 +119,12 @@ declare function docx:footnote($footnotes as element()*, $node as element()) {
$footnote/*
};
declare function docx:comment($comments as element()*, $node as element()) {
let $id := $node/@w:id
return
$comments/w:comment[@w:id = $id]/*
};
declare function docx:external-link($rels as element()*, $node as element()) {
$rels/rel:Relationship[@Id=$node/@r:id]
};
......
......@@ -76,8 +76,12 @@ declare function pmf:section($config as map(*), $node as node(), $class as xs:st
pmf:block($config, $node, $class, $content)
};
declare function pmf:anchor($config as map(*), $node as node(), $class as xs:string+, $content, $id as item()*) {
<anchor xmlns="http://www.tei-c.org/ns/1.0" xml:id="{$id}"/>
declare function pmf:anchor($config as map(*), $node as node(), $class as xs:string+, $content, $id as item()*, $optional as map(*)) {
<anchor xmlns="http://www.tei-c.org/ns/1.0" xml:id="{$id}">
{
pmf:apply-optional-attributes($optional)
}
</anchor>
};
declare function pmf:link($config as map(*), $node as node(), $class as xs:string+, $content, $uri, $target) {
......@@ -112,12 +116,22 @@ declare function pmf:graphic($config as map(*), $node as node(), $class as xs:st
</graphic>
};
declare function pmf:note($config as map(*), $node as node(), $class as xs:string+, $content, $place, $label) {
declare function pmf:note($config as map(*), $node as node(), $class as xs:string+, $content, $place, $label, $optional as map(*)) {
<note xmlns="http://www.tei-c.org/ns/1.0" place="{$place}">
{ if ($label) then attribute n { $label } else () }
{
pmf:apply-optional-attributes($optional)
}
{ pmf:apply-children($config, $node, $content) }
</note>
};
declare %private function pmf:apply-optional-attributes($optional as map(*)) {
map:for-each($optional, function($key, $value) {
attribute { $key } { $value }
})
};
declare function pmf:inline($config as map(*), $node as node(), $class as xs:string+, $content, $optional as map(*)) {
if (map:contains($optional, "tei_element")) then
element { QName("http://www.tei-c.org/ns/1.0", $optional?tei_element) } {
......
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