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