/[gentoo]/xml/htdocs/xsl/handbook.xsl
Gentoo

Contents of /xml/htdocs/xsl/handbook.xsl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (hide annotations) (download) (as text)
Thu Oct 23 11:36:24 2003 UTC (9 years, 7 months ago) by swift
Branch: MAIN
Changes since 1.6: +66 -65 lines
File MIME type: application/xml
Restyle handbook internally

1 swift 1.1 <?xml version="1.0" encoding="UTF-8"?>
2     <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
3    
4     <!-- Define global variables; if a user has
5     already defined those, this is a NOP -->
6 swift 1.7 <xsl:param name="part">0</xsl:param>
7 swift 1.1 <xsl:param name="chap">0</xsl:param>
8    
9     <!-- A book -->
10     <xsl:template match="/book">
11     <!-- If chap = 0, show an index -->
12     <xsl:choose>
13 swift 1.7 <xsl:when test="$part != 0">
14     <xsl:apply-templates select="part" />
15 swift 1.1 </xsl:when>
16     <xsl:otherwise>
17     <xsl:choose>
18     <xsl:when test="$style = 'printable'">
19     <xsl:call-template name="printdoclayout" />
20     </xsl:when>
21     <xsl:otherwise>
22     <xsl:call-template name="doclayout"/>
23     </xsl:otherwise>
24     </xsl:choose>
25     </xsl:otherwise>
26     </xsl:choose>
27     </xsl:template>
28    
29     <!-- Content of /book -->
30     <xsl:template name="bookcontent">
31     <xsl:call-template name="menubar" />
32     <h1><xsl:value-of select="title" /></h1>
33     <xsl:if test="$style = 'printable'">
34     <xsl:apply-templates select="author" />
35     </xsl:if>
36     <p>Content:</p>
37     <ul>
38 swift 1.7 <xsl:for-each select="part">
39     <xsl:param name="curpart" select="position()" />
40 swift 1.1 <li>
41 swift 1.7 <b><a href="?part={$curpart}&amp;chap=0&amp;style={$style}"><xsl:value-of select="title" /></a></b>
42 swift 1.1 <xsl:if test="abstract">
43 swift 1.6 <br />
44     <xsl:value-of select="abstract" />
45 swift 1.1 </xsl:if>
46 swift 1.6 <ol>
47 swift 1.7 <xsl:for-each select="chapter">
48     <xsl:param name="curchap" select="position()" />
49 swift 1.1 <li>
50 swift 1.7 <b><a href="?part={$curpart}&amp;chap={$curchap}&amp;style={$style}"><xsl:value-of select="title" /></a></b>
51 swift 1.1 <xsl:if test="abstract">
52     <br/>
53 swift 1.6 <xsl:value-of select="abstract" />
54 swift 1.1 </xsl:if>
55     </li>
56     </xsl:for-each>
57 swift 1.6 </ol>
58 swift 1.1 </li>
59     </xsl:for-each>
60     </ul>
61     <xsl:call-template name="menubar" />
62 swift 1.5 <xsl:apply-templates select="/book/license" />
63 swift 1.1 </xsl:template>
64    
65 swift 1.7 <!-- Part inside a book -->
66     <xsl:template match="/book/part">
67     <xsl:if test="($chap != 0) and ($part = position())">
68     <xsl:apply-templates select="chapter" />
69 swift 1.1 </xsl:if>
70 swift 1.7 <xsl:if test="($chap = 0) and ($part = position())">
71 swift 1.1 <xsl:choose>
72     <xsl:when test="$style = 'printable'">
73     <xsl:call-template name="printdoclayout" />
74     </xsl:when>
75     <xsl:otherwise>
76     <xsl:call-template name="doclayout" />
77     </xsl:otherwise>
78     </xsl:choose>
79     </xsl:if>
80     </xsl:template>
81    
82 swift 1.7 <!-- Content of /book/part -->
83     <xsl:template name="bookpartcontent">
84 swift 1.1 <xsl:call-template name="menubar" />
85     <h1><xsl:number level="multiple" format="1. " select="position()"/><xsl:value-of select="title" /></h1>
86     <xsl:if test="abstract">
87     <p><xsl:value-of select="abstract" /></p>
88     </xsl:if>
89     <p>Content:</p>
90 swift 1.6 <ol>
91 swift 1.7 <xsl:for-each select="chapter">
92 swift 1.1 <xsl:param name="curpos" select="position()" />
93     <xsl:if test="title">
94     <li>
95 swift 1.7 <b><a href="?part={$part}&amp;chap={$curpos}&amp;style={$style}"><xsl:value-of select="title" /></a></b>
96 swift 1.1 <xsl:if test="abstract">
97 swift 1.6 <br/><xsl:value-of select="abstract" />
98 swift 1.1 </xsl:if>
99     </li>
100     </xsl:if>
101     </xsl:for-each>
102 swift 1.6 </ol>
103 swift 1.1
104     <xsl:call-template name="menubar" />
105 swift 1.5 <xsl:apply-templates select="/book/license" />
106 swift 1.1 </xsl:template>
107    
108     <!-- Menu bar -->
109     <xsl:template name="menubar">
110 swift 1.7 <xsl:variable name="prevpart" select="number($part) - 1" />
111 swift 1.1 <xsl:variable name="prevchap" select="number($chap) - 1" />
112 swift 1.7 <xsl:variable name="nextpart" select="number($part) + 1" />
113 swift 1.1 <xsl:variable name="nextchap" select="number($chap) + 1" />
114     <xsl:if test="$style != 'printable'">
115     <hr />
116     <p class="alttext">
117 swift 1.7 <!-- Previous Parts -->
118 swift 1.1 <xsl:choose>
119 swift 1.7 <xsl:when test="number($prevpart) &lt; 1">
120     [ &lt;&lt; Previous Part ]
121 swift 1.1 </xsl:when>
122     <xsl:otherwise>
123 swift 1.7 [ <a href="?part={$prevpart}&amp;chap=0">&lt;&lt; Previous Part</a> ]
124 swift 1.1 </xsl:otherwise>
125     </xsl:choose>
126 swift 1.7 <!-- Previous Chapter -->
127 swift 1.1 <xsl:choose>
128 swift 1.7 <xsl:when test="number($prevchap) &lt; 1">
129     [ &lt; Previous Chapter ]
130 swift 1.1 </xsl:when>
131     <xsl:otherwise>
132 swift 1.7 [ <a href="?part={$part}&amp;chap={$prevchap}">&lt; Previous Chapter</a> ]
133 swift 1.1 </xsl:otherwise>
134     </xsl:choose>
135     <!-- Content -->
136 swift 1.7 [ <a href="?part=0&amp;chap=0">Home</a> ]
137     <!-- Next Chapter -->
138 swift 1.2 <xsl:if test="name() = 'book'">
139 swift 1.7 [ <a href="?part=1">Next Chapter &gt;</a> ]
140     </xsl:if>
141     <xsl:if test="name() = 'part'">
142     [ <a href="?part={$part}&amp;chap=1">Next Chapter &gt;</a> ]
143 swift 1.1 </xsl:if>
144 swift 1.2 <xsl:if test="name() = 'chapter'">
145 swift 1.1 <xsl:choose>
146 swift 1.7 <xsl:when test="number($chap) = count(section)">
147     [ Next Chapter &gt; ]
148 swift 1.1 </xsl:when>
149     <xsl:otherwise>
150 swift 1.7 [ <a href="?part={$part}&amp;chap={$nextchap}">Next Chapter &gt;</a> ]
151 swift 1.1 </xsl:otherwise>
152     </xsl:choose>
153     </xsl:if>
154 swift 1.7 <!-- Next Part -->
155 swift 1.2 <xsl:if test="name() = 'book'">
156 swift 1.7 [ <a href="?part={$nextpart}">Next Part &gt;&gt;</a> ]
157 swift 1.1 </xsl:if>
158 swift 1.7 <xsl:if test="name() = 'part'">
159 swift 1.1 <xsl:choose>
160 swift 1.7 <xsl:when test="number($part) = last()">
161     [ Next Part &gt;&gt; ]
162 swift 1.1 </xsl:when>
163     <xsl:otherwise>
164 swift 1.7 [ <a href="?part={$nextpart}&amp;chap=0">Next Part &gt;&gt;</a> ]
165 swift 1.1 </xsl:otherwise>
166     </xsl:choose>
167     </xsl:if>
168 swift 1.7 <xsl:if test="name() = 'chapter'">
169 swift 1.1 <xsl:choose>
170 swift 1.7 <xsl:when test="count(/book/part) = number($part)">
171     [ Next Part &gt;&gt; ]
172 swift 1.1 </xsl:when>
173     <xsl:otherwise>
174 swift 1.7 [ <a href="?part={$nextpart}&amp;chap=0">Next Part &gt;&gt;</a> ]
175 swift 1.1 </xsl:otherwise>
176     </xsl:choose>
177     </xsl:if>
178     </p>
179     <hr />
180     </xsl:if>
181     </xsl:template>
182    
183    
184 swift 1.7 <!-- Chapter inside a part -->
185     <xsl:template match="/book/part/chapter">
186     <xsl:if test="$chap = position()">
187 swift 1.1 <xsl:choose>
188     <xsl:when test="$style = 'printable'">
189     <xsl:call-template name="printdoclayout" />
190     </xsl:when>
191     <xsl:otherwise>
192     <xsl:call-template name="doclayout" />
193     </xsl:otherwise>
194     </xsl:choose>
195     </xsl:if>
196     </xsl:template>
197    
198 swift 1.7 <!-- Content of /book/part/chapter -->
199     <xsl:template name="bookpartchaptercontent">
200 swift 1.1 <xsl:call-template name="menubar" />
201     <h1><xsl:number level="multiple" format="1. " select="position()"/><xsl:value-of select="title" /></h1>
202 swift 1.2 <xsl:variable name="doc" select="include/@href"/>
203 swift 1.4 <xsl:variable name="FILE" select="document($doc)" />
204 swift 1.7 <xsl:if test="$FILE/sections/section/title">
205 swift 1.1 <b>Content: </b>
206     <ul>
207 swift 1.7 <xsl:for-each select="$FILE/sections/section/title">
208 swift 1.1 <xsl:param name="pos" select="position()" />
209 swift 1.7 <li><a href="#doc_chap{$pos}" class="altlink"><xsl:value-of select="." /></a></li>
210 swift 1.1 </xsl:for-each>
211     </ul>
212     </xsl:if>
213 swift 1.7 <xsl:apply-templates select="$FILE/sections/section" />
214 swift 1.1
215     <xsl:call-template name="menubar" />
216 swift 1.5 <xsl:apply-templates select="/book/license" />
217 swift 1.1 </xsl:template>
218    
219 swift 1.7 <!-- Section inside a chapter -->
220     <xsl:template match="/sections/section">
221 swift 1.1 <xsl:param name="pos" select="position()" />
222 swift 1.7 <a name="doc_chap{$pos}"/>
223 swift 1.1 <xsl:if test="title">
224 swift 1.7 <p class="chaphead"><span class="chapnum"><xsl:value-of select="$chap" />.<xsl:number level="multiple" format="a. " select="position()" /></span><xsl:value-of select="title" /></p>
225 swift 1.1 </xsl:if>
226 swift 1.7 <xsl:apply-templates select="body|subsection">
227     <xsl:with-param name="chpos" select="$pos"/>
228     </xsl:apply-templates>
229 swift 1.1 </xsl:template>
230    
231 swift 1.7 <!-- Subsubsection inside a section -->
232     <xsl:template match="/sections/section/subsection">
233 swift 1.2 <xsl:param name="pos" select="position()"/>
234 swift 1.7 <a name="doc_chap{$chpos}_sect{$pos}" />
235 swift 1.2 <p class="secthead"><xsl:value-of select="title" /></p>
236 swift 1.1 <xsl:apply-templates select="body" />
237     </xsl:template>
238    
239     </xsl:stylesheet>

  ViewVC Help
Powered by ViewVC 1.1.13