Commit c2417f23 authored by Wolfgang's avatar Wolfgang

Merge branch 'feature/tei-output' into 'master'

TEI output mode and docx import

See merge request !68
parents 7a7cb617 41ab3403
......@@ -12,7 +12,7 @@
}
</style>
<vaadin-upload id="uploader" accept=".xml,.tei,.odd" method="post" target="modules/lib/upload.xql" tabindex="-1" form-data-name="files[]">
<vaadin-upload id="uploader" accept=".xml,.tei,.odd,.docx" method="post" target="modules/lib/upload.xql" tabindex="-1" form-data-name="files[]">
<span slot="drop-label">Drop files here.</span>
<paper-button id="uploadBtn" slot="add-button">upload</paper-button>
</vaadin-upload>
......
......@@ -217,10 +217,10 @@ declare function deploy:store-xconf($collection as xs:string?, $json as map(*))
<text match="//tei:titleStmt/tei:title"/>
<text match="//tei:msDesc/tei:head"/>
<text qname="dbk:section">
<field name="title" expression="nav:get-metadata(ancestor::dbk:article, 'title')"/>
<field name="file" expression="util:document-name(.)"/>
<facet dimension="genre" expression="nav:get-metadata(ancestor::dbk:article, 'genre')" hierarchical="yes"/>
<facet dimension="language" expression="nav:get-metadata(ancestor::dbk:article, 'language')"/>
<field name="title" expression="nav:get-metadata((ancestor::dbk:book|ancestor::dbk:article)[1], 'title')"/>
<facet dimension="genre" expression="nav:get-metadata((ancestor::dbk:book|ancestor::dbk:article)[1], 'genre')" hierarchical="yes"/>
<facet dimension="language" expression="nav:get-metadata((ancestor::dbk:book|ancestor::dbk:article)[1], 'language')"/>
</text>
<text qname="dbk:title"/>
</lucene>
......@@ -289,7 +289,7 @@ declare function deploy:copy-odd($collection as xs:string, $json as map(*)) {
(: Copy the selected ODD and its dependencies :)
let $target := $collection || "/resources/odd"
let $mkcol := deploy:mkcol($target, ("tei", "tei"), "rwxr-x---")
for $file in ("tei_simplePrint.odd", "teipublisher.odd", $json?odd || ".odd")
for $file in ("docx.odd", "tei_simplePrint.odd", "teipublisher.odd", $json?odd || ".odd")
let $source := doc($config:odd-root || "/" || $file)
return
xmldb:store($target, $file, $source, "application/xml")
......
......@@ -5,9 +5,10 @@ declare namespace pb="http://teipublisher.com/1.0";
declare default element namespace "http://www.tei-c.org/ns/1.0";
import module namespace config="http://www.tei-c.org/tei-simple/config" at "/db/apps/tei-publisher/modules/config.xqm";
import module namespace config="http://www.tei-c.org/tei-simple/config" at "config.xqm";
import module namespace pmu="http://www.tei-c.org/tei-simple/xquery/util";
import module namespace odd="http://www.tei-c.org/tei-simple/odd2odd";
import module namespace tpu="http://www.tei-c.org/tei-publisher/util" at "lib/util.xql";
declare option output:method "json";
declare option output:media-type "application/json";
......@@ -119,7 +120,13 @@ declare function local:recompile($source as xs:string, $root as xs:string) {
let $outputRoot := request:get-parameter("output-root", $config:output-root)
let $outputPrefix := request:get-parameter("output-prefix", $config:output)
let $config := doc($root || "/configuration.xml")/*
for $module in ("web", "print", "latex", "epub")
let $odd := doc($config:odd-root || "/" || $source)
let $pi := tpu:parse-pi($odd, ())
for $module in
if ($pi?output) then
tokenize($pi?output)
else
("web", "print", "latex", "epub")
return
try {
for $file in pmu:process-odd(
......
......@@ -4,6 +4,7 @@ import module namespace config="http://www.tei-c.org/tei-simple/config" at "../c
import module namespace pmu="http://www.tei-c.org/tei-simple/xquery/util";
import module namespace odd="http://www.tei-c.org/tei-simple/odd2odd";
import module namespace tpu="http://www.tei-c.org/tei-publisher/util" at "util.xql";
declare namespace expath="http://expath.org/ns/pkg";
declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
......@@ -47,32 +48,38 @@ let $odd :=
xmldb:get-child-resources($config:odd-root)[ends-with(., ".odd")]
let $result :=
for $source in $odd
for $module in ("web", "print", "latex", "epub")
return
try {
for $file in pmu:process-odd(
odd:get-compiled($config:odd-root, $source),
$config:output-root,
$module,
"../" || $config:output,
$config:module-config)?("module")
let $src := util:binary-to-string(util:binary-doc($file))
let $compiled := util:compile-query($src, ())
return
if ($compiled/error) then
<div class="list-group-item-danger">
<h5 class="list-group-item-heading">{local:load-source($file, $compiled/error/@line)}:</h5>
<p class="list-group-item-text">{ $compiled/error/string() }</p>
<pre class="list-group-item-text">{ local:get-line($src, $compiled/error/@line)}</pre>
</div>
else
<div class="list-group-item-success">{$file}</div>
} catch * {
<div class="list-group-item-danger">
<h5 class="list-group-item-heading">Error for output mode {$module}</h5>
<p class="list-group-item-text">{ $err:description }</p>
</div>
}
let $odd := doc($config:odd-root || "/" || $source)
let $pi := tpu:parse-pi($odd, ())
for $module in
if ($pi?output) then
tokenize($pi?output)
else
("web", "print", "latex", "epub")
return
try {
for $file in pmu:process-odd(
odd:get-compiled($config:odd-root, $source),
$config:output-root,
$module,
"../" || $config:output,
$config:module-config)?("module")
let $src := util:binary-to-string(util:binary-doc($file))
let $compiled := util:compile-query($src, ())
return
if ($compiled/error) then
<div class="list-group-item-danger">
<h5 class="list-group-item-heading">{local:load-source($file, $compiled/error/@line)}:</h5>
<p class="list-group-item-text">{ $compiled/error/string() }</p>
<pre class="list-group-item-text">{ local:get-line($src, $compiled/error/@line)}</pre>
</div>
else
<div class="list-group-item-success">{$file}</div>
} catch * {
<div class="list-group-item-danger">
<h5 class="list-group-item-heading">Error for output mode {$module}</h5>
<p class="list-group-item-text">{ $err:description }</p>
</div>
}
return
<div class="errors">
<h4>Regenerated XQuery code from ODD files</h4>
......
xquery version "3.1";
import module namespace config="http://www.tei-c.org/tei-simple/config" at "../config.xqm";
import module namespace docx="http://existsolutions.com/teipublisher/docx";
import module namespace docx2tei="http://www.tei-c.org/pm/models/docx/tei/module"
at "../../transform/docx-tei-module.xql";
declare namespace json="http://www.json.org";
......@@ -10,7 +14,14 @@ declare function local:upload($root, $paths, $payloads) {
for-each-pair($paths, $payloads, function($path, $data) {
try {
let $path :=
if (ends-with($path, ".odd")) then
if (ends-with($path, ".docx")) then
let $mediaPath := $config:data-root || "/" || $root || "/" || xmldb:encode($path) || ".media"
let $stored := xmldb:store($config:data-root || "/" || $root, xmldb:encode($path), $data)
let $tei :=
docx:process($stored, $config:data-root, docx2tei:transform#2, $mediaPath)
return
xmldb:store($config:data-root || "/" || $root, xmldb:encode($path) || ".xml", $tei)
else if (ends-with($path, ".odd")) then
xmldb:store($config:odd-root, xmldb:encode($path), $data)
else
xmldb:store($config:data-root || "/" || $root, xmldb:encode($path), $data)
......
......@@ -3,9 +3,9 @@
<fileDesc>
<titleStmt>
<title>Dantiscus' Letters
<desc>16th c. correspondence with facsimile and encoding of transcriptional features and prosopographical information</desc>
</title>
</titleStmt>
......@@ -36,7 +36,7 @@
<rendition selector=".choice">
color: #888888;
</rendition>
</tagsDecl>
</encodingDesc>
<revisionDesc>
......@@ -52,7 +52,7 @@
<param name="content" value="@n"/>
<param name="facs" value="replace(@facs, '^iiif:(.*)$', '$1')"/>
<outputRendition xml:space="preserve">
......@@ -72,7 +72,7 @@
</outputRendition>
</model>
<model behaviour="omit">
......@@ -89,9 +89,9 @@
</outputRendition>
</model>
</elementSpec>
<elementSpec ident="choice" mode="change">
<model output="plain" predicate="sic and corr" behaviour="inline">
<param name="content" value="corr[1]"/>
......@@ -187,7 +187,7 @@
<modelSequence output="web" predicate="$parameters?header='short'">
<model behaviour="link">
<param name="content" value="title[1]"/>
<param name="link" value="$parameters?doc"/>
<param name="uri" value="$parameters?doc"/>
</model>
<model behaviour="block">
<param name="content" value="subsequence(title, 2)"/>
......@@ -219,4 +219,4 @@
</schemaSpec>
</body>
</text>
</TEI>
\ No newline at end of file
</TEI>
......@@ -3,8 +3,8 @@
<teiHeader>
<fileDesc>
<titleStmt>
<title>Processing Model for Docbook v5
<title>Processing Model for Docbook v5
<desc>Processing of Docbook format</desc>
</title>
<title type="short">Docbook v5 </title>
......@@ -212,27 +212,27 @@
</model>
<model predicate="$parameters?mode='breadcrumbs'" behaviour="inline">
<outputRendition xml:space="preserve" scope="before">
content: ' &gt; ';
color: #607d8b;
</outputRendition>
</model>
<model predicate="parent::note" behaviour="inline"/>
<model predicate="parent::info and $parameters?header='short'" behaviour="link">
<param name="link" value="$parameters?doc"/>
<param name="uri" value="$parameters?doc"/>
</model>
<model behaviour="heading" cssClass="title">
<param name="level" value="if ($parameters?view='single') then count(ancestor::section) + 1 else count($get(.)/ancestor::section)"/>
......@@ -370,16 +370,16 @@
<model output="epub" behaviour="block">
<param name="content" value="text()"/>
<outputRendition xml:space="preserve">
font-family: monospace;
margin: 1em 0 1em .5em;
padding: 1em 0 1em .5em;
white-space: pre-wrap;
</outputRendition>
</model>
<model output="latex" behaviour="code">
......@@ -399,16 +399,16 @@ white-space: pre-wrap;
<model output="epub" behaviour="block">
<param name="content" value="text()"/>
<outputRendition xml:space="preserve">
font-family: monospace;
margin: 1em 0 1em .5em;
padding: 1em 0 1em .5em;
white-space: pre-wrap;
</outputRendition>
</model>
<model output="latex" behaviour="code"/>
......@@ -439,10 +439,10 @@ white-space: pre-wrap;
<elementSpec ident="note">
<model output="epub" behaviour="block">
<outputRendition xml:space="preserve">
border-top: 1px solid #C0C4C0;
border-bottom: 1px solid #C0C4C0;
margin: 1em 0 1em .5em;
......@@ -450,10 +450,10 @@ padding: 1em 0 1em .5em;
-webkit-column-break-inside: avoid; /* Chrome, Safari, Opera */
page-break-inside: avoid; /* Firefox */
break-inside: avoid; /* IE 10+ */
</outputRendition>
</model>
<model output="latex" behaviour="inline">
......@@ -482,7 +482,7 @@ padding: 1em 0 1em .5em;
</elementSpec>
<elementSpec ident="link">
<model output="epub" predicate="@role='source'" behaviour="inline">
<param name="link" value="@xlink:href"/>
<param name="uri" value="@xlink:href"/>
</model>
<model output="web" predicate="@role='source'" behaviour="inline">
<param name="path" value="@xlink:href"/>
......@@ -490,21 +490,21 @@ padding: 1em 0 1em .5em;
[[content]] <iron-icon icon="icons:open-in-new"/>
</pb-edit-xml></pb:template>
<outputRendition xml:space="preserve">
text-decoration: underline;
--iron-icon-height: 16px;
vertical-align: top;
cursor: pointer;
</outputRendition>
</model>
<model predicate="@linkend" behaviour="link">
<param name="link" value="concat('?odd=', request:get-parameter('odd', ()), '&amp;amp;view=', request:get-parameter('view', ()), '&amp;amp;id=', @linkend)"/>
<param name="uri" value="concat('?odd=', request:get-parameter('odd', ()), '&amp;amp;view=', request:get-parameter('view', ()), '&amp;amp;id=', @linkend)"/>
</model>
<model behaviour="link">
<param name="link" value="@xlink:href"/>
<param name="uri" value="@xlink:href"/>
</model>
</elementSpec>
<elementSpec ident="*">
......@@ -513,25 +513,25 @@ cursor: pointer;
<elementSpec ident="guibutton" mode="add">
<model behaviour="inline">
<outputRendition xml:space="preserve">
color: #fff;
background-color: #909090;
padding-left: 4px;
padding-right: 4px;
border: 1px solid #707070;
</outputRendition>
</model>
</elementSpec>
......@@ -565,19 +565,19 @@ Not available in PDF edition. Go to \url{[[content]]} to view.
<model predicate="$parameters?path = $parameters?active" behaviour="omit"/>
<model behaviour="block">
<outputRendition xml:space="preserve">
color: #909090;
padding-left: 10px;
border-left: 3px solid #c0c0c0;
</outputRendition>
</model>
</elementSpec>
......@@ -585,23 +585,23 @@ border-left: 3px solid #c0c0c0;
<model behaviour="inline" cssClass="pubdate">
<param name="content" value="format-date(., '[MNn] [D1], [Y0001]', 'en_US', (), ())"/>
<outputRendition xml:space="preserve" scope="before">
content: '\00B7';
padding-right: 8px;
padding-left: 8px;
</outputRendition>
<outputRendition xml:space="preserve">
color: #808080;
......@@ -614,4 +614,4 @@ border-left: 3px solid #c0c0c0;
</schemaSpec>
</body>
</text>
</TEI>
\ No newline at end of file
</TEI>
<?teipublisher output="tei"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:pb="http://teipublisher.com/1.0" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:rel="http://schemas.openxmlformats.org/package/2006/relationships" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">
<teiHeader>
<fileDesc>
<titleStmt>
<title>Word DOCX
<desc>Convert DOCX via ODD</desc>
</title>
<title type="short">DOCX Import</title>
</titleStmt>
<publicationStmt>
<publisher>eXistSolutions GmbH</publisher>
<availability>
<licence target="https://www.gnu.org/licenses/gpl-3.0.en.html">Distributed under GNU General Public License</licence>
<p>Copyright 2017 <ref target="http://existsolutions.com">eXistSolutions GmbH</ref>
</p>
<p>This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.</p>
<p>This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.</p>
</availability>
</publicationStmt>
<sourceDesc>
<p>Generated by <ref target="http://tei-publisher.com">TEI Publisher</ref>
</p>
<p>born digital</p>
</sourceDesc>
</fileDesc>
<revisionDesc>
<change when="2019-05-07+02:00">Initial version</change>
</revisionDesc>
</teiHeader>
<text>
<body>
<schemaSpec start="TEI teiCorpus" ident="docx" ns="http://schemas.openxmlformats.org/wordprocessingml/2006/main"> <elementSpec ident="body" mode="add">
<model behaviour="body"/>
</elementSpec>
<elementSpec ident="p" mode="add">
<model predicate="$parameters?pstyle(.)/name[matches(@w:val, &#34;quote$&#34;, &#34;i&#34;)]" behaviour="cit"/>
<model predicate="$parameters?nstyle(.)/numFmt" behaviour="listItem">
<param name="level" value="$parameters?nstyle(.)/@w:ilvl"/>
<param name="type" value="if ($parameters?nstyle(.)/numFmt[@w:val = 'bullet']) then () else 'ordered'"/>
</model>
<model predicate="$parameters?pstyle(.)/name[matches(@w:val, &#34;^(heading|title|subtitle)&#34;, &#34;i&#34;)]" behaviour="heading">
<param name="level" value="let $l := $parameters?pstyle(.)//outlineLvl/@w:val return if ($l) then $l/number() + 1 else 0"/>
</model>
<model behaviour="paragraph"/>
</elementSpec>
<elementSpec ident="r" mode="add">
<model predicate="drawing" behaviour="inline">
<param name="content" value=".//pic:pic"/>
</model>
<model predicate="footnoteReference" behaviour="note">
<param name="content" value="$parameters?footnote(.)"/>
<param name="place" value="'footnote'"/>
</model>
<model predicate="endnoteReference" behaviour="note">
<param name="content" value="$parameters?endnote(.)"/>
<param name="place" value="'endnote'"/>
</model>
<model predicate="$parameters?cstyle(.)/name[starts-with(@w:val, 'tei:')]" behaviour="inline">
<param name="tei_element" value="substring-after($parameters?cstyle(.)/name/@w:val, 'tei:')"/>
</model>
<model predicate="rPr/u or $parameters?cstyle(.)/rPr/u" behaviour="inline">
<pb:template xmlns="" xml:space="preserve"><hi xmlns="http://www.tei-c.org/ns/1.0" rend="underline">[[content]]</hi></pb:template>
</model>
<model predicate="rPr/b or $parameters?cstyle(.)/rPr/b" behaviour="inline">
<pb:template xmlns="" xml:space="preserve"><hi xmlns="http://www.tei-c.org/ns/1.0" rend="bold">[[content]]</hi></pb:template>
</model>
<model predicate="rPr/(i|caps) or $parameters?cstyle(.)/rPr/(i|caps)" behaviour="inline">
<pb:template xmlns="" xml:space="preserve"><hi xmlns="http://www.tei-c.org/ns/1.0">[[content]]</hi></pb:template>
</model>
<model behaviour="inline"/>
</elementSpec>
<elementSpec ident="document" mode="add">
<model behaviour="document">
<param name="content" value="($parameters?properties, .)"/>
</model>
</elementSpec>
<elementSpec ident="bookmarkStart" mode="add">
<model behaviour="anchor">
<param name="id" value="@w:name"/>
</model>
</elementSpec>
<elementSpec ident="hyperlink" mode="add">
<model predicate="@w:anchor" behaviour="link">
<param name="uri" value="'#' || @w:anchor"/>
</model>
<model behaviour="link">
<param name="uri" value="$parameters?link(.)/@Target/string()"/>
</model>
</elementSpec>
<elementSpec ident="cp:coreProperties" mode="add">
<model behaviour="metadata">
<param name="title" value="if (dc:title/node()) then dc:title else replace(util:collection-name(.), '^.*?/([^/]+)/docProps.*$', '$1')"/>
<param name="author" value="dc:creator"/>
<pb:template xmlns="" xml:space="preserve"><fileDesc xmlns="http://www.tei-c.org/ns/1.0">
<titleStmt>
<title>[[title]]</title>
[[author]]
</titleStmt>
<publicationStmt>
<p>Information about publication or distribution</p>
</publicationStmt>
<sourceDesc>
<p>Information about the source</p>
</sourceDesc>
</fileDesc></pb:template>
</model>
</elementSpec>
<elementSpec ident="dc:title" mode="add">
<model behaviour="inline"/>
</elementSpec>
<elementSpec ident="dc:author" mode="add"/>
<elementSpec ident="dc:creator" mode="add">
<model behaviour="inline">
<param name="tei_element" value="'author'"/>
</model>
</elementSpec>
<elementSpec ident="tbl" mode="add">
<model behaviour="table">
<param name="content" value="tr"/>
</model>
</elementSpec>
<elementSpec ident="tr" mode="add">
<model behaviour="row">
<param name="content" value="tc"/>
</model>
</elementSpec>
<elementSpec ident="tc" mode="add">
<model behaviour="cell">
<param name="content" value="p"/>
<param name="cols" value="tcPr/gridSpan/@w:val"/>
</model>
</elementSpec>
<elementSpec ident="t" mode="add">
<model behaviour="text"/>
</elementSpec>
<elementSpec ident="*" mode="add">
<model behaviour="omit"/>
</elementSpec>
<elementSpec ident="pic:pic" mode="add">
<model behaviour="graphic">
<param name="url" value="let $id := .//a:blip/@r:embed let $mediaColl := $parameters?filename || &#34;.media/&#34; let $target := $parameters?rels/rel:Relationship[@Id=$id]/@Target return $mediaColl || substring-after($target, &#34;media/&#34;)"/>
</model>
</elementSpec>
<elementSpec ident="smartTag" mode="add">
<model behaviour="inline"/>
</elementSpec>
<elementSpec ident="pict" mode="add">
<model behaviour="inline">
<param name="content" value=".//v:imagedata"/>
</model>
</elementSpec>
<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>
</schemaSpec>
</body>
</text>
</TEI>
......@@ -2,8 +2,8 @@
<teiHeader>
<fileDesc>
<titleStmt>
<title>Graves' Letters
<title>Graves' Letters
<desc>Modern correspondence with visualization of prosopographical and geographical information</desc>
</title>
</titleStmt>
......@@ -31,11 +31,11 @@
</fileDesc>
<encodingDesc>
<tagsDecl>
<pb:behaviour ident="glossary" output="latex">
<pb:behaviour ident="glossary" output="latex">
<pb:param name="id" value="@xml:id"/>
<pb:param name="name"/>
<pb:param name="note"/>
<pb:template>\newglossaryentry{[[id]]} {
<pb:template>\newglossaryentry{[[id]]} {
name=[[name]],
description={[[note]]}
}</pb:template>
......@@ -85,10 +85,10 @@
<param name="emit" value="'letter'"/>
<param name="duration" value="1000"/>
<outputRendition>
color: #1565c0;
cursor: pointer;
</outputRendition>
</model>
<model predicate="@type='person' and id(substring-after(@ref, '#'), root($parameters?root))" behaviour="webcomponent">
......@@ -98,10 +98,10 @@ cursor: pointer;
<param name="scroll" value="true()"/>
<param name="emit" value="'letter'"/>
<outputRendition>
color: #bf360c;
cursor: pointer;
</outputRendition>
</model>
<model predicate="@type='place'" behaviour="inline">
......@@ -150,9 +150,9 @@ cursor: pointer;
<param name="content" value="'Places'"/>
<param name="level" value="2"/>
<outputRendition>
......@@ -199,9 +199,9 @@ border-bottom: 1px solid #A0A0A0;
</outputRendition>
</model>
<model behaviour="block">
......@@ -211,9 +211,9 @@ border-bottom: 1px solid #A0A0A0;
<param name="content" value="'People'"/>
<param name="level" value="2"/>
<outputRendition>
......@@ -238,9 +238,9 @@ border-bottom: 1px solid #A0A0A0;