source: stylesheets/lfs-xsl/pdf/lfs-xref.xsl@ ccded7e

11.0 11.1 11.2 11.3 12.0 12.1 kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts lazarus lxqt plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition trunk upgradedb xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since ccded7e was ccded7e, checked in by Xi Ruoyao <xry111@…>, 3 years ago

clean up unused SVN prop entries

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