2 <xsl:stylesheet xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
3 xmlns:
date=
"http://exslt.org/dates-and-times"
4 xmlns:
exsl=
"http://exslt.org/common"
5 exclude-result-prefixes=
"date exsl"
8 <!-- ********************************************************************
9 $Id: info.xsl,v 1.1 2007/03/10 05:15:34 scott Exp $
10 ********************************************************************
12 This file is part of the XSL DocBook Stylesheet distribution.
13 See ../README or http://docbook.sf.net/release/xsl/current/ for
14 copyright and other information.
16 ******************************************************************** -->
18 <xsl:variable name=
"blurb-indent">
20 <xsl:when test=
"not($man.indent.blurbs = 0)">
21 <xsl:value-of select=
"$man.indent.width"/>
23 <xsl:when test=
"not($man.indent.refsect = 0)">
24 <!-- * "zq" is the name of a register we set for -->
25 <!-- * preserving the original default indent value -->
26 <!-- * when $man.indent.refsect is non-zero; -->
27 <!-- * "u" is a roff unit specifier -->
28 <xsl:text>\n(zqu
</xsl:text>
30 <xsl:otherwise/> <!-- * otherwise, just leave it empty -->
34 <!-- ================================================================== -->
35 <!-- * About the $info param used in this stylesheet -->
37 <!-- * The $info param is a "master info" node set that contains -->
38 <!-- * the entires contents of the *info child of the current -->
39 <!-- * Refentry, plus the entire contents of the *info children of -->
40 <!-- * all ancestors of the current Refentry, in document order. -->
42 <!-- * We try to find a "best match" for selecting content from -->
43 <!-- * $infor; we look through it in reverse document order until we -->
44 <!-- * can find something usable. -->
46 <!-- * Specifically what the basic metadata-gathering XPath expression -->
47 <!-- * in this stylesheet does is: -->
49 <!-- * 1. Look through the entire "master info" node set.-->
50 <!-- * 2. Get the last node in the set that contains, for -->
51 <!-- * example, an Author element. That amounts to being the -->
52 <!-- * closest *info node to the Refentry - either its *info -->
53 <!-- * child, or the *info node of its closest ancestor that -->
54 <!-- * contains an Author. -->
56 <!-- ================================================================== -->
57 <!-- * Get user "refentry metadata" preferences -->
58 <!-- ================================================================== -->
59 <!-- * The DocBook XSL stylesheets include several user-configurable -->
60 <!-- * global stylesheet parameters for controlling refentry metadata -->
61 <!-- * gathering. Those parameters are not read directly by the other -->
62 <!-- * refentry metadata-gathering templates. Instead, they are read -->
63 <!-- * only by the get.refentry.metadata.prefs template, which -->
64 <!-- * assembles them into a structure that is then passed to the -->
65 <!-- * other refentry metadata-gathering template. -->
67 <xsl:variable name=
"get.refentry.metadata.prefs">
68 <!-- * get.refentry.metadata.prefs is in common/refentry.xsl -->
69 <xsl:call-template name=
"get.refentry.metadata.prefs"/>
72 <xsl:variable name=
"refentry.metadata.prefs"
73 select=
"exsl:node-set($get.refentry.metadata.prefs)"/>
75 <!-- * ============================================================== -->
76 <!-- * Get content for Author metadata field. -->
77 <!-- * ============================================================== -->
79 <!-- * The make.roff.metatada.author template and metadata.author -->
80 <!-- * mode are used only for populating the Author field in the -->
81 <!-- * metadata "top comment" we embed in roff source of each page. -->
83 <xsl:template name=
"make.roff.metadata.author">
84 <xsl:param name=
"info"/>
86 <xsl:when test=
"$info//author">
88 select=
"(($info[//author])[last()]//author)[1]"
89 mode=
"metadata.author"/>
91 <xsl:when test=
"$info//corpauthor">
93 select=
"(($info[//corpauthor])[last()]//corpauthor)[1]"
94 mode=
"metadata.author"/>
96 <xsl:when test=
"$info//editor">
98 select=
"(($info[//editor])[last()]//editor)[1]"
99 mode=
"metadata.author"/>
101 <xsl:when test=
"$info//corpcredit">
103 select=
"(($info[//corpcredit])[last()]//corpcredit)[1]"
104 mode=
"metadata.author"/>
106 <xsl:when test=
"$info//othercredit">
108 select=
"(($info[//othercredit])[last()]//othercredit)[1]"
109 mode=
"metadata.author"/>
111 <xsl:when test=
"$info//collab">
113 select=
"(($info[//collab])[last()]//collab)[1]"
114 mode=
"metadata.author"/>
116 <xsl:when test=
"$info//orgname">
118 select=
"(($info[//orgname])[last()]//orgname)[1]"
119 mode=
"metadata.author"/>
121 <xsl:when test=
"$info//publishername">
123 select=
"(($info[//publishername])[last()]//publishername)[1]"
124 mode=
"metadata.author"/>
126 <xsl:otherwise/> <!-- * do nothing, no author info found -->
130 <xsl:template match=
"author|editor|othercredit|collab" mode=
"metadata.author">
132 <xsl:when test=
"collabname">
133 <!-- * If this node is a Collab, then it should have a -->
134 <!-- * Collabname child, so get that. -->
135 <xsl:variable name=
"contents">
136 <xsl:apply-templates select=
"collabname"/>
138 <xsl:value-of select=
"normalize-space($contents)"/>
141 <!-- * Otherwise, this node is not a Collab, but instead -->
142 <!-- * an author|editor|othercredit, which must have a name -->
143 <!-- * of some kind; so get that name -->
144 <xsl:call-template name=
"person.name.normalized"/>
147 <xsl:if test=
".//email|address/otheraddr/ulink">
148 <xsl:text> </xsl:text>
149 <!-- * For each attribution found, use only the first e-mail -->
150 <!-- * address or ulink value found -->
151 <xsl:apply-templates select=
"(.//email|address/otheraddr/ulink)[1]"
152 mode=
"metadata.author"/>
156 <xsl:template match=
"email|address/otheraddr/ulink" mode=
"metadata.author">
157 <xsl:text><</xsl:text>
159 <xsl:when test=
"self::email">
160 <xsl:variable name=
"contents">
161 <xsl:apply-templates/>
163 <xsl:value-of select=
"normalize-space($contents)"/>
165 <xsl:when test=
"self::ulink">
166 <xsl:variable name=
"contents">
167 <xsl:apply-templates select=
"."/>
169 <xsl:value-of select=
"normalize-space($contents)"/>
172 <xsl:text>></xsl:text>
175 <xsl:template match=
"corpauthor|corpcredit|orgname|publishername" mode=
"metadata.author">
176 <xsl:variable name=
"contents">
177 <xsl:apply-templates/>
179 <xsl:value-of select=
"normalize-space($contents)"/>
182 <!-- * ============================================================== -->
183 <!-- * Assemble the AUTHOR/AUTHORS section -->
184 <!-- * ============================================================== -->
186 <xsl:template name=
"author.section">
187 <xsl:param name=
"info"/>
188 <!-- * The $info param is a "master info" node set that contains -->
189 <!-- * the entires contents of the *info child of the current -->
190 <!-- * Refentry, plus the entire contents of the *info children of -->
191 <!-- * all ancestors of the current Refentry, in document order. -->
193 <xsl:when test=
"$info//author|$info//editor|$info//collab|
194 $info//corpauthor|$info//corpcredit|
195 $info//othercredit|$info/orgname|
196 $info/publishername|$info/publisher">
197 <xsl:variable name=
"authorcount">
200 $info//author|$info//editor|$info//collab|
201 $info//corpauthor|$info//corpcredit|
202 $info//othercredit)">
205 <xsl:text>.SH
"</xsl:text>
206 <xsl:call-template name="make.authorsecttitle
">
207 <xsl:with-param name="authorcount
" select="$authorcount
"/>
209 <!-- * Now output all the actual author, editor, etc. content -->
211 select="$info//author|$info//editor|$info//collab|
212 $info//corpauthor|$info//corpcredit|
213 $info//othercredit|$info/orgname|
214 $info/publishername|$info/publisher
">
215 <xsl:apply-templates select=".
" mode="authorsect
"/>
218 <xsl:otherwise/> <!-- * do nothing, no author info found -->
222 <xsl:template name="make.authorsecttitle
">
223 <!-- * If we have exactly one attributable person/entity, then output -->
224 <!-- * localized gentext for 'Author'; otherwise, output 'Authors'. -->
225 <xsl:param name="authorcount
"/>
226 <xsl:param name="authorsecttitle
">
228 <xsl:when test="$authorcount =
1">
229 <xsl:text>Author</xsl:text>
232 <xsl:text>Authors</xsl:text>
236 <xsl:call-template name="string.upper
">
237 <xsl:with-param name="string
">
238 <xsl:call-template name="gentext
">
239 <xsl:with-param name="key
" select="$authorsecttitle
"/>
243 <xsl:text>" </xsl:text>
246 <xsl:template match=
"author|editor|othercredit" mode=
"authorsect">
247 <xsl:variable name=
"person-name">
248 <xsl:call-template name=
"person.name.normalized"/>
250 <!-- * If we have a person-name or email or ulink content, then -->
251 <!-- * output name and email or ulink content on the same line -->
253 <xsl:when test=
"not($person-name = '') or .//email or address/otheraddr/ulink">
254 <!-- * Our mode="bold" mechanism doesn't work on text nodes; so we -->
255 <!-- * need to turn the person-name into an element node first. -->
256 <xsl:variable name=
"person-name-node">
257 <bold><xsl:value-of select=
"$person-name"/></bold>
259 <xsl:text>.PP
</xsl:text>
260 <!-- * Display person name in bold -->
261 <xsl:apply-templates mode=
"bold" select=
"exsl:node-set($person-name-node)"/>
262 <!-- * Display e-mail address(es) and ulink(s) on same line as name -->
263 <xsl:apply-templates select=
".//email|address/otheraddr/ulink" mode=
"authorsect"/>
264 <xsl:text> </xsl:text>
267 <xsl:text>.br
</xsl:text>
270 <!-- * Display affiliation(s) on separate lines -->
271 <xsl:apply-templates select=
"affiliation" mode=
"authorsect"/>
272 <!-- * Display direct-child addresses on separate lines -->
273 <xsl:apply-templates select=
"address" mode=
"authorsect"/>
274 <!-- * Call template for handling various attribution possibilities -->
275 <xsl:call-template name=
"attribution"/>
278 <xsl:template match=
"collab" mode=
"authorsect">
279 <xsl:text>.PP
</xsl:text>
280 <xsl:apply-templates mode=
"bold" select=
"collabname"/>
281 <!-- * Display e-mail address(es) and ulink(s) on same line as name -->
282 <xsl:apply-templates select=
".//email|address/otheraddr/ulink" mode=
"authorsect"/>
283 <xsl:text> </xsl:text>
284 <!-- * Display affilition(s) on separate lines -->
285 <xsl:apply-templates select=
"affiliation" mode=
"authorsect"/>
288 <xsl:template match=
"corpauthor|corpcredit|orgname|publishername" mode=
"authorsect">
289 <xsl:text>.PP
</xsl:text>
290 <xsl:apply-templates mode=
"bold" select=
"."/>
291 <xsl:text> </xsl:text>
292 <xsl:if test=
"self::publishername">
293 <!-- * Display localized "Publisher" gentext -->
294 <xsl:call-template name=
"publisher.attribution"/>
298 <xsl:template match=
"publisher" mode=
"authorsect">
299 <xsl:text>.PP
</xsl:text>
300 <xsl:apply-templates mode=
"bold" select=
"publishername"/>
301 <!-- * Display e-mail address(es) and ulink(s) on same line as name -->
302 <xsl:apply-templates select=
".//email|address/otheraddr/ulink" mode=
"authorsect"/>
303 <!-- * Display addresses on separate lines -->
304 <xsl:apply-templates select=
"address" mode=
"authorsect"/>
305 <!-- * Display localized "Publisher" literal -->
306 <xsl:call-template name=
"publisher.attribution"/>
309 <xsl:template name=
"publisher.attribution">
310 <xsl:text> </xsl:text>
311 <xsl:text>.sp -
1n
</xsl:text>
312 <xsl:text>.IP
""</xsl:text>
313 <xsl:if test=
"not($blurb-indent = '')">
314 <xsl:text> </xsl:text>
315 <xsl:value-of select=
"$blurb-indent"/>
317 <xsl:text> </xsl:text>
318 <xsl:call-template name=
"gentext">
319 <xsl:with-param name=
"key" select=
"'Publisher'"/>
321 <xsl:text>.
</xsl:text>
324 <xsl:template match=
"email|address/otheraddr/ulink" mode=
"authorsect">
326 <xsl:when test=
"preceding-sibling::*[descendant-or-self::email]
327 or preceding-sibling::address/otheraddr/ulink
328 or ancestor::address[preceding-sibling::*[descendant-or-self::email]]
329 or ancestor::address[preceding-sibling::address/otheraddr/ulink]">
330 <!-- * This is not the first instance, so do nothing. -->
333 <!-- * This is first instances of an e-mail address or ulink, -->
334 <!-- * so put a space before it. -->
335 <xsl:text> </xsl:text>
338 <!-- * Note that the reason for the \& character after the opening -->
339 <!-- * angle bracket and before the closing angle bracket is to -->
340 <!-- * prevent groff from inserting a linebreak at those points and -->
341 <!-- * outputting a hyphen character where the break occurs -->
342 <xsl:text><\
&</xsl:text>
344 <xsl:when test=
"self::email">
345 <xsl:variable name=
"contents">
346 <xsl:apply-templates/>
348 <xsl:value-of select=
"normalize-space($contents)"/>
350 <xsl:when test=
"self::ulink">
351 <xsl:variable name=
"contents">
352 <xsl:apply-templates select=
"."/>
354 <xsl:value-of select=
"normalize-space($contents)"/>
357 <xsl:text>\
&></xsl:text>
359 <xsl:when test=
"not(following-sibling::*[descendant-or-self::email]
360 or following-sibling::address/otheraddr/ulink
361 or ancestor::address[following-sibling::*[descendant-or-self::email]]
362 or ancestor::address[following-sibling::address/otheraddr/ulink])">
363 <!-- * This is the final instance, so do nothing. -->
366 <!-- * Separate multiple e-mail addresses or ulinks with a comma -->
367 <xsl:text>,
</xsl:text>
372 <xsl:template match=
"affiliation" mode=
"authorsect">
373 <!-- * Get the string value of the contents of this Affiliation. If the -->
374 <!-- * affiliation only contains an Address child whose only content is -->
375 <!-- * an email address or ulink, then these contents will end up empty. -->
376 <xsl:variable name=
"contents">
377 <xsl:apply-templates mode=
"authorsect"/>
379 <!-- * If contents are actually empty except for an email address -->
380 <!-- * or ulink, then output nothing. -->
381 <xsl:if test=
"$contents != ''">
382 <xsl:text>.br
</xsl:text>
383 <xsl:for-each select=
"shortaffil|jobtitle|orgname|orgdiv|address">
384 <!-- * only display output of nodes other than email or ulink -->
385 <xsl:apply-templates select=
"node()[not(self::email) and not(self::otheraddr/ulink)]"/>
387 <xsl:when test=
"position() = last()"/> <!-- do nothing -->
389 <!-- * only add comma if the node has a child node other than -->
390 <!-- * an email address or ulink -->
391 <xsl:if test=
"child::node()[not(self::email) and not(self::otheraddr/ulink)]">
392 <xsl:text>,
</xsl:text>
397 <xsl:text> </xsl:text>
399 <xsl:when test=
"position() = last()"/> <!-- do nothing -->
401 <!-- * put a line break after every Affiliation instance except -->
402 <!-- * the last one in the set -->
403 <xsl:text>.br
</xsl:text>
409 <xsl:template match=
"address" mode=
"authorsect">
410 <xsl:variable name=
"contents"
411 select=
"normalize-space(node()[not(self::email)
412 and not(self::otheraddr/ulink)])"/>
413 <!-- * If this contents of this Address do not contain anything except -->
414 <!-- * an email address or ulink, then output nothing. -->
415 <xsl:if test=
"$contents != ''">
416 <xsl:text> </xsl:text>
417 <xsl:text>.br
</xsl:text>
418 <!--* Skip email and ulink descendants of Address (rendered elsewhere) -->
419 <xsl:apply-templates select=
"node()[not(self::email) and not(self::otheraddr/ulink)]"/>
423 <xsl:template name=
"attribution">
424 <!-- * Determine appropriate attribution for a particular person's role. -->
426 <!-- * if we have a *blurb or contrib, just use that -->
427 <xsl:when test=
"contrib|personblurb|authorblurb">
428 <xsl:apply-templates select=
"contrib|personblurb|authorblurb" mode=
"authorsect"/>
429 <xsl:text> </xsl:text>
431 <!-- * If we have no *blurb or contrib, but this is an Author or -->
432 <!-- * Editor, then render the corresponding localized gentext -->
433 <xsl:when test=
"self::author">
434 <xsl:text> </xsl:text>
435 <xsl:text>.sp -
1n
</xsl:text>
436 <xsl:text>.IP
""</xsl:text>
437 <xsl:if test=
"not($blurb-indent = '')">
438 <xsl:text> </xsl:text>
439 <xsl:value-of select=
"$blurb-indent"/>
441 <xsl:text> </xsl:text>
442 <xsl:call-template name=
"gentext">
443 <xsl:with-param name=
"key" select=
"'Author'"/>
445 <xsl:text>.
</xsl:text>
447 <xsl:when test=
"self::editor">
448 <xsl:text> </xsl:text>
449 <xsl:text>.sp -
1n
</xsl:text>
450 <xsl:text>.IP
""</xsl:text>
451 <xsl:if test=
"not($blurb-indent = '')">
452 <xsl:text> </xsl:text>
453 <xsl:value-of select=
"$blurb-indent"/>
455 <xsl:text> </xsl:text>
456 <xsl:call-template name=
"gentext">
457 <xsl:with-param name=
"key" select=
"'Editor'"/>
459 <xsl:text>.
</xsl:text>
461 <!-- * If we have no *blurb or contrib, but this is an Othercredit, -->
462 <!-- * check value of Class attribute and use corresponding gentext. -->
463 <xsl:when test=
"self::othercredit">
465 <xsl:when test=
"@class and @class != 'other'">
466 <xsl:text> </xsl:text>
467 <xsl:text>.sp -
1n
</xsl:text>
468 <xsl:text>.IP
""</xsl:text>
469 <xsl:if test=
"not($blurb-indent = '')">
470 <xsl:text> </xsl:text>
471 <xsl:value-of select=
"$blurb-indent"/>
473 <xsl:text> </xsl:text>
474 <xsl:call-template name=
"gentext">
475 <xsl:with-param name=
"key" select=
"@class"/>
477 <xsl:text>.
</xsl:text>
480 <!-- * We have an Othercredit, but not usable value for the Class -->
481 <!-- * attribute, so nothing to show, do nothing -->
486 <!-- * We have no *blurb or contrib or anything else we can use to -->
487 <!-- * display appropriate attribution for this person, so do nothing -->
492 <xsl:template match=
"personblurb|authorblurb" mode=
"authorsect">
493 <xsl:call-template name=
"mark.up.blurb.or.contrib"/>
494 <!-- * yeah, it's possible for a *blurb to have a "title" -->
495 <xsl:apply-templates select=
"title"/>
496 <xsl:apply-templates select=
"*[not(self::title)]"/>
499 <xsl:template match=
"personblurb/title|authorblurb/title">
500 <!-- * always render period after title -->
501 <xsl:variable name=
"contents">
502 <xsl:apply-templates/>
504 <xsl:value-of select=
"normalize-space($contents)"/>
505 <xsl:text>.
</xsl:text>
506 <!-- * render space after Title+period if the title is followed -->
507 <!-- * by something element content -->
508 <xsl:if test=
"following-sibling::*[name() != '']">
509 <xsl:text> </xsl:text>
513 <xsl:template match=
"contrib" mode=
"authorsect">
514 <xsl:call-template name=
"mark.up.blurb.or.contrib"/>
515 <xsl:variable name=
"contents">
516 <xsl:apply-templates/>
518 <xsl:value-of select=
"normalize-space($contents)"/>
519 <xsl:text> </xsl:text>
522 <xsl:template name=
"mark.up.blurb.or.contrib">
524 <!-- * If this *blurb has a sibling "name" element of some kind, then -->
525 <!-- * we are already outputting the name content, and we need to -->
526 <!-- * indent the *blurb content after that. -->
528 test=
"../personname|../surname|../firstname
529 |../othername|../lineage|../honorific
530 |../affiliation|../email|../address">
531 <xsl:text> </xsl:text>
532 <xsl:text>.sp -
1n
</xsl:text>
533 <xsl:text>.IP
""</xsl:text>
534 <xsl:if test=
"not($blurb-indent = '')">
535 <xsl:text> </xsl:text>
536 <xsl:value-of select=
"$blurb-indent"/>
540 <!-- * otherwise, we have no "name" content, so don't indent; -->
541 <!-- * instead, decide if we need a .PP or just a .br -->
543 <xsl:when test=
"not(preceding-sibling::*)">
544 <!-- * if this *blurb or contrib has no preceding -->
545 <!-- * siblings, then we need to start a new paragraph -->
546 <xsl:text>.PP
</xsl:text>
549 <!-- * otherwise, this has no preceding siblings, so -->
550 <!-- * just put a linebreak -->
551 <xsl:text>.br
</xsl:text>
556 <xsl:text> </xsl:text>
559 <!-- * ============================================================== -->
560 <!-- * Assemble the COPYRIGHT section -->
561 <!-- * ============================================================== -->
562 <!-- * The COPYRIGHT section is output only if a copyright or -->
563 <!-- * legalnotice is found. It contains the copyright contents -->
564 <!-- * followed by the legalnotice contents. -->
565 <xsl:template name=
"copyright.section">
566 <xsl:param name=
"info"/>
568 <xsl:when test=
"$info//copyright|$info//legalnotice">
569 <xsl:text>.SH
"</xsl:text>
570 <xsl:call-template name="string.upper
">
571 <xsl:with-param name="string
">
572 <xsl:call-template name="gentext
">
573 <xsl:with-param name="key
">Copyright</xsl:with-param>
577 <xsl:text>" </xsl:text>
578 <!-- * the copyright mode="titlepage.mode" template is -->
579 <!-- * imported from the HTML stylesheets -->
580 <xsl:for-each select=
"(($info[//copyright])[last()]//copyright)">
581 <xsl:variable name=
"contents">
582 <xsl:apply-templates select=
"." mode=
"titlepage.mode"/>
584 <xsl:value-of select=
"normalize-space($contents)"/>
585 <xsl:text> </xsl:text>
586 <xsl:text>.br
</xsl:text>
588 <xsl:text> </xsl:text>
589 <xsl:for-each select=
"(($info[//legalnotice])[last()]//legalnotice)">
590 <xsl:apply-templates select=
"." mode=
"titlepage.mode"/>
591 <xsl:text> </xsl:text>
592 <xsl:text>.br
</xsl:text>
595 <xsl:otherwise/> <!-- * do nothing, no copyright or legalnotice found -->
599 <xsl:template match=
"legalnotice">
600 <xsl:apply-templates/>
603 <!-- * ============================================================== -->
605 <!-- * suppress refmeta and all *info (we grab what we need from them -->
606 <!-- * elsewhere) -->
608 <xsl:template match=
"refmeta"/>
610 <xsl:template match=
"info|refentryinfo|referenceinfo|refsynopsisdivinfo
611 |refsectioninfo|refsect1info|refsect2info|refsect3info
612 |setinfo|bookinfo|articleinfo|chapterinfo|sectioninfo
613 |sect1info|sect2info|sect3info|sect4info|sect5info
614 |partinfo|prefaceinfo|appendixinfo|docinfo"/>
616 <!-- ============================================================== -->