Debian Codegraph @

xsl/set.xsl

raw
1 <?xml version='1.0'?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
3
4 <!--############################################################################
5 XSLT Stylesheet DocBook -> LaTeX
6 ############################################################################ -->
7
8 <xsl:param name="set.book.num">1</xsl:param>
9
10
11 <!-- ################
12 # Set of books #
13 ################ -->
14
15 <!-- Handle all the books or a single book -->
16 <xsl:template match="set">
17 <xsl:choose>
18 <xsl:when test="$set.book.num = 'all'">
19 <xsl:if test="$output.quietly = 0">
20 <xsl:message>Output all the books from the set</xsl:message>
21 </xsl:if>
22 <!-- Write a latex file per book -->
23 <xsl:apply-templates select="//book" mode="build.texfile"/>
24 </xsl:when>
25 <xsl:otherwise>
26 <xsl:message>
27 <xsl:text>Warning: only print the book [</xsl:text>
28 <xsl:value-of select="$set.book.num"/>
29 <xsl:text>]</xsl:text>
30 </xsl:message>
31 <xsl:apply-templates select="//book[position()=$set.book.num]"/>
32 </xsl:otherwise>
33 </xsl:choose>
34 </xsl:template>
35
36 <!-- Chunk a tex file per book -->
37 <xsl:template match="book" mode="build.texfile">
38 <xsl:call-template name="write.text.chunk">
39 <xsl:with-param name="filename">
40 <xsl:call-template name="bookname"/>
41 <xsl:text>.rtex</xsl:text>
42 </xsl:with-param>
43 <xsl:with-param name="method" select="'text'"/>
44 <xsl:with-param name="content">
45 <xsl:apply-templates select="."/>
46 </xsl:with-param>
47 </xsl:call-template>
48 </xsl:template>
49
50
51 <!-- Print out the book filename formatted according to <template> -->
52 <xsl:template match="book" mode="bookname" name="bookname">
53 <xsl:param name="template" select="'%b'"/>
54 <xsl:param name="exclude-gid"/>
55
56 <xsl:variable name="local-gid">
57 <xsl:apply-templates select="." mode="booknumber"/>
58 </xsl:variable>
59
60 <xsl:if test="$local-gid != $exclude-gid">
61 <xsl:variable name="basename">
62 <xsl:choose>
63 <xsl:when test="(not(@id) and not(@xml:id)) or $use.id.as.filename = 0">
64 <xsl:value-of select="concat('book', $local-gid)"/>
65 </xsl:when>
66 <xsl:otherwise>
67 <xsl:value-of select="(@id|@xml:id)[1]"/>
68 </xsl:otherwise>
69 </xsl:choose>
70 </xsl:variable>
71
72 <xsl:call-template name="string-replace">
73 <xsl:with-param name="string" select="$template"/>
74 <xsl:with-param name="from" select="'%b'"/>
75 <xsl:with-param name="to" select="$basename"/>
76 </xsl:call-template>
77 </xsl:if>
78 </xsl:template>
79
80
81 <!-- Give the list of the external documents that xr-hyper must know.
82 This template must be called in the latex book preamble.
83 -->
84 <xsl:template name="make.external.docs">
85 <!-- The list must contain only external books, not the current one -->
86 <xsl:variable name="local-gid">
87 <xsl:apply-templates select="." mode="booknumber"/>
88 </xsl:variable>
89
90 <!-- The list is meaningful only if several books are printed out -->
91 <xsl:if test="$set.book.num = 'all'">
92 <xsl:apply-templates select="//book[parent::set]" mode="bookname">
93 <xsl:with-param name="template"
94 select="'\externaldocument{%b}[%b]&#10;'"/>
95 <xsl:with-param name="exclude-gid" select="$local-gid"/>
96 </xsl:apply-templates>
97 </xsl:if>
98 </xsl:template>
99
100
101 <xsl:template match="set/setinfo"></xsl:template>
102 <xsl:template match="set/title"></xsl:template>
103 <xsl:template match="set/subtitle"></xsl:template>
104
105
106 <!-- Book numbering -->
107 <xsl:template match="book" mode="booknumber">
108 <xsl:number from="/"
109 level="any"
110 format="1"/>
111 </xsl:template>
112
113 </xsl:stylesheet>