Source files of fsfe.org, pdfreaders.org, freeyourandroid.org, ilovefs.org, drm.info, and test.fsfe.org. Contribute: https://fsfe.org/contribute/web/ https://fsfe.org
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.
 
 
 
 
 
 

72 lines
2.1 KiB

  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  3. <xsl:output method="xml" encoding="ISO-8859-1" indent="yes" />
  4. <!-- In /html/body node, append dynamic content -->
  5. <xsl:template match="/html/body">
  6. <xsl:copy>
  7. <!-- First, include what's in the source file -->
  8. <xsl:apply-templates />
  9. <!-- $today = current date (given as <html date="...">) -->
  10. <xsl:variable name="today">
  11. <xsl:value-of select="/html/@date" />
  12. </xsl:variable>
  13. <!-- Show news except those in the future, but no newsletters -->
  14. <xsl:for-each select="/html/set/news
  15. [translate (@date, '-', '') &lt;= translate ($today, '-', '') and
  16. not (@type = 'newsletter')]">
  17. <xsl:sort select="@date" order="descending" />
  18. <!-- This is a news entry -->
  19. <xsl:element name="p">
  20. <!-- Date and title -->
  21. <xsl:element name="b">
  22. <xsl:text>(</xsl:text>
  23. <xsl:value-of select="@date" />
  24. <xsl:text>) </xsl:text>
  25. <xsl:value-of select="title" />
  26. </xsl:element>
  27. <xsl:element name="br" />
  28. <!-- Text -->
  29. <xsl:apply-templates select="body/node()" />
  30. <!-- Link -->
  31. <xsl:apply-templates select="link" />
  32. </xsl:element>
  33. <!-- End news entry -->
  34. </xsl:for-each>
  35. </xsl:copy>
  36. </xsl:template>
  37. <!-- Do not copy <set> and <text> to output at all -->
  38. <xsl:template match="/html/set" />
  39. <xsl:template match="/html/text" />
  40. <!-- How to show a link -->
  41. <xsl:template match="/html/set/news/link">
  42. <xsl:element name="a">
  43. <xsl:attribute name="href">
  44. <xsl:value-of select="text()" />
  45. </xsl:attribute>
  46. <xsl:text>[</xsl:text>
  47. <xsl:value-of select="/html/text[@id='more']" />
  48. <xsl:text>]</xsl:text>
  49. </xsl:element>
  50. </xsl:template>
  51. <!-- For all other nodes, copy verbatim -->
  52. <xsl:template match="@*|node()" priority="-1">
  53. <xsl:copy>
  54. <xsl:apply-templates select="@*|node()"/>
  55. </xsl:copy>
  56. </xsl:template>
  57. </xsl:stylesheet>