source: stylesheets/lfs-xsl/xhtml/lfs-xref.xsl@ 52dcb7d

11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 52dcb7d was 52dcb7d, checked in by Xℹ Ruoyao <xry111@…>, 3 years ago

remove $Date$ and $LastChangedBy$

They are unsupported by Git.

  • Property mode set to 100644
File size: 5.5 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="http://www.w3.org/1999/xhtml"
6 exclude-result-prefixes="xlink"
7 version="1.0">
8
9 <!-- This stylesheet fixes English punctuation in xref links
10 (as was requested by the publisher) via adding @role propagation
11 in xref tags.
12 This hack may not work with xref flavours not used in the book.
13 For other languages, just remove the xref @role attributes
14 in the book XML sources and/or comment-out the inclusion of
15 this file in lfs-chunked2.xsl -->
16
17 <!-- xref:
18 Added role variable and use it when calling mode xref-to.-->
19 <!-- The original template is in {docbook-xsl}/xhtml/xref.xsl -->
20 <xsl:template match="xref" name="xref">
21 <xsl:param name="xhref" select="@xlink:href"/>
22 <!-- is the @xlink:href a local idref link? -->
23 <xsl:param name="xlink.idref">
24 <xsl:if test="starts-with($xhref,'#') and (not(contains($xhref,'('))
25 or starts-with($xhref, '#xpointer(id('))">
26 <xsl:call-template name="xpointer.idref">
27 <xsl:with-param name="xpointer" select="$xhref"/>
28 </xsl:call-template>
29 </xsl:if>
30 </xsl:param>
31 <xsl:param name="xlink.targets" select="key('id',$xlink.idref)"/>
32 <xsl:param name="linkend.targets" select="key('id',@linkend)"/>
33 <xsl:param name="target" select="($xlink.targets | $linkend.targets)[1]"/>
34 <!-- Added role variable -->
35 <xsl:variable name="role" select="@role"/>
36 <xsl:variable name="xrefstyle">
37 <xsl:choose>
38 <xsl:when test="@role and not(@xrefstyle) and $use.role.as.xrefstyle != 0">
39 <xsl:value-of select="@role"/>
40 </xsl:when>
41 <xsl:otherwise>
42 <xsl:value-of select="@xrefstyle"/>
43 </xsl:otherwise>
44 </xsl:choose>
45 </xsl:variable>
46 <xsl:call-template name="anchor"/>
47 <xsl:variable name="content">
48 <xsl:choose>
49 <xsl:when test="@endterm">
50 <xsl:variable name="etargets" select="key('id',@endterm)"/>
51 <xsl:variable name="etarget" select="$etargets[1]"/>
52 <xsl:choose>
53 <xsl:when test="count($etarget) = 0">
54 <xsl:message>
55 <xsl:value-of select="count($etargets)"/>
56 <xsl:text>Endterm points to nonexistent ID: </xsl:text>
57 <xsl:value-of select="@endterm"/>
58 </xsl:message>
59 <xsl:text>???</xsl:text>
60 </xsl:when>
61 <xsl:otherwise>
62 <xsl:apply-templates select="$etarget" mode="endterm"/>
63 </xsl:otherwise>
64 </xsl:choose>
65 </xsl:when>
66 <xsl:when test="$target/@xreflabel">
67 <xsl:call-template name="xref.xreflabel">
68 <xsl:with-param name="target" select="$target"/>
69 </xsl:call-template>
70 </xsl:when>
71 <xsl:when test="$target">
72 <xsl:if test="not(parent::citation)">
73 <xsl:apply-templates select="$target" mode="xref-to-prefix"/>
74 </xsl:if>
75 <xsl:apply-templates select="$target" mode="xref-to">
76 <xsl:with-param name="referrer" select="."/>
77 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
78 <!-- Propagate role -->
79 <xsl:with-param name="role" select="$role"/>
80 </xsl:apply-templates>
81 <xsl:if test="not(parent::citation)">
82 <xsl:apply-templates select="$target" mode="xref-to-suffix"/>
83 </xsl:if>
84 </xsl:when>
85 <xsl:otherwise>
86 <xsl:message>
87 <xsl:text>ERROR: xref linking to </xsl:text>
88 <xsl:value-of select="@linkend|@xlink:href"/>
89 <xsl:text> has no generated link text.</xsl:text>
90 </xsl:message>
91 <xsl:text>???</xsl:text>
92 </xsl:otherwise>
93 </xsl:choose>
94 </xsl:variable>
95 <xsl:call-template name="simple.xlink">
96 <xsl:with-param name="content" select="$content"/>
97 </xsl:call-template>
98 </xsl:template>
99
100 <!-- sect* mode xref-to:
101 Propagate role to mode object.xref.markup (see ../lfs-common.xsl) -->
102 <!-- The original template is in {docbook-xsl}/xhtml/xref.xsl -->
103 <xsl:template match="section|simplesect|sect1|sect2|sect3|sect4|sect5|refsect1
104 |refsect2|refsect3|refsection" mode="xref-to">
105 <xsl:param name="referrer"/>
106 <xsl:param name="xrefstyle"/>
107 <xsl:param name="verbose" select="1"/>
108 <xsl:param name="role"/>
109 <xsl:apply-templates select="." mode="object.xref.markup">
110 <xsl:with-param name="purpose" select="'xref'"/>
111 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
112 <xsl:with-param name="referrer" select="$referrer"/>
113 <xsl:with-param name="verbose" select="$verbose"/>
114 <xsl:with-param name="role" select="$role"/>
115 </xsl:apply-templates>
116 </xsl:template>
117
118 <!-- insert.title.markup:
119 Apply the role value. -->
120 <!-- The original template is in {docbook-xsl}/xhtml/xref.xsl -->
121 <xsl:template match="*" mode="insert.title.markup">
122 <xsl:param name="purpose"/>
123 <xsl:param name="xrefstyle"/>
124 <xsl:param name="title"/>
125 <xsl:param name="role"/>
126 <xsl:choose>
127 <xsl:when test="$purpose = 'xref' and titleabbrev">
128 <xsl:apply-templates select="." mode="titleabbrev.markup"/>
129 </xsl:when>
130 <xsl:otherwise>
131 <xsl:copy-of select="$title"/>
132 <xsl:value-of select="$role"/>
133 </xsl:otherwise>
134 </xsl:choose>
135 </xsl:template>
136
137</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.