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.

events-utils.xsl 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!-- XSL stylesheet for generating RSS feeds. We use RSS 0.91 for now -->
  3. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  4. <xsl:output method="xml" encoding="UTF-8" indent="yes" />
  5. <!-- how an event link should look like -->
  6. <xsl:template name="event-link">
  7. <xsl:param name="absolute-fsfe-links" select="'yes'" /> <!-- yes: http://fsfe.org/events/events.en.html#…
  8. no: /events/events.en.html#… -->
  9. <xsl:variable name="lang" select="/html/@lang" />
  10. <!-- Link -->
  11. <xsl:choose>
  12. <!-- link is already given → normalise it -->
  13. <xsl:when test="link != ''">
  14. <xsl:variable name="link">
  15. <xsl:apply-templates select="link">
  16. <xsl:with-param name="lang" select="$lang"/>
  17. <xsl:with-param name="absolute-fsfe-links" select="$absolute-fsfe-links"/>
  18. </xsl:apply-templates>
  19. </xsl:variable>
  20. <xsl:value-of select="normalize-space($link)"/>
  21. </xsl:when>
  22. <!-- link is not present, link to events.html#… -->
  23. <xsl:otherwise>
  24. <xsl:if test="$absolute-fsfe-links = 'yes'">
  25. <xsl:text>http://fsfe.org</xsl:text>
  26. </xsl:if>
  27. <xsl:text>/events/events.</xsl:text>
  28. <xsl:value-of select="$lang" />
  29. <xsl:text>.html#</xsl:text>
  30. <!-- anchor value -->
  31. <xsl:value-of select="@filename" />
  32. </xsl:otherwise>
  33. </xsl:choose>
  34. </xsl:template>
  35. <!-- ============= -->
  36. <!-- Link handling -->
  37. <!-- ============= -->
  38. <xsl:template match="link">
  39. <xsl:param name="lang" />
  40. <xsl:param name="absolute-fsfe-links" />
  41. <!-- Original link text -->
  42. <!-- We remove leading "http://fsfe.org" by default -->
  43. <xsl:variable name="link">
  44. <xsl:choose>
  45. <xsl:when test="starts-with (normalize-space(.), 'http://fsfe.org')">
  46. <xsl:value-of select="substring-after(normalize-space(.), 'http://fsfe.org')" />
  47. </xsl:when>
  48. <xsl:otherwise>
  49. <xsl:value-of select="normalize-space(.)" />
  50. </xsl:otherwise>
  51. </xsl:choose>
  52. </xsl:variable>
  53. <!-- Add leading "http://fsfe.org" if necessary -->
  54. <xsl:variable name="full-link">
  55. <xsl:choose>
  56. <xsl:when test="starts-with ($link, 'http:')">
  57. <xsl:value-of select="$link" />
  58. </xsl:when>
  59. <xsl:when test="starts-with ($link, 'https:')">
  60. <xsl:value-of select="$link" />
  61. </xsl:when>
  62. <xsl:when test="$absolute-fsfe-links != 'yes'">
  63. <xsl:value-of select="$link" />
  64. </xsl:when>
  65. <xsl:otherwise>
  66. <xsl:text>http://fsfe.org</xsl:text>
  67. <xsl:value-of select="$link" />
  68. </xsl:otherwise>
  69. </xsl:choose>
  70. </xsl:variable>
  71. <!-- Insert language into link -->
  72. <xsl:choose>
  73. <xsl:when test="starts-with ($full-link, 'http://fsfe.org/')
  74. and substring-before ($full-link, '.html') != ''">
  75. <xsl:value-of select="concat (substring-before ($full-link, '.html'),
  76. '.', $lang, '.html')" />
  77. </xsl:when>
  78. <xsl:otherwise>
  79. <xsl:value-of select="$full-link" />
  80. </xsl:otherwise>
  81. </xsl:choose>
  82. </xsl:template>
  83. </xsl:stylesheet>