Skip to content

Commit

Permalink
Merge pull request #371 from Edirom/cleanup/update-tei-stylesheets
Browse files Browse the repository at this point in the history
Update tei stylesheets
  • Loading branch information
bwbohl authored Apr 15, 2024
2 parents b6fc47f + afe2bab commit f613eb7
Show file tree
Hide file tree
Showing 39 changed files with 531 additions and 19,213 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[submodule "packages/eoTheme/resources/fonts/euryanthe"]
path = packages/eoTheme/resources/fonts/euryanthe
url = https://github.com/Edirom/EuryantheFont
[submodule "Stylesheets"]
path = add/data/xslt/tei/Stylesheets
url = https://github.com/TEIC/Stylesheets
branch = released
52 changes: 31 additions & 21 deletions add/data/xql/getText.xql
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,28 @@ xquery version "3.1";
(: IMPORTS ================================================================= :)

import module namespace edition = "http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm";

import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm";

(: NAMESPACE DECLARATIONS ================================================== :)

declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";

declare namespace request = "http://exist-db.org/xquery/request";

declare namespace tei = "http://www.tei-c.org/ns/1.0";

declare namespace xhtml = "http://www.w3.org/1999/xhtml";

(: OPTION DECLARATIONS ===================================================== :)

declare option exist:serialize "method=xhtml media-type=text/html omit-xml-declaration=yes indent=yes";
(:declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes";:)
declare option output:method "xhtml";

declare option output:media-type "text/html";

declare option output:omit-xml-declaration "yes";

declare option output:indent "yes";

(: QUERY BODY ============================================================== :)

Expand All @@ -28,8 +38,8 @@ let $path := request:get-parameter('path', '')
let $page := request:get-parameter('page', '')
let $doc := eutil:getDoc($uri)/root()
let $contextPath := request:get-context-path()

let $xslInstruction := $doc//processing-instruction(xml-stylesheet)

let $xslInstruction :=
for $i in fn:serialize($xslInstruction, ())
return
Expand All @@ -56,6 +66,7 @@ let $doc :=
else (
let $pb1 := $doc//tei:pb[@facs eq '#' || $page]/@n
let $pb2 := ($doc//tei:pb[@facs eq '#' || $page]/following::tei:pb)[1]/@n

return
transform:transform($doc, doc('../xslt/reduceToPage.xsl'),
<parameters>
Expand All @@ -65,8 +76,7 @@ let $doc :=
)
)

let $base := replace(system:get-module-load-path(), 'embedded-eXist-server', '') (:TODO:)

let $base := replace(system:get-module-load-path(), 'embedded-eXist-server', '')
let $edition := request:get-parameter('edition', '')
let $imageserver := eutil:getPreference('image_server', $edition)

Expand All @@ -80,7 +90,7 @@ let $xsl :=
if ($xslInstruction) then
($xslInstruction)
else
('../xslt/teiBody2HTML.xsl')
('../xslt/tei/profiles/edirom-body/teiBody2HTML.xsl')

(:TODO introduce injection-point for tei-stylesheet parameters :)
let $params := (
Expand All @@ -89,26 +99,26 @@ let $params := (
<param name="docUri" value="{$uri}"/>,
<param name="contextPath" value="{$contextPath}"/>,
(: parameters for the TEI Stypesheets :)
<param name="autoHead" value="'false'"/>,
<param name="autoToc" value="'false'"/>,
<param name="autoHead" value="false"/>,
<param name="autoToc" value="false"/>,
<param name="base" value="{concat($base, '/../xslt/')}"/>,
<param name="documentationLanguage" value="{eutil:getLanguage($edition)}"/>,
<param name="footnoteBackLink" value="true"/>,
<param name="graphicsPrefix" value="{$imagePrefix}"/>, (:TODO frm XSLT <param name="graphicsPrefix"/>:)
<param name="numberHeadings" value="'false'"/>,
<param name="pageLayout" value="'CSS'"/>
<param name="graphicsPrefix" value="{$imagePrefix}"/>, (:TODO from XSLT <param name="graphicsPrefix"/>:)
<param name="numberHeadings" value="false"/>,
<param name="pageLayout" value="CSS"/>
)

let $doc :=
if ($xslInstruction) then
(transform:transform($doc, doc($xsl), <parameters>{$params}</parameters>))
else
(transform:transform($doc, doc($xsl), <parameters>{$params}</parameters>))
let $doc := transform:transform($doc, doc($xsl), <parameters>{$params}</parameters>)

let $doc :=
transform:transform($doc, doc('../xslt/edirom_idPrefix.xsl'),
<parameters>
<param name="idPrefix" value="{$idPrefix}"/></parameters>
)
(: Do a second transformation to add edirom online ID prefixes for unique ID values if object is open mutiple times :)
let $xsl := '../xslt/edirom_idPrefix.xsl'

let $params := (
<param name="idPrefix" value="{$idPrefix}"/>
)

let $doc := transform:transform($doc, doc($xsl), <parameters>{$params}</parameters>)

let $body := $doc//xhtml:body

Expand Down
55 changes: 54 additions & 1 deletion add/data/xslt/edirom_idPrefix.xsl
Original file line number Diff line number Diff line change
@@ -1,17 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:math="http://www.w3.org/2005/xpath-functions/math" exclude-result-prefixes="xs" version="3.0">
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" exclude-result-prefixes="xs xd" version="3.0">

<xd:doc scope="stylesheet">
<xd:desc>This stylesheet is intended asa sceond run on HTML content for the Edirom Online, in order to prepend any ID with a prefix and avoid invalid HTML when an object is open multiple times in one Edirom Online insatnce.</xd:desc>
</xd:doc>

<xd:doc scope="component">
<xd:desc>The $idPrefix parameter is submitted externally and is the value prepended to IDs etc.</xd:desc>
</xd:doc>
<xsl:param name="idPrefix"/>

<xd:doc scope="component">
<xd:desc>The root template</xd:desc>
</xd:doc>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>

<xd:doc>
<xd:desc>Override the dafault template for elements to also apply templates on the attribute axis.</xd:desc>
</xd:doc>
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>

<xd:doc scope="component">
<xd:desc>Process id attributes by prepending the $idPrefix.</xd:desc>
</xd:doc>
<xsl:template match="@id">
<xsl:attribute name="id" select="concat($idPrefix, .)"/>
</xsl:template>

<xd:doc scope="component">
<xd:desc>Process href attributes to prepend $idPrefix for fragment identifiers.</xd:desc>
</xd:doc>
<xsl:template match="@href">
<xsl:choose>
<xsl:when test="starts-with(., '#')">
Expand All @@ -22,13 +46,42 @@
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xd:doc scope="component">
<xd:desc>Process data-tipped-options attributes to include $idPrefix.</xd:desc>
</xd:doc>
<xsl:template match="@data-tipped-options">
<xsl:attribute name="data-tipped-options" select="replace(., 'inline: ''', concat('inline: ''', $idPrefix))"/>
</xsl:template>

<xd:doc scope="component">
<xd:desc>Override default template for attributes, to copy instead of printing text content.</xd:desc>
</xd:doc>
<xsl:template match="@*">
<xsl:copy/>
</xsl:template>

<xd:doc scope="component">
<xd:desc>Override default templates for text comments and processing instructions to copy nodes.</xd:desc>
</xd:doc>
<xsl:template match="text() | comment() | processing-instruction()">
<xsl:copy/>
</xsl:template>

<xd:doc scope="component">
<xd:desc>Process onclick attributes to prepend $idPrefix if starting fragement identifiers.</xd:desc>
</xd:doc>
<xsl:template match="@onclick">
<xsl:variable name="matchExpression">loadLink('#</xsl:variable>
<xsl:attribute name="onclick">
<xsl:analyze-string select="." regex="(loadLink\('#)">
<xsl:matching-substring>
<xsl:value-of select="regex-group(1) || $idPrefix"/>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:copy/>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
1 change: 1 addition & 0 deletions add/data/xslt/tei/Stylesheets
Submodule Stylesheets added at 2027bc
Loading

0 comments on commit f613eb7

Please sign in to comment.