head.xsl 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. version="1.0">
  4. <xsl:template match="head" mode="head.mode">
  5. <xsl:variable name="nodes" select="*"/>
  6. <head>
  7. <meta name="generator" content="Website XSL Stylesheet V{$VERSION}"/>
  8. <xsl:if test="$html.stylesheet != ''">
  9. <link rel="stylesheet" href="{$html.stylesheet}" type="text/css">
  10. <xsl:if test="$html.stylesheet.type != ''">
  11. <xsl:attribute name="type">
  12. <xsl:value-of select="$html.stylesheet.type"/>
  13. </xsl:attribute>
  14. </xsl:if>
  15. </link>
  16. </xsl:if>
  17. <xsl:variable name="thisid" select="ancestor-or-self::webpage/@id"/>
  18. <xsl:variable name="thisrelpath">
  19. <xsl:apply-templates select="$autolayout//*[@id=$thisid]" mode="toc-rel-path"/>
  20. </xsl:variable>
  21. <xsl:variable name="topid">
  22. <xsl:call-template name="top.page"/>
  23. </xsl:variable>
  24. <xsl:if test="$topid != ''">
  25. <link rel="home">
  26. <xsl:attribute name="href">
  27. <xsl:call-template name="page.uri">
  28. <xsl:with-param name="page" select="$autolayout//*[@id=$topid]"/>
  29. <xsl:with-param name="relpath" select="$thisrelpath"/>
  30. </xsl:call-template>
  31. </xsl:attribute>
  32. <xsl:attribute name="title">
  33. <xsl:value-of select="$autolayout//*[@id=$topid]/title"/>
  34. </xsl:attribute>
  35. </link>
  36. </xsl:if>
  37. <xsl:variable name="upid">
  38. <xsl:call-template name="up.page"/>
  39. </xsl:variable>
  40. <xsl:if test="$upid != ''">
  41. <link rel="up">
  42. <xsl:attribute name="href">
  43. <xsl:call-template name="page.uri">
  44. <xsl:with-param name="page" select="$autolayout//*[@id=$upid]"/>
  45. <xsl:with-param name="relpath" select="$thisrelpath"/>
  46. </xsl:call-template>
  47. </xsl:attribute>
  48. <xsl:attribute name="title">
  49. <xsl:value-of select="$autolayout//*[@id=$upid]/title"/>
  50. </xsl:attribute>
  51. </link>
  52. </xsl:if>
  53. <xsl:variable name="previd">
  54. <xsl:call-template name="prev.page"/>
  55. </xsl:variable>
  56. <xsl:if test="$previd != ''">
  57. <link rel="previous">
  58. <xsl:attribute name="href">
  59. <xsl:call-template name="page.uri">
  60. <xsl:with-param name="page" select="$autolayout//*[@id=$previd]"/>
  61. <xsl:with-param name="relpath" select="$thisrelpath"/>
  62. </xsl:call-template>
  63. </xsl:attribute>
  64. <xsl:attribute name="title">
  65. <xsl:value-of select="$autolayout//*[@id=$previd]/title"/>
  66. </xsl:attribute>
  67. </link>
  68. </xsl:if>
  69. <xsl:variable name="nextid">
  70. <xsl:call-template name="next.page"/>
  71. </xsl:variable>
  72. <xsl:if test="$nextid != ''">
  73. <link rel="next">
  74. <xsl:attribute name="href">
  75. <xsl:call-template name="page.uri">
  76. <xsl:with-param name="page" select="$autolayout//*[@id=$nextid]"/>
  77. <xsl:with-param name="relpath" select="$thisrelpath"/>
  78. </xsl:call-template>
  79. </xsl:attribute>
  80. <xsl:attribute name="title">
  81. <xsl:value-of select="$autolayout//*[@id=$nextid]/title"/>
  82. </xsl:attribute>
  83. </link>
  84. </xsl:if>
  85. <xsl:variable name="firstid">
  86. <xsl:call-template name="first.page"/>
  87. </xsl:variable>
  88. <xsl:if test="$firstid != ''">
  89. <link rel="first">
  90. <xsl:attribute name="href">
  91. <xsl:call-template name="page.uri">
  92. <xsl:with-param name="page" select="$autolayout//*[@id=$firstid]"/>
  93. <xsl:with-param name="relpath" select="$thisrelpath"/>
  94. </xsl:call-template>
  95. </xsl:attribute>
  96. <xsl:attribute name="title">
  97. <xsl:value-of select="$autolayout//*[@id=$firstid]/title"/>
  98. </xsl:attribute>
  99. </link>
  100. </xsl:if>
  101. <xsl:variable name="lastid">
  102. <xsl:call-template name="last.page"/>
  103. </xsl:variable>
  104. <xsl:if test="$lastid != ''">
  105. <link rel="last">
  106. <xsl:attribute name="href">
  107. <xsl:call-template name="page.uri">
  108. <xsl:with-param name="page" select="$autolayout//*[@id=$lastid]"/>
  109. <xsl:with-param name="relpath" select="$thisrelpath"/>
  110. </xsl:call-template>
  111. </xsl:attribute>
  112. <xsl:attribute name="title">
  113. <xsl:value-of select="$autolayout//*[@id=$lastid]/title"/>
  114. </xsl:attribute>
  115. </link>
  116. </xsl:if>
  117. <xsl:apply-templates select="$autolayout/autolayout/style
  118. |$autolayout/autolayout/script
  119. |$autolayout/autolayout/headlink"
  120. mode="head.mode">
  121. <xsl:with-param name="webpage" select="ancestor::webpage"/>
  122. </xsl:apply-templates>
  123. <xsl:apply-templates mode="head.mode"/>
  124. <xsl:call-template name="user.head.content">
  125. <xsl:with-param name="node" select="ancestor::webpage"/>
  126. </xsl:call-template>
  127. </head>
  128. </xsl:template>
  129. <xsl:template match="title" mode="head.mode">
  130. <title><xsl:value-of select="."/></title>
  131. </xsl:template>
  132. <xsl:template match="titleabbrev" mode="head.mode">
  133. <!--nop-->
  134. </xsl:template>
  135. <xsl:template match="subtitle" mode="head.mode">
  136. <!--nop-->
  137. </xsl:template>
  138. <xsl:template match="summary" mode="head.mode">
  139. <!--nop-->
  140. </xsl:template>
  141. <xsl:template match="base" mode="head.mode">
  142. <base href="{@href}">
  143. <xsl:if test="@target">
  144. <xsl:attribute name="target">
  145. <xsl:value-of select="@target"/>
  146. </xsl:attribute>
  147. </xsl:if>
  148. </base>
  149. </xsl:template>
  150. <xsl:template match="keywords" mode="head.mode">
  151. <meta name="keyword" content="{.}"/>
  152. <meta name="keywords" content="{.}"/>
  153. </xsl:template>
  154. <xsl:template match="copyright" mode="head.mode">
  155. <!--nop-->
  156. </xsl:template>
  157. <xsl:template match="author" mode="head.mode">
  158. <!--nop-->
  159. </xsl:template>
  160. <xsl:template match="edition" mode="head.mode">
  161. <!--nop-->
  162. </xsl:template>
  163. <xsl:template match="meta" mode="head.mode">
  164. <xsl:choose>
  165. <xsl:when test="@http-equiv">
  166. <meta http-equiv="{@http-equiv}" content="{@content}"/>
  167. </xsl:when>
  168. <xsl:otherwise>
  169. <meta name="{@name}" content="{@content}"/>
  170. </xsl:otherwise>
  171. </xsl:choose>
  172. </xsl:template>
  173. <xsl:template match="script" mode="head.mode">
  174. <script>
  175. <xsl:choose>
  176. <xsl:when test="@language">
  177. <xsl:attribute name="language">
  178. <xsl:value-of select="@language"/>
  179. </xsl:attribute>
  180. </xsl:when>
  181. <xsl:otherwise>
  182. <xsl:attribute name="language">JavaScript</xsl:attribute>
  183. </xsl:otherwise>
  184. </xsl:choose>
  185. <xsl:choose>
  186. <xsl:when test="@type">
  187. <xsl:attribute name="type">
  188. <xsl:value-of select="@type"/>
  189. </xsl:attribute>
  190. </xsl:when>
  191. <xsl:otherwise>
  192. <xsl:attribute name="type">text/javascript</xsl:attribute>
  193. </xsl:otherwise>
  194. </xsl:choose>
  195. <xsl:apply-templates/>
  196. </script>
  197. </xsl:template>
  198. <xsl:template match="script[@src]" mode="head.mode" priority="2">
  199. <xsl:param name="webpage" select="ancestor::webpage"/>
  200. <xsl:variable name="relpath">
  201. <xsl:call-template name="root-rel-path">
  202. <xsl:with-param name="webpage" select="$webpage"/>
  203. </xsl:call-template>
  204. </xsl:variable>
  205. <xsl:variable name="language">
  206. <xsl:choose>
  207. <xsl:when test="@language">
  208. <xsl:value-of select="@language"/>
  209. </xsl:when>
  210. <xsl:otherwise>JavaScript</xsl:otherwise>
  211. </xsl:choose>
  212. </xsl:variable>
  213. <xsl:variable name="type">
  214. <xsl:choose>
  215. <xsl:when test="@type">
  216. <xsl:value-of select="@type"/>
  217. </xsl:when>
  218. <xsl:otherwise>text/javascript</xsl:otherwise>
  219. </xsl:choose>
  220. </xsl:variable>
  221. <script src="{$relpath}{@src}" language="{$language}" type="{$type}"/>
  222. </xsl:template>
  223. <xsl:template match="style" mode="head.mode">
  224. <style>
  225. <xsl:if test="@type">
  226. <xsl:attribute name="type">
  227. <xsl:value-of select="@type"/>
  228. </xsl:attribute>
  229. </xsl:if>
  230. <xsl:apply-templates/>
  231. </style>
  232. </xsl:template>
  233. <xsl:template match="style[@src]" mode="head.mode" priority="2">
  234. <xsl:param name="webpage" select="ancestor::webpage"/>
  235. <xsl:variable name="relpath">
  236. <xsl:call-template name="root-rel-path">
  237. <xsl:with-param name="webpage" select="$webpage"/>
  238. </xsl:call-template>
  239. </xsl:variable>
  240. <xsl:choose>
  241. <xsl:when test="starts-with(@src, '/')">
  242. <link rel="stylesheet" href="{@src}">
  243. <xsl:if test="@type">
  244. <xsl:attribute name="type">
  245. <xsl:value-of select="@type"/>
  246. </xsl:attribute>
  247. </xsl:if>
  248. </link>
  249. </xsl:when>
  250. <xsl:otherwise>
  251. <link rel="stylesheet" href="{$relpath}{@src}">
  252. <xsl:if test="@type">
  253. <xsl:attribute name="type">
  254. <xsl:value-of select="@type"/>
  255. </xsl:attribute>
  256. </xsl:if>
  257. </link>
  258. </xsl:otherwise>
  259. </xsl:choose>
  260. </xsl:template>
  261. <xsl:template match="headlink" mode="head.mode">
  262. <link>
  263. <xsl:copy-of select="@*"/>
  264. </link>
  265. </xsl:template>
  266. <xsl:template match="abstract" mode="head.mode">
  267. <!--nop-->
  268. </xsl:template>
  269. <xsl:template match="revhistory" mode="head.mode">
  270. <!--nop-->
  271. </xsl:template>
  272. <xsl:template match="rddl:*" mode="head.mode"
  273. xmlns:rddl='http://www.rddl.org/'>
  274. <!--nop-->
  275. </xsl:template>
  276. </xsl:stylesheet>