Source files of fsfe.org, pdfreaders.org, freeyourandroid.org, ilovefs.org, drm.info, and test.fsfe.org. Contribute: https://fsfe.org/contribute/web/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fsfeurope.xsl 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  3. <xsl:output method="html" encoding="utf-8" indent="yes"
  4. doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"
  5. doctype-system="http://www.w3.org/TR/REC-html40/loose.dtd"/>
  6. <!-- The top level element of the input file is "buildinfo" -->
  7. <xsl:template match="buildinfo">
  8. <xsl:apply-templates select="node()"/>
  9. </xsl:template>
  10. <!-- The actual HTML tree is in "buildinfo/document" -->
  11. <xsl:template match="buildinfo/document">
  12. <xsl:element name="html">
  13. <xsl:attribute name="lang">
  14. <xsl:value-of select="/buildinfo/@language"/>
  15. </xsl:attribute>
  16. <xsl:if test="/buildinfo/@language='ar'">
  17. <xsl:attribute name="dir">rtl</xsl:attribute>
  18. </xsl:if>
  19. <xsl:apply-templates select="node()"/>
  20. </xsl:element>
  21. </xsl:template>
  22. <!-- HTML head -->
  23. <xsl:template match="head">
  24. <xsl:copy>
  25. <meta name="robots" content="index, follow" />
  26. <link rel="stylesheet" media="all" href="/fsfeurope.css" type="text/css" />
  27. <link rel="stylesheet" media="print" href="/print.css" type="text/css" />
  28. <xsl:if test="/buildinfo/@language='ar'">
  29. <link rel="stylesheet" media="all" href="/rtl.css" type="text/css" />
  30. </xsl:if>
  31. <link rel="icon" href="/graphics/fsfeurope.ico" type="image/x-icon" />
  32. <link rel="shortcut icon" href="/graphics/fsfeurope.ico" type="image/x-icon" />
  33. <xsl:element name="link">
  34. <xsl:attribute name="rel">alternate</xsl:attribute>
  35. <xsl:attribute name="title">FSFE <xsl:value-of select="/buildinfo/textset/text[@id='menu1/news']" /></xsl:attribute>
  36. <xsl:attribute name="href">/news/news.<xsl:value-of select="/buildinfo/@language" />.rss</xsl:attribute>
  37. <xsl:attribute name="type">application/rss+xml</xsl:attribute>
  38. </xsl:element>
  39. <xsl:element name="link">
  40. <xsl:attribute name="rel">alternate</xsl:attribute>
  41. <xsl:attribute name="title">FSFE <xsl:value-of select="/buildinfo/textset/text[@id='menu1/events']" /></xsl:attribute>
  42. <xsl:attribute name="href">/events/events.<xsl:value-of select="/buildinfo/@language" />.rss</xsl:attribute>
  43. <xsl:attribute name="type">application/rss+xml</xsl:attribute>
  44. </xsl:element>
  45. <xsl:apply-templates select="@*|node()"/>
  46. </xsl:copy>
  47. </xsl:template>
  48. <!-- HTML body -->
  49. <xsl:template match="body">
  50. <xsl:copy>
  51. <!-- First of all, a comment to make clear this is generated -->
  52. <xsl:comment>This file was generated by an XSLT script. Please do not edit.</xsl:comment>
  53. <xsl:element name="div">
  54. <xsl:attribute name="id">wrapper</xsl:attribute>
  55. <xsl:comment>Unnecessary div, for IE only</xsl:comment>
  56. <xsl:element name="a">
  57. <xsl:attribute name="class">n</xsl:attribute>
  58. <xsl:attribute name="id">top</xsl:attribute>
  59. <xsl:attribute name="href">#content</xsl:attribute>
  60. <xsl:text>Skip menu</xsl:text>
  61. </xsl:element>
  62. <xsl:comment>Give non-graphical browsers a way to skip the menu</xsl:comment>
  63. <!-- Menu bar -->
  64. <xsl:element name="div">
  65. <xsl:attribute name="id">menu</xsl:attribute>
  66. <!-- Logo -->
  67. <xsl:element name="div">
  68. <xsl:attribute name="id">logo</xsl:attribute>
  69. <xsl:element name="a">
  70. <xsl:attribute name="href">/</xsl:attribute>
  71. <xsl:element name="img">
  72. <xsl:attribute name="alt">FSFE Logo</xsl:attribute>
  73. <xsl:attribute name="src">/graphics/logo.png</xsl:attribute>
  74. </xsl:element>
  75. </xsl:element>
  76. </xsl:element>
  77. <!-- Menu -->
  78. <xsl:for-each select="/buildinfo/menuset/menu[not(@parent)]">
  79. <xsl:sort select="@id"/>
  80. <xsl:variable name="menu"><xsl:value-of select="@id"/></xsl:variable>
  81. <xsl:element name="ul">
  82. <xsl:for-each select="/buildinfo/menuset/menu[@parent=$menu]">
  83. <xsl:sort select="@id"/>
  84. <xsl:variable name="id"><xsl:value-of select="@id"/></xsl:variable>
  85. <xsl:element name="li">
  86. <xsl:choose>
  87. <xsl:when test="not(string(.))">
  88. <xsl:value-of select="/buildinfo/textset/text[@id=$id]|
  89. /buildinfo/textsetbackup/text[@id=$id
  90. and not(@id=/buildinfo/textset/text/@id)]"/>
  91. </xsl:when>
  92. <xsl:when test=". = concat(/buildinfo/@filename ,'.html')">
  93. <xsl:value-of select="/buildinfo/textset/text[@id=$id]|
  94. /buildinfo/textsetbackup/text[@id=$id
  95. and not(@id=/buildinfo/textset/text/@id)]"/>
  96. </xsl:when>
  97. <xsl:otherwise>
  98. <xsl:element name="a">
  99. <xsl:attribute name="href"><xsl:value-of select="."/></xsl:attribute>
  100. <xsl:value-of select="/buildinfo/textset/text[@id=$id]|
  101. /buildinfo/textsetbackup/text[@id=$id
  102. and not(@id=/buildinfo/textset/text/@id)]"/>
  103. </xsl:element>
  104. </xsl:otherwise>
  105. </xsl:choose>
  106. <!-- Submenu -->
  107. <xsl:if test="/buildinfo/menuset/menu[@parent=$id]">
  108. <xsl:element name="ul">
  109. <xsl:for-each select="/buildinfo/menuset/menu[@parent=$id]">
  110. <xsl:sort select="@id" />
  111. <xsl:variable name="mid"><xsl:value-of select="@id" /></xsl:variable>
  112. <xsl:element name="li">
  113. <xsl:attribute name="class">submenu</xsl:attribute>
  114. <xsl:choose>
  115. <xsl:when test=". = concat(/buildinfo/@filename ,'.html')">
  116. <xsl:value-of select="/buildinfo/textset/text[@id=$mid]|
  117. /buildinfo/textsetbackup/text[@id=$mid
  118. and not(@id=/buildinfo/textset/text/@id)]"/>
  119. </xsl:when>
  120. <xsl:otherwise>
  121. <xsl:element name="a">
  122. <xsl:attribute name="href"><xsl:value-of select="."/></xsl:attribute>
  123. <xsl:value-of select="/buildinfo/textset/text[@id=$mid]|
  124. /buildinfo/textsetbackup/text[@id=$mid
  125. and not(@id=/buildinfo/textset/text/@id)]"/>
  126. </xsl:element>
  127. </xsl:otherwise>
  128. </xsl:choose>
  129. </xsl:element>
  130. </xsl:for-each>
  131. </xsl:element> <!-- /submenu ul -->
  132. </xsl:if>
  133. </xsl:element> <!-- /li -->
  134. </xsl:for-each>
  135. </xsl:element> <!-- /ul -->
  136. </xsl:for-each>
  137. <!-- Join the Fellowship -->
  138. <xsl:element name="a">
  139. <xsl:attribute name="href">http://fellowship.fsfe.org/about</xsl:attribute>
  140. <xsl:element name="img">
  141. <xsl:attribute name="alt">Join the Fellowship!</xsl:attribute>
  142. <xsl:attribute name="src">/graphics/join-fellowship.png</xsl:attribute>
  143. </xsl:element>
  144. </xsl:element>
  145. </xsl:element>
  146. <!-- End Menu bar -->
  147. <!-- Language bar -->
  148. <xsl:element name="div">
  149. <xsl:attribute name="id">language</xsl:attribute>
  150. <!-- Translation list -->
  151. <xsl:element name="ul">
  152. <xsl:for-each select="/buildinfo/trlist/tr">
  153. <xsl:sort select="@id"/>
  154. <xsl:element name="li">
  155. <xsl:choose>
  156. <xsl:when test="@id=/buildinfo/@language">
  157. <xsl:value-of select="." disable-output-escaping="yes"/>
  158. </xsl:when>
  159. <xsl:otherwise>
  160. <xsl:element name="a">
  161. <xsl:attribute name="href"><xsl:value-of select="/buildinfo/@filename"/>.<xsl:value-of select="@id"/>.html</xsl:attribute>
  162. <xsl:value-of select="." disable-output-escaping="yes"/>
  163. </xsl:element>
  164. </xsl:otherwise>
  165. </xsl:choose>
  166. </xsl:element>
  167. </xsl:for-each>
  168. </xsl:element>
  169. <!-- Outdated note -->
  170. <xsl:if test="/buildinfo/@outdated='yes'">
  171. <xsl:element name="p">
  172. <xsl:apply-templates select="/buildinfo/textset/text[@id='outdated']/node()" />
  173. </xsl:element>
  174. </xsl:if>
  175. <!-- Missing translation note -->
  176. <xsl:if test="/buildinfo/@language!=/buildinfo/document/@language">
  177. <xsl:element name="p">
  178. <xsl:apply-templates select="/buildinfo/textset/text[@id='notranslation']/node()" />
  179. </xsl:element>
  180. </xsl:if>
  181. </xsl:element>
  182. <!-- End Language bar -->
  183. <!-- Content -->
  184. <xsl:element name="div">
  185. <xsl:attribute name="id">content</xsl:attribute>
  186. <!-- Here goes the actual content of the <body> node of the input file -->
  187. <xsl:apply-templates select="node()"/>
  188. <!-- Link to top -->
  189. <xsl:element name="a">
  190. <xsl:attribute name="class">n</xsl:attribute>
  191. <xsl:attribute name="href">#top</xsl:attribute>
  192. <xsl:text>To top</xsl:text>
  193. </xsl:element>
  194. </xsl:element>
  195. <!-- End Content -->
  196. <!-- Footer -->
  197. <xsl:element name="div">
  198. <xsl:attribute name="id">footer</xsl:attribute>
  199. <xsl:element name="p">
  200. <!-- Copyright -->
  201. <xsl:apply-templates select="/buildinfo/textset/text[@id='copyright']/node()"/>
  202. <!-- "Last changed" magic -->
  203. <xsl:variable name="timestamp">
  204. <xsl:value-of select="/buildinfo/document/timestamp"/>
  205. </xsl:variable>
  206. <!-- FIXME: over time, all pages should have the timestamp -->
  207. <!-- tags, so this conditional could be removed -->
  208. <xsl:if test="string-length($timestamp) &gt; 0">
  209. <xsl:variable name="Date">
  210. <xsl:value-of select="substring-before(substring-after($timestamp, 'Date: '), ' $')"/>
  211. </xsl:variable>
  212. <xsl:variable name="Author">
  213. <xsl:value-of select="substring-before(substring-after($timestamp, 'Author: '), ' $')"/>
  214. </xsl:variable>
  215. <xsl:apply-templates select="/buildinfo/textset/text[@id='lastchanged']/node()"/>
  216. <xsl:value-of select="translate ($Date, '/', '-')"/>
  217. (<xsl:value-of select="$Author"/>)
  218. </xsl:if>
  219. <!-- Link to the XHTML source -->
  220. <xsl:element name="a">
  221. <xsl:attribute name="href">
  222. <xsl:text>/source</xsl:text>
  223. <xsl:value-of select="/buildinfo/@filename"/>
  224. <xsl:text>.</xsl:text>
  225. <xsl:value-of select="/buildinfo/document/@language"/>
  226. <xsl:text>.xhtml</xsl:text>
  227. </xsl:attribute>
  228. <xsl:text>[XHTML]</xsl:text>
  229. </xsl:element>
  230. <!-- Insert the appropriate translation notice -->
  231. <xsl:if test="/buildinfo/document/@language!=/buildinfo/@original">
  232. <xsl:element name="br"/>
  233. <xsl:choose>
  234. <xsl:when test="/buildinfo/document/translator">
  235. <xsl:value-of select="/buildinfo/textset/text[@id='translator1a']"/>
  236. <xsl:value-of select="/buildinfo/document/translator"/>
  237. <xsl:value-of select="/buildinfo/textset/text[@id='translator1b']"/>
  238. </xsl:when>
  239. <xsl:otherwise>
  240. <xsl:value-of select="/buildinfo/textset/text[@id='translator2']"/>
  241. </xsl:otherwise>
  242. </xsl:choose>
  243. <xsl:value-of select="/buildinfo/textset/text[@id='translator3a']"/>
  244. <xsl:element name="a">
  245. <xsl:attribute name="href">
  246. <xsl:value-of select="/buildinfo/@filename"/>
  247. <xsl:text>.en.html</xsl:text>
  248. </xsl:attribute>
  249. <xsl:value-of select="/buildinfo/textset/text[@id='translator3b']"/>
  250. </xsl:element>
  251. <xsl:value-of select="/buildinfo/textset/text[@id='translator3c']"/>
  252. </xsl:if>
  253. <!-- Permission note -->
  254. <xsl:element name="br"/>
  255. <xsl:apply-templates select="/buildinfo/textset/text[@id='permission']/node()"/>
  256. <!-- Webmaster feedback note -->
  257. <xsl:element name="br"/>
  258. <xsl:apply-templates select="/buildinfo/textset/text[@id='webmaster']/node()"/>
  259. </xsl:element>
  260. </xsl:element>
  261. <!-- End Footer -->
  262. </xsl:element>
  263. </xsl:copy>
  264. </xsl:template>
  265. <!-- Insert local menu -->
  266. <xsl:template match="localmenu">
  267. <xsl:variable name="set">
  268. <xsl:choose>
  269. <xsl:when test="@set">
  270. <xsl:value-of select="@set"/>
  271. </xsl:when>
  272. <xsl:otherwise>
  273. <xsl:text>0</xsl:text>
  274. </xsl:otherwise>
  275. </xsl:choose>
  276. </xsl:variable>
  277. <xsl:variable name="dir">
  278. <xsl:value-of select="/buildinfo/@dirname"/>
  279. </xsl:variable>
  280. <xsl:variable name="language">
  281. <xsl:value-of select="/buildinfo/@language"/>
  282. </xsl:variable>
  283. <xsl:element name="div">
  284. <xsl:attribute name="class">localmenu</xsl:attribute>
  285. <xsl:element name="p">
  286. <xsl:text>[ </xsl:text>
  287. <xsl:for-each select="/buildinfo/localmenuset/localmenuitems/menu[@dir=$dir and @set=$set]">
  288. <xsl:sort select="@id"/>
  289. <xsl:variable name="style"><xsl:value-of select="@style"/></xsl:variable>
  290. <xsl:variable name="id"><xsl:value-of select="@id"/></xsl:variable>
  291. <xsl:variable name="localmenutext">
  292. <xsl:choose>
  293. <xsl:when
  294. test="/buildinfo/localmenuset/translate/lang_part[@dir=$dir and @id=$id and @language=$language]">
  295. <xsl:value-of
  296. select="/buildinfo/localmenuset/translate/lang_part[@dir=$dir and @id=$id and @language=$language]"/>
  297. </xsl:when>
  298. <xsl:otherwise>
  299. <xsl:value-of
  300. select="/buildinfo/localmenuset/translate/lang_part[@dir=$dir and @id=$id and @language='en']"/>
  301. </xsl:otherwise>
  302. </xsl:choose>
  303. </xsl:variable>
  304. <xsl:element name="span">
  305. <xsl:attribute name="class">local_menu_item</xsl:attribute>
  306. <xsl:choose>
  307. <xsl:when test="not(substring-before(concat(/buildinfo/@filename ,'.html'), string(.)))">
  308. <xsl:element name="a">
  309. <xsl:attribute name="href"><xsl:value-of select="."/></xsl:attribute>
  310. <xsl:value-of select="$localmenutext"/>
  311. </xsl:element>
  312. </xsl:when>
  313. <xsl:otherwise>
  314. <xsl:value-of select="$localmenutext"/>
  315. </xsl:otherwise>
  316. </xsl:choose>
  317. </xsl:element>
  318. <xsl:if test="position()!=last()">
  319. <xsl:choose>
  320. <xsl:when test="$style='number'">
  321. <xsl:text> | </xsl:text>
  322. </xsl:when>
  323. <xsl:otherwise>
  324. <xsl:text> ] [ </xsl:text>
  325. </xsl:otherwise>
  326. </xsl:choose>
  327. </xsl:if>
  328. </xsl:for-each>
  329. <xsl:text> ]</xsl:text>
  330. </xsl:element>
  331. </xsl:element>
  332. </xsl:template>
  333. <!-- Do not copy non-HTML elements to output -->
  334. <xsl:template match="timestamp|
  335. translator|
  336. buildinfo/set|
  337. buildinfo/textset|
  338. buildinfo/textsetbackup|
  339. buildinfo/menuset|
  340. buildinfo/trlist|
  341. buildinfo/localmenuset"/>
  342. <!-- For all other nodes, copy verbatim -->
  343. <xsl:template match="@*|node()" priority="-1">
  344. <xsl:copy>
  345. <xsl:apply-templates select="@*|node()"/>
  346. </xsl:copy>
  347. </xsl:template>
  348. </xsl:stylesheet>