Gentoo Archives: gentoo-commits

From: "Xavier Neys (neysx)" <neysx@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo commit in xml/htdocs/xsl: guide.xsl handbook.xsl
Date: Tue, 01 Jan 2008 21:29:31
Message-Id: E1J9oft-000724-Fk@stork.gentoo.org
1 neysx 08/01/01 21:29:25
2
3 Modified: guide.xsl handbook.xsl
4 Log:
5 Added support for included bits
6
7 Revision Changes Path
8 1.224 xml/htdocs/xsl/guide.xsl
9
10 file : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/xsl/guide.xsl?rev=1.224&view=markup
11 plain: http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/xsl/guide.xsl?rev=1.224&content-type=text/plain
12 diff : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/xsl/guide.xsl?r1=1.223&r2=1.224
13
14 Index: guide.xsl
15 ===================================================================
16 RCS file: /var/cvsroot/gentoo/xml/htdocs/xsl/guide.xsl,v
17 retrieving revision 1.223
18 retrieving revision 1.224
19 diff -u -r1.223 -r1.224
20 --- guide.xsl 15 Nov 2007 08:16:42 -0000 1.223
21 +++ guide.xsl 1 Jan 2008 21:29:24 -0000 1.224
22 @@ -25,6 +25,8 @@
23
24 <xsl:include href="/xsl/devmap.xsl" />
25
26 +<xsl:include href="/xsl/doc-struct.xsl" />
27 +
28 <!-- When using <pre>, whitespaces should be preserved -->
29 <xsl:preserve-space elements="pre script"/>
30
31 @@ -102,12 +104,12 @@
32 </xsl:if>
33 </xsl:when>
34 <xsl:otherwise>
35 - <xsl:if test="count(/guide/chapter)&gt;1">
36 + <xsl:if test="count(exslt:node-set($doc-struct)//chapter)&gt;1">
37 <form name="contents" action="http://www.gentoo.org">
38 <b><xsl:value-of select="func:gettext('Content')"/></b>:
39 <select name="url" size="1" OnChange="location.href=form.url.options[form.url.selectedIndex].value" style="font-family:sans-serif,Arial,Helvetica">
40 - <xsl:for-each select="chapter">
41 - <xsl:variable name="chapid">doc_chap<xsl:number/></xsl:variable><option value="#{$chapid}"><xsl:number/>. <xsl:value-of select="title"/></option>
42 + <xsl:for-each select="exslt:node-set($doc-struct)//chapter">
43 + <option value="#doc_chap{position()}"><xsl:number/>. <xsl:value-of select="@title"/></option>
44 </xsl:for-each>
45 </select>
46 </form>
47 @@ -253,7 +255,7 @@
48 </xsl:template>
49
50
51 -<xsl:template match="/gleps|/devaway|/uris|/inserts|/glsa-index|opensearch:OpenSearchDescription">
52 +<xsl:template match="/included|/gleps|/devaway|/uris|/inserts|/glsa-index|opensearch:OpenSearchDescription">
53 <xsl:message>
54 <xsl:value-of select="concat('%%GORG%%Redirect=',$link,'?passthru=1')"/>
55 </xsl:message>
56 @@ -279,7 +281,7 @@
57 <link rel="search" type="application/opensearchdescription+xml" href="http://www.gentoo.org/search/www-gentoo-org.xml" title="Gentoo Website"/>
58 <link rel="search" type="application/opensearchdescription+xml" href="http://www.gentoo.org/search/forums-gentoo-org.xml" title="Gentoo Forums"/>
59 <link rel="search" type="application/opensearchdescription+xml" href="http://www.gentoo.org/search/bugs-gentoo-org.xml" title="Gentoo Bugzilla"/>
60 -<!-- <link rel="search" type="application/opensearchdescription+xml" href="http://www.gentoo.org/search/packages-gentoo-org.xml" title="Gentoo Packages"/> -->
61 + <link rel="search" type="application/opensearchdescription+xml" href="http://www.gentoo.org/search/packages-gentoo-org.xml" title="Gentoo Packages"/>
62 <link rel="search" type="application/opensearchdescription+xml" href="http://www.gentoo.org/search/archives-gentoo-org.xml" title="Gentoo List Archives"/>
63
64 <xsl:if test="/mainpage/newsitems">
65 @@ -704,18 +706,56 @@
66 </xsl:template>
67
68 <!-- FAQ Index & Chapter -->
69 -<xsl:template match="faqindex|chapter">
70 - <xsl:variable name="chid"><xsl:number count="faqindex|chapter"/></xsl:variable>
71 +<xsl:template match="faqindex|chapter|/sections/section">
72 + <xsl:if test="not(@test) or dyn:evaluate(@test)">
73 + <xsl:variable name="uid" select="generate-id(.)" />
74 + <xsl:variable name="chid">
75 + <xsl:value-of select="1+count(exslt:node-set($doc-struct)//chapter[@uid=$uid]/preceding-sibling::chapter)"/>
76 + </xsl:variable>
77 +
78 + <xsl:variable name="partnum">
79 + <xsl:value-of select="exslt:node-set($doc-struct)//bookpart[descendant::*[@uid=$uid]]/@pos"/>
80 + </xsl:variable>
81 + <xsl:variable name="chapnum">
82 + <xsl:value-of select="exslt:node-set($doc-struct)//bookchap[descendant::*[@uid=$uid]]/@pos"/>
83 + </xsl:variable>
84 +
85 <xsl:choose>
86 + <xsl:when test="include">
87 + <xsl:apply-templates select="document(include/@href)//chapter"/>
88 + </xsl:when>
89 +
90 <xsl:when test="title">
91 + <xsl:if test="not(position()=1 and title/text()=/mainpage/title)">
92 +
93 <p class="chaphead">
94 - <xsl:if test="@id"><a name="{@id}"/></xsl:if>
95 - <a name="doc_chap{$chid}"/>
96 - <xsl:if test="not(/mainpage) and (count(//faqindex)+count(//chapter))>1">
97 - <span class="chapnum"><xsl:value-of select="$chid"/>.&#160;</span>
98 + <xsl:if test="@id">
99 + <a name="{@id}"/>
100 </xsl:if>
101 +
102 + <xsl:choose>
103 + <xsl:when test="$TTOP='book' and $full != 0">
104 + <a name="book_part{$partnum}_chap{$chapnum}__chap{$chid}"/>
105 + </xsl:when>
106 + <xsl:otherwise>
107 + <a name="doc_chap{$chid}"/>
108 + </xsl:otherwise>
109 + </xsl:choose>
110 +
111 + <span class="chapnum">
112 + <xsl:choose>
113 + <xsl:when test="$TTOP='book'">
114 + <xsl:value-of select="$chapnum" />.<xsl:number level="multiple" format="a. " value="$chid"/>
115 + </xsl:when>
116 + <xsl:otherwise>
117 + <xsl:value-of select="$chid"/>.&#160;
118 + </xsl:otherwise>
119 + </xsl:choose>
120 + </span>
121 <xsl:value-of select="title"/>
122 </p>
123 +
124 + </xsl:if>
125 </xsl:when>
126 <xsl:otherwise>
127 <xsl:if test="/guide">
128 @@ -727,25 +767,21 @@
129 </xsl:if>
130 </xsl:otherwise>
131 </xsl:choose>
132 - <xsl:apply-templates select="body">
133 - <xsl:with-param name="chid" select="$chid"/>
134 - </xsl:apply-templates>
135 - <xsl:apply-templates select="section">
136 - <xsl:with-param name="chid" select="$chid"/>
137 - </xsl:apply-templates>
138 +
139 + <xsl:apply-templates select="section|subsection|body"/>
140
141 <xsl:if test="name()='faqindex'">
142 <!-- Generate FAQ index -->
143
144 - <xsl:for-each select="./following-sibling::chapter">
145 - <xsl:if test="section/title">
146 + <xsl:for-each select="exslt:node-set($doc-struct)//chapter[position()>1]">
147 + <xsl:if test="section[@title]">
148 <p class="secthead">
149 - <xsl:value-of select="title"/>
150 + <xsl:value-of select="@title"/>
151 </p>
152 <xsl:variable name="nchap"><xsl:value-of select="1+position()"/></xsl:variable>
153 <ul>
154 <xsl:for-each select="section">
155 - <xsl:if test="title">
156 + <xsl:if test="@title">
157 <li>
158 <a>
159 <xsl:attribute name="href">
160 @@ -758,7 +794,7 @@
161 </xsl:otherwise>
162 </xsl:choose>
163 </xsl:attribute>
164 - <xsl:value-of select="title"/>
165 + <xsl:value-of select="@title"/>
166 </a>
167 </li>
168 </xsl:if>
169 @@ -767,75 +803,122 @@
170 </xsl:if>
171 </xsl:for-each>
172 </xsl:if>
173 + </xsl:if>
174 </xsl:template>
175
176
177 <!-- Section template -->
178 -<xsl:template match="section">
179 -<xsl:param name="chid"/>
180 -<xsl:if test="title">
181 - <xsl:variable name="sectid">doc_chap<xsl:value-of select="$chid"/>_sect<xsl:number/></xsl:variable>
182 - <xsl:if test="@id">
183 - <a name="{@id}"/>
184 - </xsl:if>
185 - <p class="secthead">
186 - <a name="{$sectid}"><xsl:value-of select="title"/></a>
187 - </p>
188 -</xsl:if>
189 -<xsl:apply-templates select="body">
190 - <xsl:with-param name="chid" select="$chid"/>
191 -</xsl:apply-templates>
192 +<xsl:template match="section|/sections/section/subsection">
193 + <xsl:if test="not(@test) or dyn:evaluate(@test)">
194 +
195 + <xsl:variable name="uid" select="generate-id(.)" />
196 + <xsl:variable name="chid">
197 + <xsl:value-of select="1+count(exslt:node-set($doc-struct)//chapter[descendant::section[@uid=$uid]]/preceding-sibling::chapter)"/>
198 + </xsl:variable>
199 + <xsl:variable name="seid">
200 + <xsl:value-of select="1+count(exslt:node-set($doc-struct)//section[@uid=$uid]/preceding-sibling::section)"/>
201 + </xsl:variable>
202 +
203 + <xsl:variable name="partnum">
204 + <xsl:value-of select="exslt:node-set($doc-struct)//bookpart[descendant::*[@uid=$uid]]/@pos"/>
205 + </xsl:variable>
206 + <xsl:variable name="chapnum">
207 + <xsl:value-of select="exslt:node-set($doc-struct)//bookchap[descendant::*[@uid=$uid]]/@pos"/>
208 + </xsl:variable>
209 +
210 + <xsl:choose>
211 + <xsl:when test="include">
212 + <xsl:apply-templates select="document(include/@href)//section"/>
213 + </xsl:when>
214 +
215 + <xsl:when test="title">
216 + <xsl:variable name="sectid">
217 + <xsl:choose>
218 + <xsl:when test="$TTOP='book' and $full != 0">
219 + <xsl:value-of select="concat('book_part', $partnum, '_chap', $chapnum, '__chap', $chid, '_sect', $seid)"/>
220 + </xsl:when>
221 + <xsl:otherwise>
222 + <xsl:value-of select="concat('doc_chap', $chid, '_sect', $seid)"/>
223 + </xsl:otherwise>
224 + </xsl:choose>
225 + </xsl:variable>
226 +
227 + <p class="secthead">
228 + <xsl:if test="@id">
229 + <a name="{@id}"/></xsl:if>
230 + <a name="{$sectid}"><xsl:value-of select="title"/></a>
231 + </p>
232 + </xsl:when>
233 + </xsl:choose>
234 +
235 + <xsl:apply-templates select="body"/>
236 + </xsl:if>
237 </xsl:template>
238
239 <!-- Figure template -->
240 <xsl:template match="figure">
241 -<xsl:param name="chid"/>
242 -<xsl:variable name="fignum"><xsl:number level="any" from="chapter" count="figure"/></xsl:variable>
243 -<xsl:variable name="figid">doc_chap<xsl:value-of select="$chid"/>_fig<xsl:value-of select="$fignum"/></xsl:variable>
244 -<xsl:variable name="llink">
245 - <xsl:choose>
246 - <xsl:when test="starts-with(@link,'http://www.gentoo.org/')">
247 - <xsl:value-of select="concat($ROOT, substring-after(@link, 'http://www.gentoo.org/'))"/>
248 - </xsl:when>
249 - <xsl:when test="starts-with(@link,'/')">
250 - <xsl:value-of select="concat($ROOT, substring-after(@link, '/'))"/>
251 + <xsl:variable name="uid" select="generate-id(.)" />
252 + <xsl:variable name="chid">
253 + <xsl:value-of select="1+count(exslt:node-set($doc-struct)//chapter[descendant::figure[@uid=$uid]]/preceding-sibling::chapter)"/>
254 + </xsl:variable>
255 + <xsl:variable name="fignum">
256 + <xsl:value-of select="1+count(exslt:node-set($doc-struct)//chapter[descendant::figure[@uid=$uid]]//figure[following::figure[@uid=$uid]])"/>
257 + </xsl:variable>
258 + <xsl:variable name="figid">
259 + <xsl:choose>
260 + <xsl:when test="($TTOP = 'book') and ($full != 0)">
261 + <xsl:value-of select="concat('book_part', exslt:node-set($doc-struct)//bookpart[descendant::figure[@uid=$uid]]/@pos, '_chap', exslt:node-set($doc-struct)//bookchap[descendant::figure[@uid=$uid]]/@pos, '__chap', $chid, '_fig', $fignum)"/>
262 </xsl:when>
263 <xsl:otherwise>
264 - <xsl:value-of select="@link"/>
265 + <xsl:value-of select="concat('doc_chap', $chid, '_fig', $fignum)"/>
266 </xsl:otherwise>
267 - </xsl:choose>
268 -</xsl:variable>
269 -<br/>
270 -<a name="{$figid}"/>
271 -<table cellspacing="0" cellpadding="0" border="0">
272 - <tr>
273 - <td bgcolor="#7a5ada">
274 - <p class="codetitle">
275 + </xsl:choose>
276 + </xsl:variable>
277 +
278 + <xsl:variable name="llink">
279 + <xsl:choose>
280 + <xsl:when test="starts-with(@link,'http://www.gentoo.org/')">
281 + <xsl:value-of select="concat($ROOT, substring-after(@link, 'http://www.gentoo.org/'))"/>
282 + </xsl:when>
283 + <xsl:when test="starts-with(@link,'/')">
284 + <xsl:value-of select="concat($ROOT, substring-after(@link, '/'))"/>
285 + </xsl:when>
286 + <xsl:otherwise>
287 + <xsl:value-of select="@link"/>
288 + </xsl:otherwise>
289 + </xsl:choose>
290 + </xsl:variable>
291 + <br/>
292 + <a name="{$figid}"/>
293 + <table cellspacing="0" cellpadding="0" border="0">
294 + <tr>
295 + <td bgcolor="#7a5ada">
296 + <p class="codetitle">
297 + <xsl:choose>
298 + <xsl:when test="@caption">
299 + <xsl:value-of select="func:gettext('Figure')"/>&#160;<xsl:value-of select="$chid"/>.<xsl:value-of select="$fignum"/><xsl:value-of select="func:gettext('SpaceBeforeColon')"/>: <xsl:value-of select="@caption"/>
300 + </xsl:when>
301 + <xsl:otherwise>
302 + <xsl:value-of select="func:gettext('Figure')"/>&#160;<xsl:value-of select="$chid"/>.<xsl:value-of select="$fignum"/>
303 + </xsl:otherwise>
304 + </xsl:choose>
305 + </p>
306 + </td>
307 + </tr>
308 + <tr>
309 + <td align="center" bgcolor="#ddddff">
310 <xsl:choose>
311 - <xsl:when test="@caption">
312 - <xsl:value-of select="func:gettext('Figure')"/>&#160;<xsl:value-of select="$chid"/>.<xsl:value-of select="$fignum"/><xsl:value-of select="func:gettext('SpaceBeforeColon')"/>: <xsl:value-of select="@caption"/>
313 + <xsl:when test="@short">
314 + <img src="{$llink}" alt="Fig. {$fignum}: {@short}"/>
315 </xsl:when>
316 <xsl:otherwise>
317 - <xsl:value-of select="func:gettext('Figure')"/>&#160;<xsl:value-of select="$chid"/>.<xsl:value-of select="$fignum"/>
318 + <img src="{$llink}" alt="Fig. {$fignum}"/>
319 </xsl:otherwise>
320 </xsl:choose>
321 - </p>
322 - </td>
323 - </tr>
324 - <tr>
325 - <td align="center" bgcolor="#ddddff">
326 - <xsl:choose>
327 - <xsl:when test="@short">
328 - <img src="{$llink}" alt="Fig. {$fignum}: {@short}"/>
329 - </xsl:when>
330 - <xsl:otherwise>
331 - <img src="{$llink}" alt="Fig. {$fignum}"/>
332 - </xsl:otherwise>
333 - </xsl:choose>
334 - </td>
335 - </tr>
336 -</table>
337 -<br/>
338 + </td>
339 + </tr>
340 + </table>
341 + <br/>
342 </xsl:template>
343
344 <!--figure without a caption; just a graphical element-->
345 @@ -989,11 +1072,15 @@
346
347 <!-- Body -->
348 <xsl:template match="body">
349 -<xsl:param name="chid"/>
350 <xsl:if test="not(@test) or dyn:evaluate(@test)">
351 - <xsl:apply-templates>
352 - <xsl:with-param name="chid" select="$chid"/>
353 - </xsl:apply-templates>
354 + <xsl:choose>
355 + <xsl:when test="include">
356 + <xsl:apply-templates select="document(include/@href)//body"/>
357 + </xsl:when>
358 + <xsl:otherwise>
359 + <xsl:apply-templates select="./*[not(@test) or dyn:evaluate(@test)]"/>
360 + </xsl:otherwise>
361 + </xsl:choose>
362 </xsl:if>
363 </xsl:template>
364
365 @@ -1004,10 +1091,25 @@
366
367 <!-- Preserve whitespace, aka Code Listing -->
368 <xsl:template match="pre">
369 -<xsl:param name="chid"/>
370 <xsl:if test="not(@test) or dyn:evaluate(@test)">
371 - <xsl:variable name="prenum"><xsl:number level="any" from="chapter" count="pre[not(ancestor-or-self::*[@test and not(dyn:evaluate(@test))])]"/></xsl:variable>
372 - <xsl:variable name="preid">doc_chap<xsl:value-of select="$chid"/>_pre<xsl:value-of select="$prenum"/></xsl:variable>
373 + <xsl:variable name="uid" select="generate-id(.)" />
374 + <xsl:variable name="chid">
375 + <xsl:value-of select="1+count(exslt:node-set($doc-struct)//chapter[descendant::pre[@uid=$uid]]/preceding-sibling::chapter)"/>
376 + </xsl:variable>
377 + <xsl:variable name="prenum">
378 + <xsl:value-of select="1+count(exslt:node-set($doc-struct)//chapter[descendant::pre[@uid=$uid]]//pre[following::pre[@uid=$uid]])"/>
379 + </xsl:variable>
380 + <xsl:variable name="preid">
381 + <xsl:choose>
382 + <xsl:when test="($TTOP = 'book') and ($full != 0)">
383 + <xsl:value-of select="concat('book_part', exslt:node-set($doc-struct)//bookpart[descendant::pre[@uid=$uid]]/@pos, '_chap', exslt:node-set($doc-struct)//bookchap[descendant::pre[@uid=$uid]]/@pos, '__chap', $chid, '_pre', $prenum)"/>
384 + </xsl:when>
385 + <xsl:otherwise>
386 + <xsl:value-of select="concat('doc_chap', $chid, '_pre', $prenum)"/>
387 + </xsl:otherwise>
388 + </xsl:choose>
389 + </xsl:variable>
390 +
391 <a name="{$preid}"/>
392 <table class="ntable" width="100%" cellspacing="0" cellpadding="0" border="0">
393 <tr>
394 @@ -1106,7 +1208,8 @@
395 <xsl:choose>
396 <xsl:when test="starts-with(@link, '#doc_')">
397 <xsl:variable name="locallink" select="substring-after(@link, 'doc_')" />
398 - <a href="#book_{generate-id(/)}_{$locallink}"><xsl:apply-templates /></a>
399 + <xsl:variable name="bodyid" select="generate-id(ancestor::body)"/>
400 + <a href="{concat('#book_part',exslt:node-set($doc-struct)//bookpart[descendant::body[@uid=$bodyid]]/@pos,'_chap',exslt:node-set($doc-struct)//bookchap[descendant::body[@uid=$bodyid]]/@pos,'__',$locallink)}"><xsl:apply-templates /></a>
401 </xsl:when>
402 <xsl:otherwise>
403 <a href="{@link}"><xsl:apply-templates/></a>
404 @@ -1427,95 +1530,47 @@
405 <xsl:template name="compare-versions">
406 <xsl:param name="original"/>
407 <xsl:param name="translation"/>
408 - <xsl:choose>
409 - <xsl:when test="$original/book and $translation/book">
410 - <!-- /book == /book -->
411 - <xsl:choose>
412 - <xsl:when test="$full != 0">
413 - <!-- if full != 0, then compare all files -->
414 - <!-- Compare versions in master files -->
415 - <xsl:if test="$original/book/version != $translation/book/version">X</xsl:if>
416 - <!-- Compare versions in original chapters vs. translated chapters that have the same position -->
417 - <xsl:for-each select="$translation/book/part">
418 - <xsl:variable name="part" select="position()"/>
419 - <xsl:for-each select="chapter">
420 - <xsl:variable name="chap" select="position()"/>
421 - <xsl:variable name="ov" select="document($original/book/part[$part]/chapter[$chap]/include/@href)/sections/version"/>
422 - <xsl:variable name="tv" select="document($translation/book/part[$part]/chapter[$chap]/include/@href)/sections/version"/>
423 - <xsl:if test="$ov != $tv or not($tv) or not($ov)">X</xsl:if>
424 - </xsl:for-each>
425 - </xsl:for-each>
426 - </xsl:when>
427 - <xsl:when test="$part = '0' or $chap = '0'">
428 - <!-- Table of contents, check master file -->
429 - <xsl:if test="$original/book/version != $translation/book/version">X</xsl:if>
430 - </xsl:when>
431 - <xsl:otherwise>
432 - <!-- Compare chapters at same position (/$part/$chap/) in English handbook and in translated one -->
433 - <xsl:variable name="ov" select="document($original/book/part[position()=$part]/chapter[position()=$chap]/include/@href)/sections/version"/>
434 - <xsl:variable name="tv" select="document($translation/book/part[position()=$part]/chapter[position()=$chap]/include/@href)/sections/version"/>
435 - <xsl:if test="not ($ov)">NoOriginal</xsl:if>
436 - <xsl:if test="$ov != $tv or not($tv)">X</xsl:if>
437 - </xsl:otherwise>
438 - </xsl:choose>
439 - </xsl:when>
440 - <xsl:when test="$original/guide and $translation/guide">
441 - <!-- /guide == /guide -->
442 - <xsl:if test="$original/guide/version != $translation/guide/version">X</xsl:if>
443 - </xsl:when>
444 - <xsl:when test="$original/mainpage and $translation/mainpage">
445 - <xsl:if test="$original/mainpage/version != $translation/mainpage/version">X</xsl:if>
446 - </xsl:when>
447 - <xsl:when test="$original/sections and $translation/sections">
448 - <xsl:if test="$original/sections/version != $translation/sections/version">X</xsl:if>
449 - </xsl:when>
450 - <!-- If we did not compare book==book, mainpage==mainpage or guide==guide, then consider versions are different -->
451 - <xsl:otherwise>X</xsl:otherwise>
452 - </xsl:choose>
453 +
454 + <xsl:choose>
455 + <xsl:when test="$original/doc-struct/@type != $translation/doc-struct/@type">
456 + <xsl:text>NoOriginal</xsl:text>
457 + </xsl:when>
458 +
459 + <xsl:when test="/book and $full='0' and $chap != '0' and $part != '0' and not($original/doc-struct/bookpart[@pos=$part]/bookchap[@pos=$chap])">
460 + <xsl:text>NoOriginal</xsl:text>
461 + </xsl:when>
462 +
463 + <xsl:otherwise>
464 + <xsl:variable name="orig-versions">
465 + <xsl:for-each select="$original//version">
466 + <xsl:value-of select="concat(.,' ')"/>
467 + </xsl:for-each>
468 + </xsl:variable>
469 +
470 + <xsl:variable name="trans-versions">
471 + <xsl:for-each select="$translation//version">
472 + <xsl:value-of select="concat(.,' ')"/>
473 + </xsl:for-each>
474 + </xsl:variable>
475 +
476 + <xsl:if test="$orig-versions != $trans-versions">Different</xsl:if>
477 + </xsl:otherwise>
478 + </xsl:choose>
479 +
480 </xsl:template>
481
482 -<!-- Return the date of a document, for handbooks, it is the max(main file date, all included parts dates) -->
483 <xsl:template name="maxdate">
484 - <xsl:param name="thedoc"/>
485 - <xsl:choose>
486 - <xsl:when test="$thedoc/book">
487 - <!-- In a book: look for max(/date, include_files/sections/date) -->
488 - <xsl:for-each select="$thedoc/book/part/chapter/include">
489 - <xsl:sort select="document(@href)/sections/date" order="descending" />
490 - <xsl:if test="position() = 1">
491 - <!-- Compare the max(date) from included files with the date in the master file
492 - Of course, XSLT 1.0 knows no string comparison operator :-(
493 - So we build a node set with the two dates and we sort it.
494 - -->
495 - <xsl:variable name="theDates">
496 - <xsl:element name="bookDate">
497 - <xsl:value-of select="$thedoc/book/date"/>
498 - </xsl:element>
499 - <xsl:element name="maxChapterDate">
500 - <xsl:value-of select="document(@href)/sections/date"/>
501 - </xsl:element>
502 - </xsl:variable>
503 - <xsl:variable name="sortedDates">
504 - <xsl:for-each select="exslt:node-set($theDates)/*">
505 - <xsl:sort select="." order="descending" />
506 - <xsl:copy-of select="."/>
507 - </xsl:for-each>
508 - </xsl:variable>
509 - <!-- First date is the one we want -->
510 - <xsl:value-of select="exslt:node-set($sortedDates)/*[position()=1]"/>
511 - </xsl:if>
512 - </xsl:for-each>
513 - </xsl:when>
514 - <xsl:when test="$thedoc/guide or $thedoc/sections or $thedoc/mainpage or $thedoc/news">
515 - <xsl:value-of select="$thedoc/*[1]/date"/>
516 - </xsl:when>
517 - </xsl:choose>
518 +<xsl:param name="thedoc"/>
519 + <xsl:for-each select="$thedoc//date">
520 + <xsl:sort select="." order="descending" />
521 + <xsl:if test="position()=1"><xsl:value-of select="."/></xsl:if>
522 + </xsl:for-each>
523 </xsl:template>
524
525 <xsl:template name="contentdate">
526 <xsl:variable name="docdate">
527 <xsl:call-template name="maxdate">
528 - <xsl:with-param name="thedoc" select="/"/>
529 + <xsl:with-param name="thedoc" select="exslt:node-set($doc-struct)"/>
530 </xsl:call-template>
531 </xsl:variable>
532
533 @@ -1552,20 +1607,25 @@
534 <xsl:otherwise>
535 <!-- Document is listed in both local metadoc.xml and English one, compare version numbers -->
536 <xsl:variable name="pfile" select="$pmetadoc/metadoc/files/file[@id=$fileid]"/>
537 +
538 + <xsl:variable name="orig-struct" xmlns="">
539 + <xsl:call-template name="build-doc-struct">
540 + <xsl:with-param name="doc" select="document($pfile)"/>
541 + </xsl:call-template>
542 + </xsl:variable>
543 +
544 <xsl:variable name="versions">
545 <xsl:call-template name="compare-versions">
546 - <xsl:with-param name="original" select ="document($pfile)"/>
547 - <xsl:with-param name="translation" select ="/"/>
548 + <xsl:with-param name="translation" select ="exslt:node-set($doc-struct)"/>
549 + <xsl:with-param name="original" select ="exslt:node-set($orig-struct)"/>
550 </xsl:call-template>
551 </xsl:variable>
552 +
553 <xsl:choose>
554 - <xsl:when test="contains($versions,'NoOriginal')">
555 - <xsl:value-of select="func:gettext('NoOriginal')"/>
556 - </xsl:when>
557 - <xsl:when test="string-length($versions) > 0">
558 + <xsl:when test="$versions = 'Different'">
559 <xsl:variable name="pdocdate">
560 <xsl:call-template name="maxdate">
561 - <xsl:with-param name="thedoc" select="document($pfile)"/>
562 + <xsl:with-param name="thedoc" select="exslt:node-set($orig-struct)"/>
563 </xsl:call-template>
564 </xsl:variable>
565 <xsl:variable name="res">
566 @@ -1576,6 +1636,9 @@
567 </xsl:variable>
568 <xsl:copy-of select="$res"/>
569 </xsl:when>
570 + <xsl:when test="contains($versions,'NoOriginal')">
571 + <xsl:value-of select="func:gettext('NoOriginal')"/>
572 + </xsl:when>
573 </xsl:choose>
574 </xsl:otherwise>
575 </xsl:choose>
576
577
578
579 1.37 xml/htdocs/xsl/handbook.xsl
580
581 file : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/xsl/handbook.xsl?rev=1.37&view=markup
582 plain: http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/xsl/handbook.xsl?rev=1.37&content-type=text/plain
583 diff : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/xsl/handbook.xsl?r1=1.36&r2=1.37
584
585 Index: handbook.xsl
586 ===================================================================
587 RCS file: /var/cvsroot/gentoo/xml/htdocs/xsl/handbook.xsl,v
588 retrieving revision 1.36
589 retrieving revision 1.37
590 diff -u -r1.36 -r1.37
591 --- handbook.xsl 29 Aug 2007 13:22:20 -0000 1.36
592 +++ handbook.xsl 1 Jan 2008 21:29:24 -0000 1.37
593 @@ -2,7 +2,8 @@
594 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
595 xmlns:dyn="http://exslt.org/dynamic"
596 xmlns:func="http://exslt.org/functions"
597 - extension-element-prefixes="func dyn">
598 + xmlns:exslt="http://exslt.org/common"
599 + extension-element-prefixes="exslt func dyn">
600
601 <!-- Define global variables; if a user has
602 already defined those, this is a NOP -->
603 @@ -277,12 +278,11 @@
604 <xsl:variable name="FILE" select="document($doc)" />
605 <xsl:if test="$full = 0">
606 <!-- Chapter content only when rendering a single page -->
607 - <xsl:if test="$FILE/sections/section/title">
608 + <xsl:if test="count(exslt:node-set($doc-struct)//chapter)&gt;1">
609 <b><xsl:value-of select="func:gettext('Content')"/>: </b>
610 <ul>
611 - <xsl:for-each select="$FILE/sections/section[not(@test) or dyn:evaluate(@test)]/title">
612 - <xsl:variable name="pos" select="position()" />
613 - <li><a href="#doc_chap{$pos}" class="altlink"><xsl:value-of select="." /></a></li>
614 + <xsl:for-each select="exslt:node-set($doc-struct)//chapter">
615 + <li><a href="#doc_chap{position()}" class="altlink"><xsl:value-of select="@title" /></a></li>
616 </xsl:for-each>
617 </ul>
618 </xsl:if>
619 @@ -310,68 +310,4 @@
620 </xsl:if>
621 </xsl:template>
622
623 -<!-- Section inside a chapter -->
624 -<xsl:template match="/sections/section">
625 - <xsl:param name="chapnum"/>
626 - <xsl:param name="partnum"/>
627 - <xsl:param name="pos" select="position()"/>
628 - <xsl:choose>
629 - <xsl:when test="$full = 1">
630 - <!-- We need two anchors, 1 for internal links, 1 for cross-chapters links -->
631 - <a name="book_{generate-id(../..)}_chap{$pos}"/>
632 - <a name="book_part{$partnum}_chap{$chapnum}__chap{$pos}"/>
633 - </xsl:when>
634 - <xsl:otherwise>
635 - <a name="doc_chap{$pos}"/>
636 - </xsl:otherwise>
637 - </xsl:choose>
638 - <xsl:if test="@id">
639 - <a name="{@id}"/>
640 - </xsl:if>
641 - <xsl:if test="title">
642 - <p class="chaphead"><span class="chapnum"><xsl:value-of select="$chapnum" />.<xsl:number level="multiple" format="a. " value="position()" /></span><xsl:value-of select="title" /></p>
643 - </xsl:if>
644 -
645 - <xsl:choose>
646 - <xsl:when test="$full = 1">
647 - <xsl:apply-templates select="body|subsection">
648 - <xsl:with-param name="chpos" select="$pos"/>
649 - <xsl:with-param name="chapnum" select="$chapnum"/>
650 - <xsl:with-param name="partnum" select="$partnum"/>
651 - </xsl:apply-templates>
652 - </xsl:when>
653 - <xsl:otherwise>
654 - <xsl:apply-templates select="body|subsection">
655 - <xsl:with-param name="chpos" select="$pos"/>
656 - </xsl:apply-templates>
657 - </xsl:otherwise>
658 - </xsl:choose>
659 -
660 -</xsl:template>
661 -
662 -<!-- Subsubsection inside a section -->
663 -<xsl:template match="/sections/section/subsection">
664 - <xsl:param name="chapnum" />
665 - <xsl:param name="partnum" />
666 - <xsl:param name="chpos" />
667 - <xsl:variable name="pos" select="position()"/>
668 - <xsl:if test="not(@test) or dyn:evaluate(@test)">
669 - <xsl:choose>
670 - <xsl:when test="$full = 1">
671 - <!-- We need two anchors, 1 for internal links, 1 for cross-chapters links -->
672 - <a name="book_{generate-id(../../..)}_chap{$chpos}_sect{$pos}"/>
673 - <a name="book_part{$partnum}_chap{$chapnum}__chap{$chpos}_sect{$pos}"/>
674 - </xsl:when>
675 - <xsl:otherwise>
676 - <a name="doc_chap{$chpos}_sect{$pos}" />
677 - </xsl:otherwise>
678 - </xsl:choose>
679 - <xsl:if test="@id">
680 - <a name= "{@id}"/>
681 - </xsl:if>
682 - <p class="secthead"><xsl:value-of select="title" /></p>
683 - <xsl:apply-templates select="body" />
684 - </xsl:if>
685 -</xsl:template>
686 -
687 </xsl:stylesheet>
688
689
690
691 --
692 gentoo-commits@g.o mailing list