Whamcloud - gitweb
32b51040051491dfb2640b917b95a7034d3e74e0
[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
47 <!-- mychapter definition This has been copied from xsl-ns-stylesheets/fo/component.xsl 
48         and modified to provide highlight regions of text for an entire chapter. 
49         This is consistent with the high-lighting provided by textdecoration_1 !-->
50 <xsl:template name="mychapter">
51         <xsl:param name='version'/>
52         <xsl:param name='chunkid'/>
53   <xsl:variable name="id">
54     <xsl:call-template name="object.id"/>
55   </xsl:variable>
56
57   <xsl:variable name="master-reference">
58     <xsl:call-template name="select.pagemaster"/>
59   </xsl:variable>
60
61   <fo:page-sequence hyphenate="{$hyphenate}"
62                     master-reference="{$master-reference}">
63     <xsl:attribute name="language">
64       <xsl:call-template name="l10n.language"/>
65     </xsl:attribute>
66     <xsl:attribute name="format">
67       <xsl:call-template name="page.number.format">
68         <xsl:with-param name="master-reference" select="$master-reference"/>
69       </xsl:call-template>
70     </xsl:attribute>
71     <xsl:attribute name="initial-page-number">
72       <xsl:call-template name="initial.page.number">
73         <xsl:with-param name="master-reference" select="$master-reference"/>
74       </xsl:call-template>
75     </xsl:attribute>
76
77     <xsl:attribute name="force-page-count">
78       <xsl:call-template name="force.page.count">
79         <xsl:with-param name="master-reference" select="$master-reference"/>
80       </xsl:call-template>
81     </xsl:attribute>
82
83     <xsl:attribute name="hyphenation-character">
84       <xsl:call-template name="gentext">
85         <xsl:with-param name="key" select="'hyphenation-character'"/>
86       </xsl:call-template>
87     </xsl:attribute>
88     <xsl:attribute name="hyphenation-push-character-count">
89       <xsl:call-template name="gentext">
90         <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
91       </xsl:call-template>
92     </xsl:attribute>
93     <xsl:attribute name="hyphenation-remain-character-count">
94       <xsl:call-template name="gentext">
95         <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
96       </xsl:call-template>
97     </xsl:attribute>
98
99     <xsl:apply-templates select="." mode="running.head.mode">
100       <xsl:with-param name="master-reference" select="$master-reference"/>
101     </xsl:apply-templates>
102
103     <xsl:apply-templates select="." mode="running.foot.mode">
104       <xsl:with-param name="master-reference" select="$master-reference"/>
105     </xsl:apply-templates>
106
107     <fo:flow flow-name="xsl-region-body">
108       <xsl:call-template name="set.flow.properties">
109         <xsl:with-param name="element" select="local-name(.)"/>
110         <xsl:with-param name="master-reference" select="$master-reference"/>
111       </xsl:call-template>
112
113         <fo:block-container id='chapterdecoration-{$chunkid}'
114                         padding='5pt'
115                         border-color='gray'
116                         border-style='solid'
117                         border-width='1pt'>
118                         <fo:block-container float='left' text-indent='3px' start-indent='-20px'>
119                                 <fo:block background-color="gray">
120                                         <xsl:value-of select='$version'/>
121                                 </fo:block>
122                         </fo:block-container>
123                   <fo:block id="{$id}"
124                                         xsl:use-attribute-sets="component.titlepage.properties">
125                         <xsl:call-template name="chapter.titlepage"/>
126                   </fo:block>
127
128                   <!-- RHEL and SLES versions have an older docbook xsl install
129                        that fails on this call: 
130                            xsl:call-template name="make.component.tocs"/-->
131
132                   <xsl:apply-templates/>
133       </fo:block-container>
134     </fo:flow>
135   </fo:page-sequence>
136 </xsl:template>
137
138
139 <!-- conditional matching template: this calls text decoration
140           template with the correct variables. -->
141 <xsl:template match="*[@condition]">
142     <xsl:variable name="id">
143         <xsl:call-template name="object.id"/>
144     </xsl:variable>
145         <xsl:variable name="versionstr">
146                 <xsl:choose>
147                         <xsl:when test="@condition = 'l21'">Introduced in Lustre 2.1</xsl:when>
148                         <xsl:when test="@condition = 'l22'">Introduced in Lustre 2.2</xsl:when>
149                         <xsl:when test="@condition = 'l23'">Introduced in Lustre 2.3</xsl:when>
150                         <xsl:when test="@condition = 'l24'">Introduced in Lustre 2.4</xsl:when>
151                         <xsl:when test="@condition = 'l25'">Introduced in Lustre 2.5</xsl:when>
152                         <xsl:when test="@condition = 'l26'">Introduced in Lustre 2.6</xsl:when>
153                         <xsl:when test="@condition = 'l27'">Introduced in Lustre 2.7</xsl:when>
154                         <xsl:when test="@condition = 'l28'">Introduced in Lustre 2.8</xsl:when>
155                         <xsl:when test="@condition = 'l29'">Introduced in Lustre 2.9</xsl:when>
156                         <xsl:otherwise>Documentation Error: unrecognised condition attribute</xsl:otherwise>
157                 </xsl:choose>
158         </xsl:variable>
159     <xsl:choose>
160         <xsl:when test="name(..) = 'part'">
161                 <xsl:call-template name='mychapter'>
162                 <xsl:with-param name='version' select="$versionstr"/>
163                 <xsl:with-param name='chunkid' select="$id"/>
164             </xsl:call-template>
165                 </xsl:when>
166                 <xsl:otherwise>
167             <xsl:call-template name='textdecoration_1'>
168                 <xsl:with-param name='version' select="$versionstr"/>
169                 <xsl:with-param name='chunkid' select="$id"/>
170             </xsl:call-template>
171                 </xsl:otherwise>
172     </xsl:choose>
173 </xsl:template>
174
175 <!-- toc.line template: This template over loads the behavior of creating the table of contents. It
176                 adds in a small entry to identify lustre version specific features.
177                 for more information, see this page:
178                 http://xml.web.cern.ch/XML/www.sagehill.net/xml/docbookxsl/PrintCustomEx.html#PrintTocEntries -->
179 <xsl:template name="toc.line">
180         <xsl:variable name="id">
181                 <xsl:call-template name="object.id"/>
182         </xsl:variable>
183         <xsl:variable name="lustrecond">
184                 <xsl:choose>
185                         <xsl:when test="@condition='l21'">L 2.1</xsl:when>
186                         <xsl:when test="@condition='l22'">L 2.2</xsl:when>
187                         <xsl:when test="@condition='l23'">L 2.3</xsl:when>
188                         <xsl:when test="@condition='l24'">L 2.4</xsl:when>
189                         <xsl:when test="@condition='l25'">L 2.5</xsl:when>
190                         <xsl:when test="@condition='l26'">L 2.6</xsl:when>
191                         <xsl:when test="@condition='l27'">L 2.7</xsl:when>
192                         <xsl:when test="@condition='l28'">L 2.8</xsl:when>
193                         <xsl:when test="@condition='l29'">L 2.9</xsl:when>
194                         <xsl:otherwise></xsl:otherwise>
195                 </xsl:choose>
196         </xsl:variable>
197
198         <xsl:variable name="label">
199                 <xsl:apply-templates select="." mode="label.markup"/>
200         </xsl:variable>
201         <fo:block text-align-last="justify"
202                         end-indent="{$toc.indent.width}pt"
203                         last-line-end-indent="-{$toc.indent.width}pt">
204                 <fo:inline keep-with-next.within-line="always">
205                         <xsl:choose>
206                                 <xsl:when test="local-name(.) = 'chapter'">
207                                         <xsl:attribute name="font-weight">bold</xsl:attribute>
208                                 </xsl:when>
209                         </xsl:choose>
210                         <fo:basic-link internal-destination="{$id}">
211                                 <xsl:if test="$label != ''">
212                                         <xsl:copy-of select="$label"/>
213                                         <xsl:value-of select="$autotoc.label.separator"/>
214                                 </xsl:if>
215                                 <xsl:apply-templates select="." mode="title.markup"/>
216                         </fo:basic-link>
217                 </fo:inline>
218                 <fo:inline keep-together.within-line="always">
219                         <xsl:text> </xsl:text>
220                         <fo:leader leader-pattern="dots"
221                                         leader-pattern-width="3pt"
222                                         leader-alignment="reference-area"
223                                         keep-with-next.within-line="always"/>
224                         <xsl:text>  </xsl:text>
225                         <xsl:value-of select='$lustrecond'/>
226                         <xsl:text>  </xsl:text>
227                         <fo:basic-link internal-destination="{$id}">
228                                 <fo:page-number-citation ref-id="{$id}"/>
229                         </fo:basic-link>
230                 </fo:inline>
231         </fo:block>
232 </xsl:template>
233
234 </xsl:stylesheet>