1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
<?xml version='1.0' encoding='ISO-8859-1'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
exclude-result-prefixes="xlink"
version="1.0">
<!-- This stylesheet fixes English punctuation in xref links
(as was requested by the publisher) via adding @role propagation
in xref tags.
This hack may not work with xref flavours not used in the book.
For other languages, just remove the xref @role attributes
in the book XML sources and/or comment-out the inclusion of
this file in lfs-pdf.xsl -->
<!-- xref:
Added role variable and use it when calling mode xref-to.-->
<!-- The original template is in {docbook-xsl}/fo/xref.xsl -->
<xsl:template match="xref" name="xref">
<xsl:param name="xhref" select="@xlink:href"/>
<!-- is the @xlink:href a local idref link? -->
<xsl:param name="xlink.idref">
<xsl:if test="starts-with($xhref,'#')
and (not(contains($xhref,'('))
or starts-with($xhref, '#xpointer(id('))">
<xsl:call-template name="xpointer.idref">
<xsl:with-param name="xpointer" select="$xhref"/>
</xsl:call-template>
</xsl:if>
</xsl:param>
<xsl:param name="xlink.targets" select="key('id',$xlink.idref)"/>
<xsl:param name="linkend.targets" select="key('id',@linkend)"/>
<xsl:param name="target" select="($xlink.targets | $linkend.targets)[1]"/>
<xsl:param name="refelem" select="local-name($target)"/>
<!-- Added role variable -->
<xsl:variable name="role" select="@role"/>
<xsl:variable name="xrefstyle">
<xsl:choose>
<xsl:when test="@role and not(@xrefstyle)
and $use.role.as.xrefstyle != 0">
<xsl:value-of select="@role"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@xrefstyle"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="content">
<fo:inline xsl:use-attribute-sets="xref.properties">
<xsl:choose>
<xsl:when test="@endterm">
<xsl:variable name="etargets" select="key('id',@endterm)"/>
<xsl:variable name="etarget" select="$etargets[1]"/>
<xsl:choose>
<xsl:when test="count($etarget) = 0">
<xsl:message>
<xsl:value-of select="count($etargets)"/>
<xsl:text>Endterm points to nonexistent ID: </xsl:text>
<xsl:value-of select="@endterm"/>
</xsl:message>
<xsl:text>???</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="$etarget" mode="endterm"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$target/@xreflabel">
<xsl:call-template name="xref.xreflabel">
<xsl:with-param name="target" select="$target"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$target">
<xsl:if test="not(parent::citation)">
<xsl:apply-templates select="$target" mode="xref-to-prefix"/>
</xsl:if>
<xsl:apply-templates select="$target" mode="xref-to">
<xsl:with-param name="referrer" select="."/>
<xsl:with-param name="xrefstyle" select="$xrefstyle"/>
<!-- Propagate role -->
<xsl:with-param name="role" select="$role"/>
</xsl:apply-templates>
<xsl:if test="not(parent::citation)">
<xsl:apply-templates select="$target" mode="xref-to-suffix"/>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:message>
<xsl:text>ERROR: xref linking to </xsl:text>
<xsl:value-of select="@linkend|@xlink:href"/>
<xsl:text> has no generated link text.</xsl:text>
</xsl:message>
<xsl:text>???</xsl:text>
</xsl:otherwise>
</xsl:choose>
</fo:inline>
</xsl:variable>
<!-- Convert it into an active link -->
<xsl:call-template name="simple.xlink">
<xsl:with-param name="content" select="$content"/>
</xsl:call-template>
<!-- Add standard page reference? -->
<xsl:choose>
<xsl:when test="not($target)">
<!-- page numbers only for local targets -->
</xsl:when>
<xsl:when test="starts-with(normalize-space($xrefstyle), 'select:')
and contains($xrefstyle, 'nopage')">
<!-- negative xrefstyle in instance turns it off -->
</xsl:when>
<!-- positive xrefstyle already handles it -->
<xsl:when test="not(starts-with(normalize-space($xrefstyle), 'select:')
and (contains($xrefstyle, 'page')
or contains($xrefstyle, 'Page')))
and ( $insert.xref.page.number = 'yes'
or $insert.xref.page.number = '1')
or local-name($target) = 'para'">
<xsl:apply-templates select="$target" mode="page.citation">
<xsl:with-param name="id" select="$target/@id|$target/@xml:id"/>
</xsl:apply-templates>
</xsl:when>
</xsl:choose>
</xsl:template>
<!-- sect* mode xref-to:
Propagate role to mode object.xref.markup (see ../lfs-common.xsl) -->
<!-- The original template is in {docbook-xsl}/fo/xref.xsl -->
<xsl:template match="section|simplesect|sect1|sect2|sect3|sect4|sect5
|refsect1|refsect2|refsect3|refsection" mode="xref-to">
<xsl:param name="referrer"/>
<xsl:param name="xrefstyle"/>
<xsl:param name="verbose" select="1"/>
<xsl:param name="role"/>
<xsl:apply-templates select="." mode="object.xref.markup">
<xsl:with-param name="purpose" select="'xref'"/>
<xsl:with-param name="xrefstyle" select="$xrefstyle"/>
<xsl:with-param name="referrer" select="$referrer"/>
<xsl:with-param name="verbose" select="$verbose"/>
<xsl:with-param name="role" select="$role"/>
</xsl:apply-templates>
</xsl:template>
<!-- insert.title.markup:
Apply the role value. -->
<!-- The original template is in {docbook-xsl}/fo/xref.xsl -->
<xsl:template match="*" mode="insert.title.markup">
<xsl:param name="purpose"/>
<xsl:param name="xrefstyle"/>
<xsl:param name="title"/>
<xsl:param name="role"/>
<xsl:choose>
<xsl:when test="$purpose = 'xref' and titleabbrev">
<xsl:apply-templates select="." mode="titleabbrev.markup"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$title"/>
<xsl:value-of select="$role"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
|