Debian Codegraph @

docbook-xsl-ns/fo/xep.xsl

raw symbols SCIP
1 <?xml version='1.0'?>
2 <xsl:stylesheet exclude-result-prefixes="d"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:d="http://docbook.org/ns/docbook"
5 xmlns:fo="http://www.w3.org/1999/XSL/Format"
6 xmlns:rx="http://www.renderx.com/XSL/Extensions"
7 version='1.0'>
8
9 <!-- ********************************************************************
10 (c) Stephane Bline Peregrine Systems 2001
11 Implementation of xep extensions:
12 * Pdf bookmarks (based on the XEP 2.5 implementation)
13 * Document information (XEP 2.5 meta information extensions)
14 ******************************************************************** -->
15
16 <!-- FIXME: Norm, I changed things so that the top-level element (book or set)
17 does not appear in the TOC. Is this the right thing? -->
18
19 <xsl:template name="xep-document-information">
20 <rx:meta-info>
21 <xsl:variable name="authors"
22 select="(//d:author|//d:editor|//d:corpauthor|//d:authorgroup)[1]"/>
23 <xsl:if test="$authors">
24 <xsl:variable name="author">
25 <xsl:choose>
26 <xsl:when test="$authors[self::d:authorgroup]">
27 <xsl:call-template name="person.name.list">
28 <xsl:with-param name="person.list"
29 select="$authors/*[self::d:author|self::d:corpauthor|
30 self::d:othercredit|self::d:editor]"/>
31 </xsl:call-template>
32 </xsl:when>
33 <xsl:when test="$authors[self::d:corpauthor]">
34 <xsl:value-of select="$authors"/>
35 </xsl:when>
36 <xsl:when test="$authors[d:orgname]">
37 <xsl:value-of select="$authors/d:orgname"/>
38 </xsl:when>
39 <xsl:otherwise>
40 <xsl:call-template name="person.name">
41 <xsl:with-param name="node" select="$authors"/>
42 </xsl:call-template>
43 </xsl:otherwise>
44 </xsl:choose>
45 </xsl:variable>
46 <xsl:element name="rx:meta-field">
47 <xsl:attribute name="name">author</xsl:attribute>
48 <xsl:attribute name="value">
49 <xsl:value-of select="normalize-space($author)"/>
50 </xsl:attribute>
51 </xsl:element>
52 </xsl:if>
53
54 <xsl:variable name="title">
55 <xsl:apply-templates select="/*[1]" mode="label.markup"/>
56 <xsl:apply-templates select="/*[1]" mode="title.markup"/>
57 </xsl:variable>
58
59 <xsl:element name="rx:meta-field">
60 <xsl:attribute name="name">creator</xsl:attribute>
61 <xsl:attribute name="value">
62 <xsl:text>DocBook </xsl:text>
63 <xsl:value-of select="$DistroTitle"/>
64 <xsl:text> V</xsl:text>
65 <xsl:value-of select="$VERSION"/>
66 </xsl:attribute>
67 </xsl:element>
68
69 <xsl:element name="rx:meta-field">
70 <xsl:attribute name="name">title</xsl:attribute>
71 <xsl:attribute name="value">
72 <xsl:value-of select="normalize-space($title)"/>
73 </xsl:attribute>
74 </xsl:element>
75
76 <xsl:if test="//d:keyword">
77 <xsl:element name="rx:meta-field">
78 <xsl:attribute name="name">keywords</xsl:attribute>
79 <xsl:attribute name="value">
80 <xsl:for-each select="//d:keyword">
81 <xsl:value-of select="normalize-space(.)"/>
82 <xsl:if test="position() != last()">
83 <xsl:text>, </xsl:text>
84 </xsl:if>
85 </xsl:for-each>
86 </xsl:attribute>
87 </xsl:element>
88 </xsl:if>
89
90 <xsl:if test="//d:subjectterm">
91 <xsl:element name="rx:meta-field">
92 <xsl:attribute name="name">subject</xsl:attribute>
93 <xsl:attribute name="value">
94 <xsl:for-each select="//d:subjectterm">
95 <xsl:value-of select="normalize-space(.)"/>
96 <xsl:if test="position() != last()">
97 <xsl:text>, </xsl:text>
98 </xsl:if>
99 </xsl:for-each>
100 </xsl:attribute>
101 </xsl:element>
102 </xsl:if>
103 </rx:meta-info>
104 </xsl:template>
105
106 <!-- ********************************************************************
107 Pdf bookmarks
108 ******************************************************************** -->
109
110 <xsl:template match="*" mode="xep.outline">
111 <xsl:apply-templates select="*" mode="xep.outline"/>
112 </xsl:template>
113
114 <xsl:template match="d:set|d:book|d:part|d:reference|d:preface|d:chapter|d:appendix|d:article
115 |d:glossary|d:bibliography|d:index|d:setindex|d:topic
116 |d:refentry|d:refsynopsisdiv
117 |d:refsect1|d:refsect2|d:refsect3|d:refsection
118 |d:sect1|d:sect2|d:sect3|d:sect4|d:sect5|d:section"
119 mode="xep.outline">
120 <xsl:variable name="id">
121 <xsl:call-template name="object.id"/>
122 </xsl:variable>
123 <xsl:variable name="bookmark-label">
124 <xsl:apply-templates select="." mode="object.title.markup"/>
125 </xsl:variable>
126
127 <!-- Put the root element bookmark at the same level as its children -->
128 <!-- If the object is a set or book, generate a bookmark for the toc -->
129 <xsl:choose>
130 <xsl:when test="self::d:index and $generate.index = 0"/>
131 <xsl:when test="parent::*">
132 <rx:bookmark internal-destination="{$id}">
133 <xsl:attribute name="starting-state">
134 <xsl:value-of select="$bookmarks.state"/>
135 </xsl:attribute>
136 <rx:bookmark-label>
137 <xsl:value-of select="normalize-space($bookmark-label)"/>
138 </rx:bookmark-label>
139 <xsl:apply-templates select="*" mode="xep.outline"/>
140 </rx:bookmark>
141 </xsl:when>
142 <xsl:otherwise>
143 <xsl:if test="$bookmark-label != ''">
144 <rx:bookmark internal-destination="{$id}">
145 <xsl:attribute name="starting-state">
146 <xsl:value-of select="$bookmarks.state"/>
147 </xsl:attribute>
148 <rx:bookmark-label>
149 <xsl:value-of select="normalize-space($bookmark-label)"/>
150 </rx:bookmark-label>
151 </rx:bookmark>
152 </xsl:if>
153
154 <xsl:variable name="toc.params">
155 <xsl:call-template name="find.path.params">
156 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
157 </xsl:call-template>
158 </xsl:variable>
159 <xsl:if test="contains($toc.params, 'toc')
160 and d:set|d:book|d:part|d:reference|d:section|d:sect1|d:refentry
161 |d:article|d:topic|d:bibliography|d:glossary|d:chapter
162 |d:appendix">
163 <rx:bookmark internal-destination="toc...{$id}">
164 <rx:bookmark-label>
165 <xsl:call-template name="gentext">
166 <xsl:with-param name="key" select="'TableofContents'"/>
167 </xsl:call-template>
168 </rx:bookmark-label>
169 </rx:bookmark>
170 </xsl:if>
171 <xsl:apply-templates select="*" mode="xep.outline"/>
172 </xsl:otherwise>
173 </xsl:choose>
174 </xsl:template>
175
176 <xsl:template name="xep-pis">
177 <xsl:if test="$crop.marks != 0">
178 <xsl:processing-instruction name="xep-pdf-crop-mark-width"><xsl:value-of select="$crop.mark.width"/></xsl:processing-instruction>
179 <xsl:processing-instruction name="xep-pdf-crop-offset"><xsl:value-of select="$crop.mark.offset"/></xsl:processing-instruction>
180 <xsl:processing-instruction name="xep-pdf-bleed"><xsl:value-of select="$crop.mark.bleed"/></xsl:processing-instruction>
181 </xsl:if>
182
183 <xsl:call-template name="user-xep-pis"/>
184 </xsl:template>
185
186 <!-- Placeholder for user defined PIs -->
187 <xsl:template name="user-xep-pis"/>
188
189 </xsl:stylesheet>