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

trunk
Last change on this file was 74111fc7, checked in by Pierre Labastie <pierre.labastie@…>, 3 months ago

Remove any reference to xlink namespace

In lfs-xref.xsl in both pdf and xhtml.
Also change encoding to utf-8.

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