html.xsl 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <?xml version="1.0" encoding="ASCII"?>
  2. <!--This file was created automatically by html2xhtml-->
  3. <!--from the HTML stylesheets.-->
  4. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0">
  5. <!-- ********************************************************************
  6. $Id$
  7. ********************************************************************
  8. This file is part of the XSL DocBook Stylesheet distribution.
  9. See ../README or http://docbook.sf.net/release/xsl/current/ for
  10. copyright and other information.
  11. ******************************************************************** -->
  12. <!-- The generate.html.title template is currently used for generating HTML -->
  13. <!-- "title" attributes for some inline elements only, but not for any -->
  14. <!-- block elements. It is called in eleven places in the inline.xsl -->
  15. <!-- file. But it's called by all the inline.* templates (e.g., -->
  16. <!-- inline.boldseq), which in turn are called by other (element) -->
  17. <!-- templates, so it results, currently, in supporting generation of the -->
  18. <!-- HTML "title" attribute for a total of about 92 elements. -->
  19. <!-- You can use mode="html.title.attribute" to get a title for -->
  20. <!-- an element specified by a param, including targets of cross references. -->
  21. <xsl:template name="generate.html.title">
  22. <xsl:apply-templates select="." mode="html.title.attribute"/>
  23. </xsl:template>
  24. <!-- Generate a title attribute for the context node -->
  25. <xsl:template match="*" mode="html.title.attribute">
  26. <xsl:variable name="is.title">
  27. <xsl:call-template name="gentext.template.exists">
  28. <xsl:with-param name="context" select="'title'"/>
  29. <xsl:with-param name="name" select="local-name(.)"/>
  30. <xsl:with-param name="lang">
  31. <xsl:call-template name="l10n.language"/>
  32. </xsl:with-param>
  33. </xsl:call-template>
  34. </xsl:variable>
  35. <xsl:variable name="is.title-numbered">
  36. <xsl:call-template name="gentext.template.exists">
  37. <xsl:with-param name="context" select="'title-numbered'"/>
  38. <xsl:with-param name="name" select="local-name(.)"/>
  39. <xsl:with-param name="lang">
  40. <xsl:call-template name="l10n.language"/>
  41. </xsl:with-param>
  42. </xsl:call-template>
  43. </xsl:variable>
  44. <xsl:variable name="is.title-unnumbered">
  45. <xsl:call-template name="gentext.template.exists">
  46. <xsl:with-param name="context" select="'title-unnumbered'"/>
  47. <xsl:with-param name="name" select="local-name(.)"/>
  48. <xsl:with-param name="lang">
  49. <xsl:call-template name="l10n.language"/>
  50. </xsl:with-param>
  51. </xsl:call-template>
  52. </xsl:variable>
  53. <xsl:variable name="gentext.title">
  54. <xsl:if test="$is.title != 0 or $is.title-numbered != 0 or $is.title-unnumbered != 0">
  55. <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
  56. </xsl:if>
  57. </xsl:variable>
  58. <xsl:choose>
  59. <xsl:when test="string-length($gentext.title) != 0">
  60. <xsl:attribute name="title">
  61. <xsl:value-of select="$gentext.title"/>
  62. </xsl:attribute>
  63. </xsl:when>
  64. <!-- Fall back to alt if available -->
  65. <xsl:when test="alt">
  66. <xsl:attribute name="title">
  67. <xsl:value-of select="normalize-space(alt)"/>
  68. </xsl:attribute>
  69. </xsl:when>
  70. </xsl:choose>
  71. </xsl:template>
  72. <xsl:template name="dir">
  73. <xsl:param name="inherit" select="0"/>
  74. <xsl:variable name="dir">
  75. <xsl:choose>
  76. <xsl:when test="@dir">
  77. <xsl:value-of select="@dir"/>
  78. </xsl:when>
  79. <xsl:when test="$inherit != 0">
  80. <xsl:value-of select="ancestor::*/@dir[1]"/>
  81. </xsl:when>
  82. </xsl:choose>
  83. </xsl:variable>
  84. <xsl:if test="$dir != ''">
  85. <xsl:attribute name="dir">
  86. <xsl:value-of select="$dir"/>
  87. </xsl:attribute>
  88. </xsl:if>
  89. </xsl:template>
  90. <xsl:template name="anchor">
  91. <xsl:param name="node" select="."/>
  92. <xsl:param name="conditional" select="1"/>
  93. <xsl:variable name="id">
  94. <xsl:call-template name="object.id">
  95. <xsl:with-param name="object" select="$node"/>
  96. </xsl:call-template>
  97. </xsl:variable>
  98. <xsl:if test="$conditional = 0 or $node/@id or $node/@xml:id">
  99. <a id="{$id}"/>
  100. </xsl:if>
  101. </xsl:template>
  102. <xsl:template name="href.target.uri">
  103. <xsl:param name="context" select="."/>
  104. <xsl:param name="object" select="."/>
  105. <xsl:text>#</xsl:text>
  106. <xsl:call-template name="object.id">
  107. <xsl:with-param name="object" select="$object"/>
  108. </xsl:call-template>
  109. </xsl:template>
  110. <xsl:template name="href.target">
  111. <xsl:param name="context" select="."/>
  112. <xsl:param name="object" select="."/>
  113. <xsl:text>#</xsl:text>
  114. <xsl:call-template name="object.id">
  115. <xsl:with-param name="object" select="$object"/>
  116. </xsl:call-template>
  117. </xsl:template>
  118. <xsl:template name="href.target.with.base.dir">
  119. <xsl:param name="context" select="."/>
  120. <xsl:param name="object" select="."/>
  121. <xsl:if test="$manifest.in.base.dir = 0">
  122. <xsl:value-of select="$base.dir"/>
  123. </xsl:if>
  124. <xsl:call-template name="href.target">
  125. <xsl:with-param name="context" select="$context"/>
  126. <xsl:with-param name="object" select="$object"/>
  127. </xsl:call-template>
  128. </xsl:template>
  129. <xsl:template name="dingbat">
  130. <xsl:param name="dingbat">bullet</xsl:param>
  131. <xsl:call-template name="dingbat.characters">
  132. <xsl:with-param name="dingbat" select="$dingbat"/>
  133. </xsl:call-template>
  134. </xsl:template>
  135. <xsl:template name="dingbat.characters">
  136. <!-- now that I'm using the real serializer, all that dingbat malarky -->
  137. <!-- isn't necessary anymore... -->
  138. <xsl:param name="dingbat">bullet</xsl:param>
  139. <xsl:choose>
  140. <xsl:when test="$dingbat='bullet'">&#8226;</xsl:when>
  141. <xsl:when test="$dingbat='copyright'">&#169;</xsl:when>
  142. <xsl:when test="$dingbat='trademark'">&#8482;</xsl:when>
  143. <xsl:when test="$dingbat='trade'">&#8482;</xsl:when>
  144. <xsl:when test="$dingbat='registered'">&#174;</xsl:when>
  145. <xsl:when test="$dingbat='service'">(SM)</xsl:when>
  146. <xsl:when test="$dingbat='nbsp'">&#160;</xsl:when>
  147. <xsl:when test="$dingbat='ldquo'">&#8220;</xsl:when>
  148. <xsl:when test="$dingbat='rdquo'">&#8221;</xsl:when>
  149. <xsl:when test="$dingbat='lsquo'">&#8216;</xsl:when>
  150. <xsl:when test="$dingbat='rsquo'">&#8217;</xsl:when>
  151. <xsl:when test="$dingbat='em-dash'">&#8212;</xsl:when>
  152. <xsl:when test="$dingbat='mdash'">&#8212;</xsl:when>
  153. <xsl:when test="$dingbat='en-dash'">&#8211;</xsl:when>
  154. <xsl:when test="$dingbat='ndash'">&#8211;</xsl:when>
  155. <xsl:otherwise>
  156. <xsl:text>&#8226;</xsl:text>
  157. </xsl:otherwise>
  158. </xsl:choose>
  159. </xsl:template>
  160. <xsl:template name="id.warning">
  161. <xsl:if test="$id.warnings != 0 and not(@id) and not(@xml:id) and parent::*">
  162. <xsl:variable name="title">
  163. <xsl:choose>
  164. <xsl:when test="title">
  165. <xsl:value-of select="title[1]"/>
  166. </xsl:when>
  167. <xsl:when test="substring(local-name(*[1]), string-length(local-name(*[1])-3) = 'info') and *[1]/title">
  168. <xsl:value-of select="*[1]/title[1]"/>
  169. </xsl:when>
  170. <xsl:when test="refmeta/refentrytitle">
  171. <xsl:value-of select="refmeta/refentrytitle"/>
  172. </xsl:when>
  173. <xsl:when test="refnamediv/refname">
  174. <xsl:value-of select="refnamediv/refname[1]"/>
  175. </xsl:when>
  176. </xsl:choose>
  177. </xsl:variable>
  178. <xsl:message>
  179. <xsl:text>ID recommended on </xsl:text>
  180. <xsl:value-of select="local-name(.)"/>
  181. <xsl:if test="$title != ''">
  182. <xsl:text>: </xsl:text>
  183. <xsl:choose>
  184. <xsl:when test="string-length($title) &gt; 40">
  185. <xsl:value-of select="substring($title,1,40)"/>
  186. <xsl:text>...</xsl:text>
  187. </xsl:when>
  188. <xsl:otherwise>
  189. <xsl:value-of select="$title"/>
  190. </xsl:otherwise>
  191. </xsl:choose>
  192. </xsl:if>
  193. </xsl:message>
  194. </xsl:if>
  195. </xsl:template>
  196. <xsl:template match="*" mode="class.attribute">
  197. <xsl:param name="class" select="local-name(.)"/>
  198. <!-- permit customization of class attributes -->
  199. <!-- Use element name by default -->
  200. <xsl:attribute name="class">
  201. <xsl:apply-templates select="." mode="class.value">
  202. <xsl:with-param name="class" select="$class"/>
  203. </xsl:apply-templates>
  204. </xsl:attribute>
  205. </xsl:template>
  206. <xsl:template match="*" mode="class.value">
  207. <xsl:param name="class" select="local-name(.)"/>
  208. <!-- permit customization of class value only -->
  209. <!-- Use element name by default -->
  210. <xsl:value-of select="$class"/>
  211. </xsl:template>
  212. </xsl:stylesheet>