Whamcloud - gitweb
LUDOC-114 lnet: LNET/LND credits and flow control
[doc/manual.git] / style / customstyle_fo.xsl
1 <?xml version='1.0'?>
2 <xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3         xmlns:fo="http://www.w3.org/1999/XSL/Format"
4         xmlns:d="http://docbook.org/ns/docbook"
5         exclude-result-prefixes="d"
6         version="1.0" >
7 <!-- xsl:import takes place at compile time. For this reason, I sed in the correct
8      primary xsl pdf, and then run xsltproc -->
9 <xsl:import href="PRIMARYXSL"/>
10 <xsl:output method='xml'/>
11
12 <xsl:param name="fop1.extensions" select="1"></xsl:param>
13 <xsl:param name="chapter.autolabel" select="1"></xsl:param>
14 <xsl:param name="section.autolabel" select="1"></xsl:param>
15 <xsl:param name="appendix.autolabel" select="1"></xsl:param>
16 <xsl:param name="autotoc.label.in.hyperlink" select="1"></xsl:param>
17 <xsl:param name="section.label.includes.component.label" select="1"></xsl:param>
18
19 <!--  textdecoration_1 applies the style to the text to highlight an region
20                 of the documentation refers to a lustre specific version.
21
22                 template_{1,2,3} all use the 'condition="{l23,l24}" attributes and add
23                 decoration to the rendered version of the manual to show lustre version
24                 specific features. -->
25
26 <!-- textdecoration_1: a template to highlight regions of text. -->
27 <xsl:template name='textdecoration_1'>
28         <xsl:param name='version'/>
29         <xsl:param name='chunkid'/>
30         <fo:block-container id="{$chunkid}"
31                         padding='5pt'
32                         border-color='gray'
33                         border-style='solid'
34                         border-width='1pt'>
35                 <fo:block-container float='left' text-indent='3px' start-indent='-20px'>
36                         <fo:block background-color="gray">
37                                 <xsl:value-of select='$version'/>
38                         </fo:block>
39                 </fo:block-container>
40                 <fo:block text-indent='0px' start-indent='0px'>
41                         <xsl:apply-templates/>
42                 </fo:block>
43         </fo:block-container>
44 </xsl:template>
45
46 <!-- conditional matching template: this calls text decoration
47           template with the correct variables. -->
48 <xsl:template match="*[@condition]">
49     <xsl:variable name="id">
50         <xsl:call-template name="object.id"/>
51     </xsl:variable>
52     <xsl:call-template name='section.titlepage'/>
53     <xsl:choose>
54         <xsl:when test="@condition = 'l21'">
55             <xsl:call-template name='textdecoration_1'>
56                 <xsl:with-param name='version' select="'introduced in Lustre 2.1'"/>
57                 <xsl:with-param name='chunkid' select="$id"/>
58             </xsl:call-template>
59         </xsl:when>
60         <xsl:when test="@condition = 'l22'">
61             <xsl:call-template name='textdecoration_1'>
62                 <xsl:with-param name='version' select="'introduced in Lustre 2.2'"/>
63                 <xsl:with-param name='chunkid' select="$id"/>
64             </xsl:call-template>
65         </xsl:when>
66         <xsl:when test="@condition = 'l23'">
67             <xsl:call-template name='textdecoration_1'>
68                 <xsl:with-param name='version' select="'introduced in Lustre 2.3'"/>
69                 <xsl:with-param name='chunkid' select="$id"/>
70             </xsl:call-template>
71         </xsl:when>
72         <xsl:when test="@condition = 'l24'">
73             <xsl:call-template name='textdecoration_1'>
74                 <xsl:with-param name='version' select="'introduced in Lustre 2.4'"/>
75                 <xsl:with-param name='chunkid' select="$id"/>
76             </xsl:call-template>
77         </xsl:when>
78         <xsl:when test="@condition = 'l25'">
79             <xsl:call-template name='textdecoration_1'>
80                 <xsl:with-param name='version' select="'introduced in Lustre 2.5'"/>
81                 <xsl:with-param name='chunkid' select="$id"/>
82             </xsl:call-template>
83         </xsl:when>
84         <xsl:otherwise>
85             <xsl:call-template name='textdecoration_1'>
86                 <xsl:with-param name='version' select="'unrecognised Lustre version'"/>
87                 <xsl:with-param name='chunkid' select="$id"/>
88             </xsl:call-template>
89         </xsl:otherwise>
90     </xsl:choose>
91 </xsl:template>
92
93 <!-- toc.line template: This template over loads the behavior of creating the table of contents. It
94                 adds in a small entry to identify lustre version specific features.
95                 for more information, see this page:
96                 http://xml.web.cern.ch/XML/www.sagehill.net/xml/docbookxsl/PrintCustomEx.html#PrintTocEntries -->
97 <xsl:template name="toc.line">
98         <xsl:variable name="id">
99                 <xsl:call-template name="object.id"/>
100         </xsl:variable>
101         <xsl:variable name="lustrecond">
102                 <xsl:choose>
103                         <xsl:when test="@condition='l21'">L 2.1</xsl:when>
104                         <xsl:when test="@condition='l22'">L 2.2</xsl:when>
105                         <xsl:when test="@condition='l23'">L 2.3</xsl:when>
106                         <xsl:when test="@condition='l24'">L 2.4</xsl:when>
107                         <xsl:when test="@condition='l25'">L 2.5</xsl:when>
108                         <xsl:otherwise></xsl:otherwise>
109                 </xsl:choose>
110         </xsl:variable>
111
112         <xsl:variable name="label">
113                 <xsl:apply-templates select="." mode="label.markup"/>
114         </xsl:variable>
115         <fo:block text-align-last="justify"
116                         end-indent="{$toc.indent.width}pt"
117                         last-line-end-indent="-{$toc.indent.width}pt">
118                 <fo:inline keep-with-next.within-line="always">
119                         <xsl:choose>
120                                 <xsl:when test="local-name(.) = 'chapter'">
121                                         <xsl:attribute name="font-weight">bold</xsl:attribute>
122                                 </xsl:when>
123                         </xsl:choose>
124                         <fo:basic-link internal-destination="{$id}">
125                                 <xsl:if test="$label != ''">
126                                         <xsl:copy-of select="$label"/>
127                                         <xsl:value-of select="$autotoc.label.separator"/>
128                                 </xsl:if>
129                                 <xsl:apply-templates select="." mode="title.markup"/>
130                         </fo:basic-link>
131                 </fo:inline>
132                 <fo:inline keep-together.within-line="always">
133                         <xsl:text> </xsl:text>
134                         <fo:leader leader-pattern="dots"
135                                         leader-pattern-width="3pt"
136                                         leader-alignment="reference-area"
137                                         keep-with-next.within-line="always"/>
138                         <xsl:text>  </xsl:text>
139                         <xsl:value-of select='$lustrecond'/>
140                         <xsl:text>  </xsl:text>
141                         <fo:basic-link internal-destination="{$id}">
142                                 <fo:page-number-citation ref-id="{$id}"/>
143                         </fo:basic-link>
144                 </fo:inline>
145         </fo:block>
146 </xsl:template>
147
148 </xsl:stylesheet>