Commit 49de0cbb authored by Wolfgang's avatar Wolfgang

docx import: distinguish different types of notes

parent 358d8841
No preview for this file type
......@@ -6,7 +6,9 @@
<title>DOCX Output Preview
<desc>A test ODD to preview TEI imported from Word docx</desc>
<desc>A test ODD to preview TEI imported from Word docx</desc>
</title>
</titleStmt>
<publicationStmt>
......@@ -54,6 +56,8 @@
font-family: Menlo, Consolas, monospace;
font-size: 0.85em;
......@@ -65,6 +69,8 @@ font-size: 0.85em;
</outputRendition>
</model>
</elementSpec>
......@@ -80,6 +86,8 @@ font-size: 0.85em;
color: #e24329;
font-variant: small-caps;
......@@ -89,6 +97,8 @@ font-variant: small-caps;
</outputRendition>
</model>
<model behaviour="inline">
......@@ -115,25 +125,15 @@ font-variant: small-caps;
<model behaviour="inline">
<outputRendition xml:space="preserve">
font-family: Menlo, Consolas, monospace;
font-size: .85em;
</outputRendition>
<outputRendition xml:space="preserve" scope="before">
content: '&lt;';
</outputRendition>
<outputRendition xml:space="preserve" scope="after">
content: '&gt;';
</outputRendition>
</model>
</elementSpec>
......@@ -159,6 +159,8 @@ font-size: .85em;
margin-left: 10px;
margin-right: 10px;
padding-left: 10px;
......@@ -172,6 +174,8 @@ border-left: 1px solid #C0C0C0;
</outputRendition>
</model>
</elementSpec>
......@@ -214,34 +218,69 @@ border-left: 1px solid #C0C0C0;
</model>
</elementSpec>
<elementSpec ident="head" mode="change">
<model predicate="$parameters?header='short'" behaviour="inline">
<model predicate="$parameters?header='short'" behaviour="inline">
<param name="content" value="replace(string-join(.//text()[not(parent::ref)]), '^(.*?)[^\w]*$', '$1')"/>
</model>
<model predicate="parent::figure" behaviour="block">
<model predicate="parent::figure" behaviour="block">
<outputRendition xml:space="preserve">
font-style: italic;
</outputRendition>
</model>
<model predicate="parent::table" behaviour="block">
<model predicate="parent::table" behaviour="block">
<outputRendition xml:space="preserve">
font-style: italic;
</outputRendition>
</model>
<model predicate="parent::lg" behaviour="block">
<model predicate="parent::lg" behaviour="block">
<outputRendition xml:space="preserve">
font-style: italic;
</outputRendition>
</model>
<model predicate="parent::list" behaviour="block">
<model predicate="parent::list" behaviour="block">
<outputRendition xml:space="preserve">
font-weight: bold;
</outputRendition>
</model>
<model predicate="parent::div" behaviour="heading">
<model predicate="parent::div" behaviour="heading">
<param name="level" value="count($get(.)/ancestor::div)"/>
</model>
<model behaviour="block"/>
</elementSpec>
<model behaviour="block"/>
</elementSpec>
<elementSpec ident="anchor" mode="change">
<model predicate="@type='note'" behaviour="inline" cssClass="note">
<param name="content" value="let $nr := count(./preceding::note[@target]) let $ch := codepoints-to-string(string-to-codepoints(&#34;a&#34;) + $nr mod 26) return $ch || '-'"/>
<pb:template xmlns="" xml:space="preserve"><a rel="footnote">[[content]]</a></pb:template>
</model>
<model behaviour="anchor">
<param name="id" value="@xml:id"/>
</model>
</elementSpec>
<elementSpec ident="note" mode="change">
<model predicate="@target" behaviour="note">
<param name="label" value="let $nr := count(./preceding::note[@target]) let $ch := codepoints-to-string(string-to-codepoints(&#34;a&#34;) + $nr mod 26) return '-' || $ch"/>
</model>
<model predicate="@place" behaviour="note">
<param name="place" value="@place"/>
<param name="label" value="@n"/>
</model>
<model predicate="parent::div and not(@place)" behaviour="block">
<outputRendition xml:space="preserve">
margin-left: 10px;margin-right: 10px;
font-size:smaller;
</outputRendition>
</model>
<model predicate="not(@place)" behaviour="inline">
<outputRendition xml:space="preserve" scope="before">
content:" [";
</outputRendition>
<outputRendition xml:space="preserve" scope="after">
content:"] ";
</outputRendition>
<outputRendition xml:space="preserve">
font-size:small;
</outputRendition>
</model>
</elementSpec>
</schemaSpec>
</body>
</text>
......
......@@ -24,7 +24,9 @@
<desc>Convert DOCX via ODD</desc>
<desc>Convert DOCX via ODD</desc>
</title>
<title type="short">DOCX Import</title>
</titleStmt>
......@@ -76,10 +78,21 @@
<elementSpec ident="r" mode="add">
<model predicate="drawing" behaviour="inline">
<param name="content" value=".//pic:pic"/>
</model>
<model predicate="ancestor::w:footnote and $parameters?cstyle(.)/name/@w:val = 'footnote reference'" behaviour="omit">
<desc>Omit footnote characters inside the footnote text itself</desc>
</model>
<model predicate="footnoteReference[@w:customMarkFollows]" behaviour="note">
<desc>Footnote reference with a custom mark is encoded with type=original</desc>
<param name="content" value="$parameters?footnote(.)"/>
<param name="place" value="'footnote'"/>
<param name="label" value="w:t"/>
<param name="type" value="'original'"/>
</model>
<model predicate="footnoteReference" behaviour="note">
<param name="content" value="$parameters?footnote(.)"/>
<param name="place" value="'footnote'"/>
<param name="label" value="w:t"/>
</model>
<model predicate="endnoteReference" behaviour="note">
<param name="content" value="$parameters?endnote(.)"/>
......@@ -191,6 +204,19 @@
<elementSpec ident="v:imagedata" mode="add">
<model behaviour="graphic">
<param name="url" value="let $id := @r:id let $mediaColl := $parameters?filename || &#34;.media/&#34; let $relationship := $parameters?rels/rel:Relationship[@Id=$id] let $target := $relationship/@Target return if ($relationship/@TargetMode = &#34;External&#34;) then $target else $mediaColl || substring-after($target, &#34;media/&#34;)"/>
</model>
</elementSpec>
<elementSpec ident="commentRangeStart" mode="add">
<model behaviour="anchor">
<param name="id" value="'ac'||@w:id"/>
<param name="type" value="'note'"/>
</model>
</elementSpec>
<elementSpec ident="commentRangeEnd" mode="add">
<model behaviour="note">
<param name="content" value="$parameters?comment(.)"/>
<param name="place" value="'footnote'"/>
<param name="target" value="'ac' || @w:id"/>
</model>
</elementSpec>
</schemaSpec>
......
......@@ -21,6 +21,10 @@ import module namespace html="http://www.tei-c.org/tei-simple/xquery/functions";
import module namespace epub="http://www.tei-c.org/tei-simple/xquery/functions/epub";
(: generated template function for element spec: anchor :)
declare %private function model:template-anchor($config as map(*), $node as node()*, $params as map(*)) {
<t xmlns=""><a rel="footnote">{$config?apply-children($config, $node, $params?content)}</a></t>/*
};
(: generated template function for element spec: hi :)
declare %private function model:template-hi($config as map(*), $node as node()*, $params as map(*)) {
<t xmlns=""><span class="{$config?apply-children($config, $node, $params?rend)}">{$config?apply-children($config, $node, $params?content)}</span></t>/*
......@@ -93,7 +97,18 @@ declare function model:apply($config as map(*), $input as node()*) {
case element(pc) return
html:inline($config, ., ("tei-pc"), .)
case element(anchor) return
html:anchor($config, ., ("tei-anchor"), ., @xml:id)
if (@type='note') then
let $params :=
map {
"content": let $nr := count(./preceding::note[@target]) let $ch := codepoints-to-string(string-to-codepoints("a") + $nr mod 26) return $ch || '-'
}
let $content :=
model:template-anchor($config, ., $params)
return
html:inline(map:merge(($config, map:entry("template", true()))), ., ("tei-anchor1", "note"), $content)
else
html:anchor($config, ., ("tei-anchor2"), ., @xml:id)
case element(TEI) return
html:document($config, ., ("tei-TEI"), .)
case element(formula) return
......@@ -138,16 +153,19 @@ declare function model:apply($config as map(*), $input as node()*) {
case element(code) return
html:inline($config, ., ("tei-code"), .)
case element(note) return
if (@place) then
epub:note($config, ., ("tei-note1"), ., @place, @n)
if (@target) then
epub:note($config, ., ("tei-note1"), ., (), let $nr := count(./preceding::note[@target]) let $ch := codepoints-to-string(string-to-codepoints("a") + $nr mod 26) return '-' || $ch)
else
if (parent::div and not(@place)) then
epub:block($config, ., ("tei-note2"), .)
if (@place) then
epub:note($config, ., ("tei-note2"), ., @place, @n)
else
if (not(@place)) then
html:inline($config, ., ("tei-note3"), .)
if (parent::div and not(@place)) then
epub:block($config, ., ("tei-note3"), .)
else
$config?apply($config, ./node())
if (not(@place)) then
html:inline($config, ., ("tei-note4"), .)
else
$config?apply($config, ./node())
case element(dateline) return
epub:block($config, ., ("tei-dateline"), .)
case element(back) return
......
......@@ -19,6 +19,10 @@ import module namespace css="http://www.tei-c.org/tei-simple/xquery/css";
import module namespace latex="http://www.tei-c.org/tei-simple/xquery/functions/latex";
(: generated template function for element spec: anchor :)
declare %private function model:template-anchor($config as map(*), $node as node()*, $params as map(*)) {
<t xmlns=""><a rel="footnote">{$config?apply-children($config, $node, $params?content)}</a></t>/*
};
(: generated template function for element spec: hi :)
declare %private function model:template-hi($config as map(*), $node as node()*, $params as map(*)) {
<t xmlns=""><span class="{$config?apply-children($config, $node, $params?rend)}">{$config?apply-children($config, $node, $params?content)}</span></t>/*
......@@ -88,7 +92,18 @@ declare function model:apply($config as map(*), $input as node()*) {
case element(pc) return
latex:inline($config, ., ("tei-pc"), .)
case element(anchor) return
latex:anchor($config, ., ("tei-anchor"), ., @xml:id)
if (@type='note') then
let $params :=
map {
"content": let $nr := count(./preceding::note[@target]) let $ch := codepoints-to-string(string-to-codepoints("a") + $nr mod 26) return $ch || '-'
}
let $content :=
model:template-anchor($config, ., $params)
return
latex:inline(map:merge(($config, map:entry("template", true()))), ., ("tei-anchor1", "note"), $content)
else
latex:anchor($config, ., ("tei-anchor2"), ., @xml:id)
case element(TEI) return
latex:document($config, ., ("tei-TEI"), .)
case element(formula) return
......@@ -133,16 +148,19 @@ declare function model:apply($config as map(*), $input as node()*) {
case element(code) return
latex:inline($config, ., ("tei-code"), .)
case element(note) return
if (@place) then
latex:note($config, ., ("tei-note1"), ., @place, @n)
if (@target) then
latex:note($config, ., ("tei-note1"), ., (), let $nr := count(./preceding::note[@target]) let $ch := codepoints-to-string(string-to-codepoints("a") + $nr mod 26) return '-' || $ch)
else
if (parent::div and not(@place)) then
latex:block($config, ., ("tei-note2"), .)
if (@place) then
latex:note($config, ., ("tei-note2"), ., @place, @n)
else
if (not(@place)) then
latex:inline($config, ., ("tei-note3"), .)
if (parent::div and not(@place)) then
latex:block($config, ., ("tei-note3"), .)
else
$config?apply($config, ./node())
if (not(@place)) then
latex:inline($config, ., ("tei-note4"), .)
else
$config?apply($config, ./node())
case element(dateline) return
latex:block($config, ., ("tei-dateline"), .)
case element(back) return
......
......@@ -19,6 +19,10 @@ import module namespace css="http://www.tei-c.org/tei-simple/xquery/css";
import module namespace fo="http://www.tei-c.org/tei-simple/xquery/functions/fo";
(: generated template function for element spec: anchor :)
declare %private function model:template-anchor($config as map(*), $node as node()*, $params as map(*)) {
<t xmlns=""><a rel="footnote">{$config?apply-children($config, $node, $params?content)}</a></t>/*
};
(: generated template function for element spec: hi :)
declare %private function model:template-hi($config as map(*), $node as node()*, $params as map(*)) {
<t xmlns=""><span class="{$config?apply-children($config, $node, $params?rend)}">{$config?apply-children($config, $node, $params?content)}</span></t>/*
......@@ -88,7 +92,18 @@ declare function model:apply($config as map(*), $input as node()*) {
case element(pc) return
fo:inline($config, ., ("tei-pc"), .)
case element(anchor) return
fo:anchor($config, ., ("tei-anchor"), ., @xml:id)
if (@type='note') then
let $params :=
map {
"content": let $nr := count(./preceding::note[@target]) let $ch := codepoints-to-string(string-to-codepoints("a") + $nr mod 26) return $ch || '-'
}
let $content :=
model:template-anchor($config, ., $params)
return
fo:inline(map:merge(($config, map:entry("template", true()))), ., ("tei-anchor1", "note"), $content)
else
fo:anchor($config, ., ("tei-anchor2"), ., @xml:id)
case element(TEI) return
fo:document($config, ., ("tei-TEI"), .)
case element(formula) return
......@@ -133,16 +148,19 @@ declare function model:apply($config as map(*), $input as node()*) {
case element(code) return
fo:inline($config, ., ("tei-code"), .)
case element(note) return
if (@place) then
fo:note($config, ., ("tei-note1"), ., @place, @n)
if (@target) then
fo:note($config, ., ("tei-note1"), ., (), let $nr := count(./preceding::note[@target]) let $ch := codepoints-to-string(string-to-codepoints("a") + $nr mod 26) return '-' || $ch)
else
if (parent::div and not(@place)) then
fo:block($config, ., ("tei-note2"), .)
if (@place) then
fo:note($config, ., ("tei-note2"), ., @place, @n)
else
if (not(@place)) then
fo:inline($config, ., ("tei-note3"), .)
if (parent::div and not(@place)) then
fo:block($config, ., ("tei-note3"), .)
else
$config?apply($config, ./node())
if (not(@place)) then
fo:inline($config, ., ("tei-note4"), .)
else
$config?apply($config, ./node())
case element(dateline) return
fo:block($config, ., ("tei-dateline"), .)
case element(back) return
......
......@@ -19,6 +19,10 @@ import module namespace css="http://www.tei-c.org/tei-simple/xquery/css";
import module namespace html="http://www.tei-c.org/tei-simple/xquery/functions";
(: generated template function for element spec: anchor :)
declare %private function model:template-anchor($config as map(*), $node as node()*, $params as map(*)) {
<t xmlns=""><a rel="footnote">{$config?apply-children($config, $node, $params?content)}</a></t>/*
};
(: generated template function for element spec: hi :)
declare %private function model:template-hi($config as map(*), $node as node()*, $params as map(*)) {
<t xmlns=""><span class="{$config?apply-children($config, $node, $params?rend)}">{$config?apply-children($config, $node, $params?content)}</span></t>/*
......@@ -91,7 +95,18 @@ declare function model:apply($config as map(*), $input as node()*) {
case element(pc) return
html:inline($config, ., ("tei-pc"), .)
case element(anchor) return
html:anchor($config, ., ("tei-anchor"), ., @xml:id)
if (@type='note') then
let $params :=
map {
"content": let $nr := count(./preceding::note[@target]) let $ch := codepoints-to-string(string-to-codepoints("a") + $nr mod 26) return $ch || '-'
}
let $content :=
model:template-anchor($config, ., $params)
return
html:inline(map:merge(($config, map:entry("template", true()))), ., ("tei-anchor1", "note"), $content)
else
html:anchor($config, ., ("tei-anchor2"), ., @xml:id)
case element(TEI) return
html:document($config, ., ("tei-TEI"), .)
case element(formula) return
......@@ -136,16 +151,19 @@ declare function model:apply($config as map(*), $input as node()*) {
case element(code) return
html:inline($config, ., ("tei-code"), .)
case element(note) return
if (@place) then
html:note($config, ., ("tei-note1"), ., @place, @n)
if (@target) then
html:note($config, ., ("tei-note1"), ., (), let $nr := count(./preceding::note[@target]) let $ch := codepoints-to-string(string-to-codepoints("a") + $nr mod 26) return '-' || $ch)
else
if (parent::div and not(@place)) then
html:block($config, ., ("tei-note2"), .)
if (@place) then
html:note($config, ., ("tei-note2"), ., @place, @n)
else
if (not(@place)) then
html:inline($config, ., ("tei-note3"), .)
if (parent::div and not(@place)) then
html:block($config, ., ("tei-note3"), .)
else
$config?apply($config, ./node())
if (not(@place)) then
html:inline($config, ., ("tei-note4"), .)
else
$config?apply($config, ./node())
case element(dateline) return
html:block($config, ., ("tei-dateline"), .)
case element(back) return
......
......@@ -102,10 +102,10 @@ h4 {
.tei-hi3 { font-style: italic; }
.tei-hi4 { font-style: italic; }
.tei-code { font-family:monospace }
.tei-note2 { margin-left: 10px;margin-right: 10px; font-size:smaller; }
.tei-note3:before { content:" ["; }
.tei-note3:after { content:"] "; }
.tei-note3 { font-size:small; }
.tei-note3 { margin-left: 10px;margin-right: 10px; font-size:smaller; }
.tei-note4:before { content:" ["; }
.tei-note4:after { content:"] "; }
.tei-note4 { font-size:small; }
.tei-del { text-decoration: line-through; }
.tei-trailer { color: green; }
.tei-speaker { font-style:italic; }
......@@ -162,4 +162,6 @@ h4 {
.tei-persName1 { color: #007e00; }
.tei-persName2 { color: #007e00; }
.tei-tag { font-family: Menlo, Consolas, monospace; font-size: .85em; }
.tei-tag:before { content: '<'; }
.tei-tag:after { content: '>'; }
.tei-eg { margin-left: 1.5em; }
\ 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