source: BOOK/stylesheets/lfs-xsl/xhtml/lfs-xref.xsl@ 6bb9a5e

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 6bb9a5e was f8c4e94, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Added LFS XSL Stylesheets.

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