Skip to content

Commit

Permalink
follow the contribution rule regarding namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
lueck committed Oct 9, 2024
1 parent 0bc83bd commit 2c42df7
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 70 deletions.
55 changes: 27 additions & 28 deletions xsl/latex/librend.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
name="https://scdh.zivgitlabpages.uni-muenster.de/tei-processing/transform/xsl/latex/librend.xsl"
package-version="1.0.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:map="http://www.w3.org/2005/xpath-functions/map"
xmlns:i18n="http://scdh.wwu.de/transform/i18n#" xmlns:text="http://scdh.wwu.de/transform/text#"
xmlns:rend="http://scdh.wwu.de/transform/rend#" xmlns:text="http://scdh.wwu.de/transform/text#"
xmlns:app="http://scdh.wwu.de/transform/app#" xmlns:note="http://scdh.wwu.de/transform/note#"
xmlns:edmac="http://scdh.wwu.de/transform/edmac#" exclude-result-prefixes="#all"
xpath-default-namespace="http://www.tei-c.org/ns/1.0" version="3.0">

<!-- names of indices (used by imakeidx) -->
<xsl:param name="text:indices" as="xs:string*" required="false"
<xsl:param name="rend:indices" as="xs:string*" required="false"
select="'person', 'place', 'org', 'event'"/>

<xsl:use-package
Expand Down Expand Up @@ -50,38 +50,38 @@

<!-- add hooks everywhere -->
<xsl:template mode="text:text app:reading-text note:editorial" match="*">
<xsl:call-template name="text:hooks"/>
<xsl:call-template name="rend:hooks"/>
</xsl:template>


<!-- named entities make up indices. Its up to downstream packages to use them or to let the go. -->

<xsl:template mode="text:text app:reading-text note:editorial" match="rs">
<xsl:call-template name="text:index-entity">
<xsl:call-template name="rend:index-entity">
<xsl:with-param name="index" select="@type"/>
</xsl:call-template>
</xsl:template>

<xsl:template mode="text:text app:reading-text note:editorial" match="persName">
<xsl:call-template name="text:index-entity">
<xsl:call-template name="rend:index-entity">
<xsl:with-param name="index">person</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template mode="text:text app:reading-text note:editorial" match="placeName">
<xsl:call-template name="text:index-entity">
<xsl:call-template name="rend:index-entity">
<xsl:with-param name="index">place</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template mode="text:text app:reading-text note:editorial" match="orgName">
<xsl:call-template name="text:index-entity">
<xsl:call-template name="rend:index-entity">
<xsl:with-param name="index">org</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template mode="text:text app:reading-text note:editorial" match="eventName">
<xsl:call-template name="text:index-entity">
<xsl:call-template name="rend:index-entity">
<xsl:with-param name="index">event</xsl:with-param>
</xsl:call-template>
</xsl:template>
Expand All @@ -90,47 +90,46 @@
</xsl:use-package>

<!-- hooks -->
<xsl:mode name="text:hook-ahead" on-no-match="deep-skip" visibility="public"/>
<xsl:mode name="text:hook-before" on-no-match="deep-skip" visibility="public"/>
<xsl:mode name="text:hook-after" on-no-match="deep-skip" visibility="public"/>
<xsl:mode name="text:hook-behind" on-no-match="deep-skip" visibility="public"/>
<xsl:mode name="rend:hook-ahead" on-no-match="deep-skip" visibility="public"/>
<xsl:mode name="rend:hook-before" on-no-match="deep-skip" visibility="public"/>
<xsl:mode name="rend:hook-after" on-no-match="deep-skip" visibility="public"/>
<xsl:mode name="rend:hook-behind" on-no-match="deep-skip" visibility="public"/>

<xsl:template name="text:hooks" visibility="public">
<xsl:template name="rend:hooks" visibility="public">
<xsl:context-item as="element()" use="required"/>
<xsl:apply-templates mode="text:hook-ahead" select="."/>
<xsl:apply-templates mode="rend:hook-ahead" select="."/>
<xsl:call-template name="edmac:edlabel">
<xsl:with-param name="suffix" select="'-start'"/>
</xsl:call-template>
<xsl:apply-templates mode="text:hook-before" select="."/>
<xsl:apply-templates mode="rend:hook-before" select="."/>
<!-- #current mode on children.
This works albeit we are in a named template!
Its guaranteed by the specs.
Quote From the XSLT 3.0 TR:
Its guaranteed by the specs. Quote From the XSLT 3.0 TR:
"Definition: At any point in the processing of a stylesheet,
there is a current mode." -->
<xsl:apply-templates mode="#current"/>
<xsl:apply-templates mode="text:hook-after" select="."/>
<xsl:apply-templates mode="rend:hook-after" select="."/>
<xsl:call-template name="edmac:edlabel">
<xsl:with-param name="suffix" select="'-end'"/>
</xsl:call-template>
<xsl:apply-templates mode="text:hook-behind" select="."/>
<xsl:apply-templates mode="rend:hook-behind" select="."/>
</xsl:template>


<!-- named template that generates entries to the indices.
This also calls the hooks.
The index parameter should be of the values of rs/@type, i.e., 'person', 'place', 'org', 'event', etc. -->
<xsl:template name="text:index-entity" visibility="public">
<xsl:template name="rend:index-entity" visibility="public">
<xsl:context-item as="element()" use="required"/>
<xsl:param name="index" as="xs:string" required="true"/>
<!-- early hooks and start label -->
<xsl:apply-templates mode="text:hook-ahead" select="."/>
<xsl:apply-templates mode="rend:hook-ahead" select="."/>
<xsl:call-template name="edmac:edlabel">
<xsl:with-param name="suffix" select="'-start'"/>
</xsl:call-template>
<xsl:apply-templates mode="text:hook-before" select="."/>
<xsl:apply-templates mode="rend:hook-before" select="."/>
<!-- output index macro -->
<xsl:for-each select="text:index-keys(., $index)">
<xsl:for-each select="rend:index-keys(., $index)">
<xsl:text>\index[</xsl:text>
<xsl:value-of select="$index"/>
<xsl:text>]{</xsl:text>
Expand All @@ -140,15 +139,15 @@
<!-- current mode on children -->
<xsl:apply-templates mode="#current"/>
<!-- late hooks and ending label -->
<xsl:apply-templates mode="text:hook-after" select="."/>
<xsl:apply-templates mode="rend:hook-after" select="."/>
<xsl:call-template name="edmac:edlabel">
<xsl:with-param name="suffix" select="'-end'"/>
</xsl:call-template>
<xsl:apply-templates mode="text:hook-behind" select="."/>
<xsl:apply-templates mode="rend:hook-behind" select="."/>
</xsl:template>

<!-- likely to be replaced with a more sophisticated function that gets names for keys -->
<xsl:function name="text:index-keys" as="xs:string*" visibility="public">
<xsl:function name="rend:index-keys" as="xs:string*" visibility="public">
<xsl:param name="context" as="element()"/>
<xsl:param name="index" as="xs:string"/>
<xsl:variable name="keys" as="xs:string*">
Expand All @@ -166,12 +165,12 @@


<!-- contributions to the latex prologue -->
<xsl:template name="text:latex-header-index" visibility="public">
<xsl:template name="rend:latex-header-index" visibility="public">
<xsl:context-item as="item()" use="required"/>
<xsl:text>&lb;\makeatletter%</xsl:text>
<xsl:text>&lb;\@ifpackageloaded{imakeidx}{}{\usepackage{imakeidx}}%</xsl:text>
<xsl:text>&lb;\makeatother%</xsl:text>
<xsl:for-each select="(root(.)//rs/@type ! string(), $text:indices) => distinct-values()">
<xsl:for-each select="(root(.)//rs/@type ! string(), $rend:indices) => distinct-values()">
<xsl:text>&lb;\makeindex[name=</xsl:text>
<xsl:value-of select="."/>
<xsl:text>,title={</xsl:text>
Expand Down
64 changes: 33 additions & 31 deletions xsl/latex/libtext.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
package-version="1.0.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:map="http://www.w3.org/2005/xpath-functions/map"
xmlns:i18n="http://scdh.wwu.de/transform/i18n#" xmlns:text="http://scdh.wwu.de/transform/text#"
xmlns:edmac="http://scdh.wwu.de/transform/edmac#" exclude-result-prefixes="#all"
xpath-default-namespace="http://www.tei-c.org/ns/1.0" version="3.0" default-mode="text:text">
xmlns:edmac="http://scdh.wwu.de/transform/edmac#" xmlns:rend="http://scdh.wwu.de/transform/rend#"
exclude-result-prefixes="#all" xpath-default-namespace="http://www.tei-c.org/ns/1.0" version="3.0"
default-mode="text:text">


<!-- corrects how the section level is set from the level of divs a head coccurs in -->
Expand All @@ -29,7 +30,8 @@
<xsl:use-package
name="https://scdh.zivgitlabpages.uni-muenster.de/tei-processing/transform/xsl/latex/librend.xsl"
package-version="1.0.0">
<xsl:accept component="mode" names="text:*" visibility="public"/>
<xsl:accept component="mode" names="text:text" visibility="public"/>
<xsl:accept component="mode" names="rend:*" visibility="public"/>
<xsl:accept component="function" names="*" visibility="public"/>
<xsl:accept component="template" names="*" visibility="public"/>

Expand Down Expand Up @@ -60,12 +62,12 @@

<xsl:template match="head">
<xsl:variable name="level" as="xs:integer" select="text:section-level(.)"/>
<xsl:apply-templates mode="text:hook-ahead" select=".">
<xsl:apply-templates mode="rend:hook-ahead" select=".">
<xsl:with-param name="level" as="xs:integer" select="$level" tunnel="true"/>
</xsl:apply-templates>
<xsl:text>&lb;</xsl:text>
<xsl:call-template name="edmac:par-start"/>
<xsl:apply-templates mode="text:hook-before" select=".">
<xsl:apply-templates mode="rend:hook-before" select=".">
<xsl:with-param name="level" as="xs:integer" select="$level" tunnel="true"/>
</xsl:apply-templates>
<xsl:text>&lb;\eled</xsl:text>
Expand All @@ -81,17 +83,17 @@
<xsl:with-param name="suffix" select="'-end'"/>
</xsl:call-template>
<xsl:text>}</xsl:text>
<xsl:apply-templates mode="text:hook-after" select=".">
<xsl:apply-templates mode="rend:hook-after" select=".">
<xsl:with-param name="level" as="xs:integer" select="$level" tunnel="true"/>
</xsl:apply-templates>
<xsl:call-template name="edmac:par-end"/>
<xsl:text>&lb;&lb;</xsl:text>
<xsl:apply-templates mode="text:hook-behind" select=".">
<xsl:apply-templates mode="rend:hook-behind" select=".">
<xsl:with-param name="level" as="xs:integer" select="$level" tunnel="true"/>
</xsl:apply-templates>
</xsl:template>

<xsl:template mode="text:hook-ahead" match="head">
<xsl:template mode="rend:hook-ahead" match="head">
<xsl:param name="level" as="xs:integer" select="0" tunnel="true"/>
<xsl:choose>
<xsl:when test="not($edmac:section-workaround)"/>
Expand All @@ -104,7 +106,7 @@
</xsl:choose>
</xsl:template>

<xsl:template mode="text:hook-after" match="head">
<xsl:template mode="rend:hook-after" match="head">
<xsl:param name="level" as="xs:integer" select="0" tunnel="true"/>
<xsl:choose>
<xsl:when test="not($edmac:section-workaround)"/>
Expand All @@ -118,15 +120,15 @@
</xsl:template>

<xsl:template match="div | div1 | div2 | div3 | div4 | div5 | div6 | div7">
<xsl:apply-templates mode="text:hook-ahead" select="."/>
<xsl:apply-templates mode="rend:hook-ahead" select="."/>
<xsl:call-template name="edmac:edlabel">
<xsl:with-param name="suffix" select="'-start'"/>
</xsl:call-template>
<xsl:apply-templates/>
<xsl:call-template name="edmac:edlabel">
<xsl:with-param name="suffix" select="'-end'"/>
</xsl:call-template>
<xsl:apply-templates mode="text:hook-behind" select="."/>
<xsl:apply-templates mode="rend:hook-behind" select="."/>
</xsl:template>

<xsl:template match="p">
Expand All @@ -143,39 +145,39 @@
</xsl:template>

<xsl:template match="lg[not(lg)]">
<xsl:apply-templates mode="text:hook-ahead" select="."/>
<xsl:apply-templates mode="rend:hook-ahead" select="."/>
<xsl:call-template name="edmac:stanza-start"/>
<xsl:call-template name="edmac:edlabel">
<xsl:with-param name="suffix" select="'-start'"/>
</xsl:call-template>
<xsl:apply-templates mode="text:hook-before" select="."/>
<xsl:apply-templates mode="rend:hook-before" select="."/>
<xsl:apply-templates/>
<xsl:apply-templates mode="text:hook-after" select="."/>
<xsl:apply-templates mode="rend:hook-after" select="."/>
<xsl:call-template name="edmac:edlabel">
<xsl:with-param name="suffix" select="'-end'"/>
</xsl:call-template>
<xsl:call-template name="edmac:stanza-end"/>
<xsl:apply-templates mode="text:hook-behind" select="."/>
<xsl:apply-templates mode="rend:hook-behind" select="."/>
</xsl:template>

<!-- a single verse not in lg is output as a stanza -->
<xsl:template match="l[not(ancestor::lg)]">
<xsl:apply-templates mode="text:hook-ahead" select="."/>
<xsl:apply-templates mode="rend:hook-ahead" select="."/>
<xsl:call-template name="edmac:stanza-start"/>
<xsl:call-template name="edmac:edlabel">
<xsl:with-param name="suffix" select="'-start'"/>
</xsl:call-template>
<xsl:apply-templates mode="text:hook-before" select="."/>
<xsl:apply-templates mode="rend:hook-before" select="."/>
<xsl:variable name="latex" as="text()*">
<xsl:call-template name="text:verse"/>
</xsl:variable>
<xsl:value-of select="edmac:normalize($latex)"/>
<xsl:apply-templates mode="text:hook-after" select="."/>
<xsl:apply-templates mode="rend:hook-after" select="."/>
<xsl:call-template name="edmac:edlabel">
<xsl:with-param name="suffix" select="'-end'"/>
</xsl:call-template>
<xsl:call-template name="edmac:stanza-end"/>
<xsl:apply-templates mode="text:hook-behind" select="."/>
<xsl:apply-templates mode="rend:hook-behind" select="."/>
</xsl:template>

<xsl:template match="l[ancestor::lg]">
Expand Down Expand Up @@ -260,9 +262,9 @@
<xsl:call-template name="edmac:edlabel">
<xsl:with-param name="suffix" select="'-start'"/>
</xsl:call-template>
<xsl:apply-templates mode="text:hook-before" select="."/>
<xsl:apply-templates mode="rend:hook-before" select="."/>
<xsl:text>[...]</xsl:text>
<xsl:apply-templates mode="text:hook-after" select="."/>
<xsl:apply-templates mode="rend:hook-after" select="."/>
<xsl:call-template name="text:inline-footnotes"/>
<xsl:call-template name="edmac:app-end"/>
</xsl:template>
Expand All @@ -272,11 +274,11 @@
<xsl:call-template name="edmac:edlabel">
<xsl:with-param name="suffix" select="'-start'"/>
</xsl:call-template>
<xsl:apply-templates mode="text:hook-before" select="."/>
<xsl:apply-templates mode="rend:hook-before" select="."/>
<!--xsl:text>[</xsl:text-->
<xsl:apply-templates/>
<!--xsl:text>]</xsl:text-->
<xsl:apply-templates mode="text:hook-after" select="."/>
<xsl:apply-templates mode="rend:hook-after" select="."/>
<xsl:call-template name="text:inline-footnotes"/>
<xsl:call-template name="edmac:app-end"/>
</xsl:template>
Expand All @@ -286,11 +288,11 @@
<xsl:call-template name="edmac:edlabel">
<xsl:with-param name="suffix" select="'-start'"/>
</xsl:call-template>
<xsl:apply-templates mode="text:hook-before" select="."/>
<xsl:apply-templates mode="rend:hook-before" select="."/>
<!--xsl:text>[? </xsl:text-->
<xsl:apply-templates/>
<!--xsl:text> ?]</xsl:text-->
<xsl:apply-templates mode="text:hook-after" select="."/>
<xsl:apply-templates mode="rend:hook-after" select="."/>
<xsl:call-template name="text:inline-footnotes"/>
<xsl:call-template name="edmac:app-end"/>
</xsl:template>
Expand All @@ -300,9 +302,9 @@
<xsl:call-template name="edmac:edlabel">
<xsl:with-param name="suffix" select="'-start'"/>
</xsl:call-template>
<xsl:apply-templates mode="text:hook-before" select="."/>
<xsl:apply-templates mode="rend:hook-before" select="."/>
<xsl:apply-templates select="corr"/>
<xsl:apply-templates mode="text:hook-after" select="."/>
<xsl:apply-templates mode="rend:hook-after" select="."/>
<xsl:call-template name="text:inline-footnotes"/>
<xsl:call-template name="edmac:app-end"/>
</xsl:template>
Expand All @@ -312,9 +314,9 @@
<xsl:call-template name="edmac:edlabel">
<xsl:with-param name="suffix" select="'-start'"/>
</xsl:call-template>
<xsl:apply-templates mode="text:hook-before" select="."/>
<xsl:apply-templates mode="rend:hook-before" select="."/>
<xsl:apply-templates/>
<xsl:apply-templates mode="text:hook-after" select="."/>
<xsl:apply-templates mode="rend:hook-after" select="."/>
<xsl:call-template name="text:inline-footnotes"/>
<xsl:call-template name="edmac:app-end"/>
</xsl:template>
Expand All @@ -324,9 +326,9 @@
<xsl:call-template name="edmac:edlabel">
<xsl:with-param name="suffix" select="'-start'"/>
</xsl:call-template>
<xsl:apply-templates mode="text:hook-before" select="."/>
<xsl:apply-templates mode="rend:hook-before" select="."/>
<xsl:apply-templates/>
<xsl:apply-templates mode="text:hook-after" select="."/>
<xsl:apply-templates mode="rend:hook-after" select="."/>
<xsl:call-template name="text:inline-footnotes"/>
<xsl:call-template name="edmac:app-end"/>
</xsl:template>
Expand Down
Loading

0 comments on commit 2c42df7

Please sign in to comment.