Skip to content

Commit fbb45d4

Browse files
committed
Backporting apparatus bugfixes from PN.
git-svn-id: https://svn.code.sf.net/p/epidoc/code/trunk/example-p5-xslt@2163 85be4e97-ed4a-0410-b6a7-8d1dfdb05c0b
1 parent ed21e77 commit fbb45d4

File tree

2 files changed

+87
-31
lines changed

2 files changed

+87
-31
lines changed

tpl-apparatus.xsl

+59-25
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
<xsl:with-param name="part"><xsl:value-of select="$part3" /></xsl:with-param>
119119
<xsl:with-param name="pos">first</xsl:with-param>
120120
</xsl:call-template></xsl:when>
121-
<xsl:when test="contains($part3, ' : ')"><xsl:value-of select="substring-before($part3, ' :')"/></xsl:when>
121+
<xsl:when test="contains($part3, ' : ') and lem/@resp"><xsl:value-of select="substring-before($part3, ' :')"/></xsl:when>
122122
<xsl:otherwise>Current edition</xsl:otherwise>
123123
</xsl:choose>
124124

@@ -240,7 +240,7 @@
240240
<xsl:with-param name="obf" select="normalize-space($titleagg)"/>
241241
</xsl:call-template>
242242
</xsl:variable>
243-
<xsl:attribute name="title" select="$title"/>
243+
<xsl:attribute name="title"><xsl:apply-templates select="$title" mode="sqbrackets"/></xsl:attribute>
244244
<!-- <xsl:if test="$apptype = ('appbl')"> and $childtype != ''"> 'siccorr', 'subst', 'origreg', 'appalt' and $childtype='subst'"> -->
245245
<xsl:value-of select="normalize-space(replace(replace($part1, 'FNORD(\S)*', ''), '\(\*\)', ''))"/>
246246
<xsl:if test="normalize-space($part1) != '' and (not(ends-with(normalize-space($part1), ','))) and (not(ends-with(normalize-space($part1), '.')))">,</xsl:if> <!-- --><xsl:text> </xsl:text><xsl:value-of select="normalize-space(replace(replace($part3, 'FNORD(\S)*', ''), '\(\*\)', ''))"/>
@@ -351,7 +351,7 @@
351351
<!-- Used by: txPtchild, appcontent, teiaddanddel.xsl#t:add -->
352352
<xsl:param name="addpath" select="''"/>
353353
<xsl:param name="delpath"/><xsl:choose>
354-
<!-- Old encoding: (stil supported) -->
354+
<!-- Old encoding: (still supported) -->
355355
<xsl:when test="(
356356
not(preceding-sibling::node())
357357
or matches(preceding-sibling::node()[1][self::text()], '[\s\n\r\t]')
@@ -662,10 +662,10 @@
662662
</xsl:choose>
663663
</xsl:template>
664664

665-
666-
665+
<!-- The recurse_* templates handle isolating the piece of text that will be printed in the apparatus,
666+
by finding the word breaks before and after it.-->
667667
<xsl:template name="recurse_back">
668-
<!-- Recurse trhough preceding sibling nodes until a space or carriage return is found -->
668+
<!-- Recurse through preceding sibling nodes until a space or carriage return is found -->
669669
<!-- Used by hirend, appcontent -->
670670
<!-- When used by hirend ($origin='hi'), will strip diacritics -->
671671
<xsl:param name="step"/>
@@ -681,7 +681,27 @@
681681
<xsl:when test="$step[self::text()]">
682682
<xsl:choose>
683683
<xsl:when test="matches($step, '[\s\n\r\t]')">
684-
<xsl:copy-of select="$buildup"/>
684+
<xsl:choose>
685+
<xsl:when test="string-length($buildup) = 0">
686+
<xsl:choose>
687+
<xsl:when test="$origin='hi'">
688+
<xsl:call-template name="trans-string">
689+
<xsl:with-param name="trans-text">
690+
<xsl:call-template name="string-after-space">
691+
<xsl:with-param name="test-string" select="$step"/>
692+
</xsl:call-template>
693+
</xsl:with-param>
694+
</xsl:call-template>
695+
</xsl:when>
696+
<xsl:otherwise>
697+
<xsl:call-template name="string-after-space">
698+
<xsl:with-param name="test-string" select="$step"/>
699+
</xsl:call-template>
700+
</xsl:otherwise>
701+
</xsl:choose>
702+
</xsl:when>
703+
<xsl:otherwise><xsl:copy-of select="$buildup"/></xsl:otherwise>
704+
</xsl:choose>
685705
</xsl:when>
686706
<!-- if the text node is a first child and a space hasn't been located yet... -->
687707
<xsl:when test="not($step/preceding-sibling::node()[1])">
@@ -780,7 +800,7 @@
780800
<xsl:with-param name="origin" select="$origin"/>
781801
</xsl:call-template>
782802
</xsl:variable>
783-
<xsl:apply-templates select="$builddown"/>
803+
<xsl:apply-templates select="$builddown/node()"/>
784804
<xsl:copy-of select="$buildup"/>
785805
</xsl:when>
786806
<xsl:otherwise>
@@ -812,7 +832,7 @@
812832
<xsl:template name="recurse_down_back">
813833
<!-- Recurse through child nodes until a space or carriage return is found. Re-create elements when necessary -->
814834
<!-- Used by recurse_back -->
815-
<!-- Handles buidlup for right-to-left space/return search -->
835+
<!-- Handles buildup for right-to-left space/return search -->
816836
<xsl:param name="step"/>
817837
<xsl:param name="buildup"/>
818838
<xsl:param name="origin"/>
@@ -871,11 +891,7 @@
871891
<xsl:variable name="curstep-id" select="generate-id($step)"/>
872892
<xsl:choose>
873893
<xsl:when test="matches(., '[\s\n\r\t]')"/>
874-
<xsl:when test="for $i in following::text()[generate-id(ancestor::node()[1])=$curstep-id]
875-
return
876-
if (matches($i, '[\s\n\r\t]'))
877-
then false()
878-
else true()">
894+
<xsl:when test="following::text()[generate-id(ancestor::node()[1])=$curstep-id and matches(., '[\s\n\r\t]')]">
879895
<xsl:call-template name="recurse_down_back">
880896
<xsl:with-param name="step" select="following-sibling::node()[1]"/>
881897
<xsl:with-param name="buildup" select="buildup"/>
@@ -899,7 +915,7 @@
899915
</xsl:template>
900916

901917
<xsl:template name="recurse_forward">
902-
<!-- Recurse trhough following sibling nodes until a space or carriage return is found -->
918+
<!-- Recurse through following sibling nodes until a space or carriage return is found -->
903919
<!-- Used by hirend, appcontent -->
904920
<xsl:param name="step"/>
905921

@@ -1014,14 +1030,14 @@
10141030
</xsl:call-template>
10151031
</xsl:when>
10161032
<xsl:when test="($step[self::text] or $step[self::*]) and matches($step, '[\s\n\r\t]')">
1017-
<xsl:variable name="buildown">
1033+
<xsl:variable name="builddown">
10181034
<xsl:call-template name="recurse_down">
10191035
<xsl:with-param name="step" select="$step"/>
10201036
<xsl:with-param name="origin" select="$origin"/>
10211037
</xsl:call-template>
10221038
</xsl:variable>
10231039
<xsl:variable name="resolve">
1024-
<xsl:apply-templates select="$buildown"/>
1040+
<xsl:apply-templates select="$builddown/node()"/>
10251041
</xsl:variable>
10261042
<xsl:value-of select="$resolve"/>
10271043
</xsl:when>
@@ -1072,6 +1088,24 @@
10721088
<xsl:element name="{$step/name()}" xmlns="http://www.tei-c.org/ns/1.0">
10731089
<xsl:sequence select="$step/@*"/>
10741090
<xsl:choose>
1091+
<xsl:when test="local-name($step/node()[1]) = '' and matches($step/node()[1], '[\s\t\r\n]')">
1092+
<xsl:choose>
1093+
<xsl:when test="$origin='hi'">
1094+
<xsl:call-template name="trans-string">
1095+
<xsl:with-param name="trans-text">
1096+
<xsl:call-template name="string-before-space">
1097+
<xsl:with-param name="test-string" select="$step/node()[1]"/>
1098+
</xsl:call-template>
1099+
</xsl:with-param>
1100+
</xsl:call-template>
1101+
</xsl:when>
1102+
<xsl:otherwise>
1103+
<xsl:call-template name="string-before-space">
1104+
<xsl:with-param name="test-string" select="$step/node()[1]"/>
1105+
</xsl:call-template>
1106+
</xsl:otherwise>
1107+
</xsl:choose>
1108+
</xsl:when>
10751109
<xsl:when test="$step/text() and not($step/*)">
10761110
<xsl:choose>
10771111
<xsl:when test="$origin='hi'">
@@ -1352,9 +1386,9 @@
13521386
</xsl:template>
13531387

13541388
<xsl:template name="trans-string">
1355-
<!-- transforms context of <hi> into lowercase unaccented for rendering in app -->
1389+
<!-- transforms context of <hi> into lowercase unaccented for rendering in app -->
13561390
<xsl:param name="trans-text" select="."/>
1357-
<xsl:value-of select="translate($trans-text, $all-grc, $grc-lower-strip)"/>
1391+
<xsl:value-of select="translate($trans-text, $all-grc, $grc-lower-strip)"/>
13581392
</xsl:template>
13591393

13601394
<xsl:template name="childCertainty">
@@ -1367,7 +1401,7 @@
13671401
<xsl:template name="support">
13681402
<!-- called by template "hirend" above; decides whether text support is "ostrakon" or other (prob. = "papyrus") -->
13691403
<xsl:choose>
1370-
<xsl:when test="starts-with(//t:idno[@type='filename'],'o.')">
1404+
<xsl:when test="starts-with(ancestor::t:TEI//t:idno[@type='filename'],'o.')">
13711405
<xsl:text> ostrakon</xsl:text>
13721406
</xsl:when>
13731407
<xsl:otherwise>
@@ -1394,12 +1428,12 @@
13941428
</xsl:variable>
13951429
<xsl:variable name="no-l">
13961430
<xsl:choose>
1397-
<xsl:when test="$apptype = 'siccorr'"><xsl:value-of select="substring-before(replace($scribeswitch, 'l. ', 'for which correct to '), '(corr)')"
1431+
<xsl:when test="$apptype = 'siccorr'"><xsl:value-of select="substring-before(replace($scribeswitch, 'l\. ', 'for which correct to '), '(corr)')"
13981432
/></xsl:when>
1399-
<xsl:when test="$apptype = ('origreg', 'subst', 'appalt', 'apped')"><xsl:value-of select="replace($scribeswitch, 'l. ', 'for which read ')"/></xsl:when>
1400-
<xsl:when test="contains($scribeswitch, 'prev. ed.')"><xsl:value-of select="replace($scribeswitch, 'l. ', 'for which read ')"/></xsl:when>
1401-
<xsl:when test="$apptype = 'appbl'"><xsl:value-of select="replace($scribeswitch, 'l. ', 'normalises to ')"/></xsl:when>
1402-
<xsl:otherwise><xsl:value-of select="replace($scribeswitch, 'l. ', 'Scribe wrote ')"
1433+
<xsl:when test="$apptype = ('origreg', 'subst', 'appalt', 'apped')"><xsl:value-of select="replace($scribeswitch, 'l\. ', 'for which read ')"/></xsl:when>
1434+
<xsl:when test="contains($scribeswitch, 'prev. ed.')"><xsl:value-of select="replace($scribeswitch, 'l\. ', 'for which read ')"/></xsl:when>
1435+
<xsl:when test="$apptype = 'appbl'"><xsl:value-of select="replace($scribeswitch, 'l\. ', 'normalises to ')"/></xsl:when>
1436+
<xsl:otherwise><xsl:value-of select="replace($scribeswitch, 'l\. ', 'Scribe wrote ')"
14031437
/></xsl:otherwise>
14041438
</xsl:choose>
14051439
</xsl:variable>

txt-tpl-apparatus.xsl

+28-6
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,33 @@ Apparatus
2828
</xsl:call-template>
2929

3030
<!-- Found in tpl-apparatus.xsl -->
31-
<xsl:call-template name="ddbdp-app"/>
31+
<xsl:call-template name="ddbdp-app">
32+
<xsl:with-param name="apptype">
33+
<xsl:choose>
34+
<xsl:when test="self::t:choice[child::t:orig and child::t:reg]">
35+
<xsl:text>origreg</xsl:text>
36+
</xsl:when>
37+
<xsl:when test="self::t:choice[child::t:sic and child::t:corr]">
38+
<xsl:text>siccorr</xsl:text>
39+
</xsl:when>
40+
<xsl:when test="self::t:subst">
41+
<xsl:text>subst</xsl:text>
42+
</xsl:when>
43+
<xsl:when test="self::t:app[@type='alternative']">
44+
<xsl:text>appalt</xsl:text>
45+
</xsl:when>
46+
<xsl:when test="self::t:app[@type='editorial'][starts-with(t:lem/@resp,'BL ')]">
47+
<xsl:text>appbl</xsl:text>
48+
</xsl:when>
49+
<xsl:when test="self::t:app[@type='editorial'][starts-with(t:lem/@resp,'PN ')]">
50+
<xsl:text>apppn</xsl:text>
51+
</xsl:when>
52+
<xsl:when test="self::t:app[@type='editorial']">
53+
<xsl:text>apped</xsl:text>
54+
</xsl:when>
55+
</xsl:choose>
56+
</xsl:with-param>
57+
</xsl:call-template>
3258

3359
<!-- Only creates a new line if the following is not true -->
3460
<!--<xsl:if test="not(descendant::t:choice | descendant::t:subst | descendant::t:app)">
@@ -40,8 +66,7 @@ Apparatus
4066
<xsl:text>
4167
&#xD;
4268
&#xD;</xsl:text>
43-
</xsl:if>
44-
69+
</xsl:if>
4570
</xsl:template>
4671

4772

@@ -64,9 +89,6 @@ Apparatus
6489
<xsl:when test="$location = 'text'">
6590
<xsl:text>(*)</xsl:text>
6691
</xsl:when>
67-
<xsl:when test="$location = 'apparatus'">
68-
<xsl:text>^ </xsl:text>
69-
</xsl:when>
7092
</xsl:choose>
7193
</xsl:if>
7294
</xsl:template>

0 commit comments

Comments
 (0)