common.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. <?xml version="1.0"?>
  2. <reference xml:id="base">
  3. <info>
  4. <title>Common » Base Template Reference</title>
  5. <releaseinfo role="meta">
  6. $Id: common.xsl 9347 2012-05-11 03:49:49Z bobstayton $
  7. </releaseinfo>
  8. </info>
  9. <partintro xml:id="partintro">
  10. <title>Introduction</title>
  11. <para>This is technical reference documentation for the “base”
  12. set of common templates in the DocBook XSL Stylesheets.</para>
  13. <para>This is not intended to be user documentation. It is
  14. provided for developers writing customization layers for the
  15. stylesheets.</para>
  16. </partintro>
  17. <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.is.component">
  18. <refnamediv>
  19. <refname>is.component</refname>
  20. <refpurpose>Tests if a given node is a component-level element</refpurpose>
  21. </refnamediv>
  22. <refsynopsisdiv>
  23. <synopsis>&lt;xsl:template name="is.component"&gt;
  24. &lt;xsl:param name="node" select="."/&gt;
  25. ...
  26. &lt;/xsl:template&gt;</synopsis>
  27. </refsynopsisdiv>
  28. <refsect1><title>Description</title>
  29. <para>This template returns '1' if the specified node is a component
  30. (Chapter, Appendix, etc.), and '0' otherwise.</para>
  31. </refsect1><refsect1><title>Parameters</title>
  32. <variablelist>
  33. <varlistentry><term>node</term>
  34. <listitem>
  35. <para>The node which is to be tested.</para>
  36. </listitem>
  37. </varlistentry>
  38. </variablelist>
  39. </refsect1><refsect1><title>Returns</title>
  40. <para>This template returns '1' if the specified node is a component
  41. (Chapter, Appendix, etc.), and '0' otherwise.</para>
  42. </refsect1></refentry>
  43. <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.is.section">
  44. <refnamediv>
  45. <refname>is.section</refname>
  46. <refpurpose>Tests if a given node is a section-level element</refpurpose>
  47. </refnamediv>
  48. <refsynopsisdiv>
  49. <synopsis>&lt;xsl:template name="is.section"&gt;
  50. &lt;xsl:param name="node" select="."/&gt;
  51. ...
  52. &lt;/xsl:template&gt;</synopsis>
  53. </refsynopsisdiv>
  54. <refsect1><title>Description</title>
  55. <para>This template returns '1' if the specified node is a section
  56. (Section, Sect1, Sect2, etc.), and '0' otherwise.</para>
  57. </refsect1><refsect1><title>Parameters</title>
  58. <variablelist>
  59. <varlistentry><term>node</term>
  60. <listitem>
  61. <para>The node which is to be tested.</para>
  62. </listitem>
  63. </varlistentry>
  64. </variablelist>
  65. </refsect1><refsect1><title>Returns</title>
  66. <para>This template returns '1' if the specified node is a section
  67. (Section, Sect1, Sect2, etc.), and '0' otherwise.</para>
  68. </refsect1></refentry>
  69. <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.section.level">
  70. <refnamediv>
  71. <refname>section.level</refname>
  72. <refpurpose>Returns the hierarchical level of a section</refpurpose>
  73. </refnamediv>
  74. <refsynopsisdiv>
  75. <synopsis>&lt;xsl:template name="section.level"&gt;
  76. &lt;xsl:param name="node" select="."/&gt;
  77. ...
  78. &lt;/xsl:template&gt;</synopsis>
  79. </refsynopsisdiv>
  80. <refsect1><title>Description</title>
  81. <para>This template calculates the hierarchical level of a section.
  82. The element <tag>sect1</tag> is at level 1, <tag>sect2</tag> is
  83. at level 2, etc.</para>
  84. <para>Recursive sections are calculated down to the fifth level.</para>
  85. </refsect1><refsect1><title>Parameters</title>
  86. <variablelist>
  87. <varlistentry><term>node</term>
  88. <listitem>
  89. <para>The section node for which the level should be calculated.
  90. Defaults to the context node.</para>
  91. </listitem>
  92. </varlistentry>
  93. </variablelist>
  94. </refsect1><refsect1><title>Returns</title>
  95. <para>The section level, <quote>1</quote>, <quote>2</quote>, etc.
  96. </para>
  97. </refsect1></refentry>
  98. <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.qanda.section.level">
  99. <refnamediv>
  100. <refname>qanda.section.level</refname>
  101. <refpurpose>Returns the hierarchical level of a QandASet</refpurpose>
  102. </refnamediv>
  103. <refsynopsisdiv>
  104. <synopsis>&lt;xsl:template name="qanda.section.level"/&gt;</synopsis>
  105. </refsynopsisdiv>
  106. <refsect1><title>Description</title>
  107. <para>This template calculates the hierarchical level of a QandASet.
  108. </para>
  109. </refsect1><refsect1><title>Returns</title>
  110. <para>The level, <quote>1</quote>, <quote>2</quote>, etc.
  111. </para>
  112. </refsect1></refentry>
  113. <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.select.mediaobject">
  114. <refnamediv>
  115. <refname>select.mediaobject</refname>
  116. <refpurpose>Selects and processes an appropriate media object from a list</refpurpose>
  117. </refnamediv>
  118. <refsynopsisdiv>
  119. <synopsis>&lt;xsl:template name="select.mediaobject"&gt;
  120. &lt;xsl:param name="olist" select="imageobject|imageobjectco |videoobject|audioobject|textobject"/&gt;
  121. ...
  122. &lt;/xsl:template&gt;</synopsis>
  123. </refsynopsisdiv>
  124. <refsect1><title>Description</title>
  125. <para>This template takes a list of media objects (usually the
  126. children of a mediaobject or inlinemediaobject) and processes
  127. the "right" object.</para>
  128. <para>This template relies on a template named
  129. "select.mediaobject.index" to determine which object
  130. in the list is appropriate.</para>
  131. <para>If no acceptable object is located, nothing happens.</para>
  132. </refsect1><refsect1><title>Parameters</title>
  133. <variablelist>
  134. <varlistentry><term>olist</term>
  135. <listitem>
  136. <para>The node list of potential objects to examine.</para>
  137. </listitem>
  138. </varlistentry>
  139. </variablelist>
  140. </refsect1><refsect1><title>Returns</title>
  141. <para>Calls &lt;xsl:apply-templates&gt; on the selected object.</para>
  142. </refsect1></refentry>
  143. <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.select.mediaobject.index">
  144. <refnamediv>
  145. <refname>select.mediaobject.index</refname>
  146. <refpurpose>Selects the position of the appropriate media object from a list</refpurpose>
  147. </refnamediv>
  148. <refsynopsisdiv>
  149. <synopsis>&lt;xsl:template name="select.mediaobject.index"&gt;
  150. &lt;xsl:param name="olist" select="imageobject|imageobjectco |videoobject|audioobject|textobject"/&gt;
  151. &lt;xsl:param name="count"&gt;1&lt;/xsl:param&gt;
  152. ...
  153. &lt;/xsl:template&gt;</synopsis>
  154. </refsynopsisdiv>
  155. <refsect1><title>Description</title>
  156. <para>This template takes a list of media objects (usually the
  157. children of a mediaobject or inlinemediaobject) and determines
  158. the "right" object. It returns the position of that object
  159. to be used by the calling template.</para>
  160. <para>If the parameter <parameter>use.role.for.mediaobject</parameter>
  161. is nonzero, then it first checks for an object with
  162. a role attribute of the appropriate value. It takes the first
  163. of those. Otherwise, it takes the first acceptable object
  164. through a recursive pass through the list.</para>
  165. <para>This template relies on a template named "is.acceptable.mediaobject"
  166. to determine if a given object is an acceptable graphic. The semantics
  167. of media objects is that the first acceptable graphic should be used.
  168. </para>
  169. <para>If no acceptable object is located, no index is returned.</para>
  170. </refsect1><refsect1><title>Parameters</title>
  171. <variablelist>
  172. <varlistentry><term>olist</term>
  173. <listitem>
  174. <para>The node list of potential objects to examine.</para>
  175. </listitem>
  176. </varlistentry>
  177. <varlistentry><term>count</term>
  178. <listitem>
  179. <para>The position in the list currently being considered by the
  180. recursive process.</para>
  181. </listitem>
  182. </varlistentry>
  183. </variablelist>
  184. </refsect1><refsect1><title>Returns</title>
  185. <para>Returns the position in the original list of the selected object.</para>
  186. </refsect1></refentry>
  187. <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.is.acceptable.mediaobject">
  188. <refnamediv>
  189. <refname>is.acceptable.mediaobject</refname>
  190. <refpurpose>Returns '1' if the specified media object is recognized</refpurpose>
  191. </refnamediv>
  192. <refsynopsisdiv>
  193. <synopsis>&lt;xsl:template name="is.acceptable.mediaobject"&gt;
  194. &lt;xsl:param name="object"/&gt;
  195. ...
  196. &lt;/xsl:template&gt;</synopsis>
  197. </refsynopsisdiv>
  198. <refsect1><title>Description</title>
  199. <para>This template examines a media object and returns '1' if the
  200. object is recognized as a graphic.</para>
  201. </refsect1><refsect1><title>Parameters</title>
  202. <variablelist>
  203. <varlistentry><term>object</term>
  204. <listitem>
  205. <para>The media object to consider.</para>
  206. </listitem>
  207. </varlistentry>
  208. </variablelist>
  209. </refsect1><refsect1><title>Returns</title>
  210. <para>0 or 1</para>
  211. </refsect1></refentry>
  212. <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.check.id.unique">
  213. <refnamediv>
  214. <refname>check.id.unique</refname>
  215. <refpurpose>Warn users about references to non-unique IDs</refpurpose>
  216. </refnamediv>
  217. <refsynopsisdiv>
  218. <synopsis>&lt;xsl:template name="check.id.unique"&gt;
  219. &lt;xsl:param name="linkend"/&gt;
  220. ...
  221. &lt;/xsl:template&gt;</synopsis>
  222. </refsynopsisdiv>
  223. <refsect1><title>Description</title>
  224. <para>If passed an ID in <varname>linkend</varname>,
  225. <function>check.id.unique</function> prints
  226. a warning message to the user if either the ID does not exist or
  227. the ID is not unique.</para>
  228. </refsect1></refentry>
  229. <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.check.idref.targets">
  230. <refnamediv>
  231. <refname>check.idref.targets</refname>
  232. <refpurpose>Warn users about incorrectly typed references</refpurpose>
  233. </refnamediv>
  234. <refsynopsisdiv>
  235. <synopsis>&lt;xsl:template name="check.idref.targets"&gt;
  236. &lt;xsl:param name="linkend"/&gt;
  237. &lt;xsl:param name="element-list"/&gt;
  238. ...
  239. &lt;/xsl:template&gt;</synopsis>
  240. </refsynopsisdiv>
  241. <refsect1><title>Description</title>
  242. <para>If passed an ID in <varname>linkend</varname>,
  243. <function>check.idref.targets</function> makes sure that the element
  244. pointed to by the link is one of the elements listed in
  245. <varname>element-list</varname> and warns the user otherwise.</para>
  246. </refsect1></refentry>
  247. <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.copyright.years">
  248. <refnamediv>
  249. <refname>copyright.years</refname>
  250. <refpurpose>Print a set of years with collapsed ranges</refpurpose>
  251. </refnamediv>
  252. <refsynopsisdiv>
  253. <synopsis>&lt;xsl:template name="copyright.years"&gt;
  254. &lt;xsl:param name="years"/&gt;
  255. &lt;xsl:param name="print.ranges" select="1"/&gt;
  256. &lt;xsl:param name="single.year.ranges" select="0"/&gt;
  257. &lt;xsl:param name="firstyear" select="0"/&gt;
  258. &lt;xsl:param name="nextyear" select="0"/&gt;
  259. ...
  260. &lt;/xsl:template&gt;</synopsis>
  261. </refsynopsisdiv>
  262. <refsect1><title>Description</title>
  263. <para>This template prints a list of year elements with consecutive
  264. years printed as a range. In other words:</para>
  265. <screen>&lt;year&gt;1992&lt;/year&gt;
  266. &lt;year&gt;1993&lt;/year&gt;
  267. &lt;year&gt;1994&lt;/year&gt;</screen>
  268. <para>is printed <quote>1992-1994</quote>, whereas:</para>
  269. <screen>&lt;year&gt;1992&lt;/year&gt;
  270. &lt;year&gt;1994&lt;/year&gt;</screen>
  271. <para>is printed <quote>1992, 1994</quote>.</para>
  272. <para>This template assumes that all the year elements contain only
  273. decimal year numbers, that the elements are sorted in increasing
  274. numerical order, that there are no duplicates, and that all the years
  275. are expressed in full <quote>century+year</quote>
  276. (<quote>1999</quote> not <quote>99</quote>) notation.</para>
  277. </refsect1><refsect1><title>Parameters</title>
  278. <variablelist>
  279. <varlistentry><term>years</term>
  280. <listitem>
  281. <para>The initial set of year elements.</para>
  282. </listitem>
  283. </varlistentry>
  284. <varlistentry><term>print.ranges</term>
  285. <listitem>
  286. <para>If non-zero, multi-year ranges are collapsed. If zero, all years
  287. are printed discretely.</para>
  288. </listitem>
  289. </varlistentry>
  290. <varlistentry><term>single.year.ranges</term>
  291. <listitem>
  292. <para>If non-zero, two consecutive years will be printed as a range,
  293. otherwise, they will be printed discretely. In other words, a single
  294. year range is <quote>1991-1992</quote> but discretely it's
  295. <quote>1991, 1992</quote>.</para>
  296. </listitem>
  297. </varlistentry>
  298. </variablelist>
  299. </refsect1><refsect1><title>Returns</title>
  300. <para>This template returns the formatted list of years.</para>
  301. </refsect1></refentry>
  302. <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.find.path.params">
  303. <refnamediv>
  304. <refname>find.path.params</refname>
  305. <refpurpose>Search in a table for the "best" match for the node</refpurpose>
  306. </refnamediv>
  307. <refsynopsisdiv>
  308. <synopsis>&lt;xsl:template name="find.path.params"&gt;
  309. &lt;xsl:param name="node" select="."/&gt;
  310. &lt;xsl:param name="table" select="''"/&gt;
  311. &lt;xsl:param name="location"&gt;
  312. &lt;xsl:call-template name="xpath.location"&gt;
  313. &lt;xsl:with-param name="node" select="$node"/&gt;
  314. &lt;/xsl:call-template&gt;
  315. &lt;/xsl:param&gt;
  316. ...
  317. &lt;/xsl:template&gt;</synopsis>
  318. </refsynopsisdiv>
  319. <refsect1><title>Description</title>
  320. <para>This template searches in a table for the value that most-closely
  321. (in the typical best-match sense of XSLT) matches the current (element)
  322. node location.</para>
  323. </refsect1></refentry>
  324. <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.string.upper">
  325. <refnamediv>
  326. <refname>string.upper</refname>
  327. <refpurpose>Converts a string to all uppercase letters</refpurpose>
  328. </refnamediv>
  329. <refsynopsisdiv>
  330. <synopsis>&lt;xsl:template name="string.upper"&gt;
  331. &lt;xsl:param name="string" select="''"/&gt;
  332. ...
  333. &lt;/xsl:template&gt;</synopsis>
  334. </refsynopsisdiv>
  335. <refsect1><title>Description</title>
  336. <para>Given a string, this template does a language-aware conversion
  337. of that string to all uppercase letters, based on the values of the
  338. <literal>lowercase.alpha</literal> and
  339. <literal>uppercase.alpha</literal> gentext keys for the current
  340. locale. It affects only those characters found in the values of
  341. <literal>lowercase.alpha</literal> and
  342. <literal>uppercase.alpha</literal>. All other characters are left
  343. unchanged.</para>
  344. </refsect1><refsect1><title>Parameters</title>
  345. <variablelist>
  346. <varlistentry><term>string</term>
  347. <listitem>
  348. <para>The string to convert to uppercase.</para>
  349. </listitem>
  350. </varlistentry>
  351. </variablelist>
  352. </refsect1></refentry>
  353. <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.string.lower">
  354. <refnamediv>
  355. <refname>string.lower</refname>
  356. <refpurpose>Converts a string to all lowercase letters</refpurpose>
  357. </refnamediv>
  358. <refsynopsisdiv>
  359. <synopsis>&lt;xsl:template name="string.lower"&gt;
  360. &lt;xsl:param name="string" select="''"/&gt;
  361. ...
  362. &lt;/xsl:template&gt;</synopsis>
  363. </refsynopsisdiv>
  364. <refsect1><title>Description</title>
  365. <para>Given a string, this template does a language-aware conversion
  366. of that string to all lowercase letters, based on the values of the
  367. <literal>uppercase.alpha</literal> and
  368. <literal>lowercase.alpha</literal> gentext keys for the current
  369. locale. It affects only those characters found in the values of
  370. <literal>uppercase.alpha</literal> and
  371. <literal>lowercase.alpha</literal>. All other characters are left
  372. unchanged.</para>
  373. </refsect1><refsect1><title>Parameters</title>
  374. <variablelist>
  375. <varlistentry><term>string</term>
  376. <listitem>
  377. <para>The string to convert to lowercase.</para>
  378. </listitem>
  379. </varlistentry>
  380. </variablelist>
  381. </refsect1></refentry>
  382. <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.select.choice.separator">
  383. <refnamediv>
  384. <refname>select.choice.separator</refname>
  385. <refpurpose>Returns localized choice separator</refpurpose>
  386. </refnamediv>
  387. <refsynopsisdiv>
  388. <synopsis>&lt;xsl:template name="select.choice.separator"/&gt;</synopsis>
  389. </refsynopsisdiv>
  390. <refsect1><title>Description</title>
  391. <para>This template enables auto-generation of an appropriate
  392. localized "choice" separator (for example, "and" or "or") before
  393. the final item in an inline list (though it could also be useful
  394. for generating choice separators for non-inline lists).</para>
  395. <para>It currently works by evaluating a processing instruction
  396. (PI) of the form &lt;?dbchoice choice="foo"?&gt; :
  397. <itemizedlist>
  398. <listitem>
  399. <simpara>if the value of the <tag>choice</tag>
  400. pseudo-attribute is "and" or "or", returns a localized "and"
  401. or "or"</simpara>
  402. </listitem>
  403. <listitem>
  404. <simpara>otherwise returns the literal value of the
  405. <tag>choice</tag> pseudo-attribute</simpara>
  406. </listitem>
  407. </itemizedlist>
  408. The latter is provided only as a temporary workaround because the
  409. locale files do not currently have translations for the word
  410. <wordasword>or</wordasword>. So if you want to generate a a
  411. logical "or" separator in French (for example), you currently need
  412. to do this:
  413. <literallayout>&lt;?dbchoice choice="ou"?&gt;</literallayout>
  414. </para>
  415. <warning>
  416. <para>The <tag>dbchoice</tag> processing instruction is
  417. an unfortunate hack; support for it may disappear in the future
  418. (particularly if and when a more appropriate means for marking
  419. up "choice" lists becomes available in DocBook).</para>
  420. </warning>
  421. </refsect1></refentry>
  422. <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.evaluate.info.profile">
  423. <refnamediv>
  424. <refname>evaluate.info.profile</refname>
  425. <refpurpose>Evaluates an info profile</refpurpose>
  426. </refnamediv>
  427. <refsynopsisdiv>
  428. <synopsis>&lt;xsl:template name="evaluate.info.profile"&gt;
  429. &lt;xsl:param name="profile"/&gt;
  430. &lt;xsl:param name="info"/&gt;
  431. ...
  432. &lt;/xsl:template&gt;</synopsis>
  433. </refsynopsisdiv>
  434. <refsect1><title>Description</title>
  435. <para>This template evaluates an "info profile" matching the XPath
  436. expression given by the <parameter>profile</parameter>
  437. parameter. It relies on the XSLT <function>evaluate()</function>
  438. extension function.</para>
  439. <para>The value of the <parameter>profile</parameter> parameter
  440. can include the literal string <literal>$info</literal>. If found
  441. in the value of the <parameter>profile</parameter> parameter, the
  442. literal string <literal>$info</literal> string is replaced with
  443. the value of the <parameter>info</parameter> parameter, which
  444. should be a set of <replaceable>*info</replaceable> nodes; the
  445. expression is then evaluated using the XSLT
  446. <function>evaluate()</function> extension function.</para>
  447. </refsect1><refsect1><title>Parameters</title>
  448. <variablelist>
  449. <varlistentry>
  450. <term>profile</term>
  451. <listitem>
  452. <para>A string representing an XPath expression </para>
  453. </listitem>
  454. </varlistentry>
  455. <varlistentry>
  456. <term>info</term>
  457. <listitem>
  458. <para>A set of *info nodes</para>
  459. </listitem>
  460. </varlistentry>
  461. </variablelist>
  462. </refsect1><refsect1><title>Returns</title>
  463. <para>Returns a node (the result of evaluating the
  464. <parameter>profile</parameter> parameter)</para>
  465. </refsect1></refentry>
  466. <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.graphic.format.content-type">
  467. <refnamediv>
  468. <refname>graphic.format.content-type</refname>
  469. <refpurpose>Returns mimetype for media format</refpurpose>
  470. </refnamediv>
  471. <refsynopsisdiv>
  472. <synopsis>&lt;xsl:template name="graphic.format.content-type"&gt;
  473. &lt;xsl:param name="format"/&gt;
  474. ...
  475. &lt;/xsl:template&gt;</synopsis>
  476. </refsynopsisdiv>
  477. <refsect1><title>Description</title>
  478. <para>This takes as input a 'format' param and returns
  479. a mimetype string. It uses an xsl:choose after first
  480. converting the input to all uppercase.</para>
  481. </refsect1></refentry>
  482. </reference>