Debian Codegraph @

xsl/cover.xsl

raw
1 <?xml version='1.0'?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:exsl="http://exslt.org/common"
4 exclude-result-prefixes="exsl" version='1.0'>
5
6 <!--############################################################################
7 XSLT Stylesheet DocBook -> LaTeX
8 ############################################################################ -->
9
10 <!-- Default cover handler: put a specified image on a new physical page.
11 The first <cover> is assumed to be for the front page, the second one is
12 for the back page.
13
14 The implementation tries to match the DocBook 4 method that uses
15 <mediaobject>s with role='cover' to represent a cover, but it ignores those
16 elements if <cover> elements are found.
17 -->
18
19 <xsl:template name="front.cover">
20 <xsl:param name="info" select="/*/*[contains(name(.), 'info')]"/>
21 <xsl:call-template name="make.cover">
22 <xsl:with-param name="idx" select="1"/>
23 <xsl:with-param name="info" select="$info"/>
24 </xsl:call-template>
25 </xsl:template>
26
27 <xsl:template name="back.cover">
28 <xsl:param name="info" select="/*/*[contains(name(.), 'info')]"/>
29 <xsl:call-template name="make.cover">
30 <xsl:with-param name="idx" select="2"/>
31 <xsl:with-param name="info" select="$info"/>
32 </xsl:call-template>
33 </xsl:template>
34
35 <xsl:template name="make.cover">
36 <xsl:param name="idx" select="1"/>
37 <xsl:param name="info"/>
38
39 <xsl:variable name="covers" select="$info/cover"/>
40 <xsl:variable name="medias" select="$info//mediaobject[@role='cover']"/>
41
42 <xsl:choose>
43 <xsl:when test="count($covers) &gt;= $idx">
44 <xsl:apply-templates select="$covers[$idx]/mediaobject" mode="cover"/>
45 </xsl:when>
46 <xsl:when test="count($medias) &gt;= $idx">
47 <xsl:apply-templates select="$medias[$idx]" mode="cover"/>
48 </xsl:when>
49 </xsl:choose>
50 </xsl:template>
51
52 <xsl:template match="mediaobject" mode="cover">
53 <xsl:variable name="idx">
54 <xsl:call-template name="mediaobject.select.idx">
55 <xsl:with-param name="role" select="'front-large'"/>
56 </xsl:call-template>
57 </xsl:variable>
58
59 <xsl:variable name="img" select="imageobject[position()=$idx]"/>
60
61 <xsl:text>\putoncover{</xsl:text>
62 <xsl:apply-templates select="$img/imagedata" mode="cover"/>
63 <xsl:text>}&#10;</xsl:text>
64 </xsl:template>
65
66 <xsl:template match="imagedata" mode="cover">
67 <xsl:call-template name="imagedata">
68 <xsl:with-param name="layout.width" select="'\paperwidth'"/>
69 <xsl:with-param name="layout.height" select="'\paperheight'"/>
70 </xsl:call-template>
71 </xsl:template>
72
73 </xsl:stylesheet>