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.

xhtml2xml.xsl 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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="xml" encoding="UTF-8" indent="yes"/>
  4. <xsl:param name="link"/>
  5. <xsl:template match="/html">
  6. <xsl:element name="newsset">
  7. <xsl:element name="news">
  8. <xsl:attribute name="date">
  9. <xsl:value-of select="/html/@newsdate"/>
  10. </xsl:attribute>
  11. <xsl:if test="/html/@type">
  12. <xsl:attribute name ="type">
  13. <xsl:value-of select="/html/@type"/>
  14. </xsl:attribute>
  15. </xsl:if>
  16. <!-- TODO: to be removed -->
  17. <xsl:if test="/html/@tags">
  18. <xsl:attribute name ="tags">
  19. <xsl:value-of select="/html/@tags"/>
  20. </xsl:attribute>
  21. </xsl:if>
  22. <xsl:element name="title">
  23. <xsl:value-of select="/html/head/title"/>
  24. </xsl:element>
  25. <xsl:element name="body">
  26. <xsl:value-of select="/html/body/p[@newsteaser]"/>
  27. </xsl:element>
  28. <xsl:element name="body-complete">
  29. <xsl:copy-of select="/html/body/node()"/>
  30. </xsl:element>
  31. <xsl:element name="link">
  32. <xsl:variable name="the_link">
  33. <xsl:value-of select="/html/@link"/>
  34. </xsl:variable>
  35. <xsl:choose>
  36. <xsl:when test="not(string($the_link))">
  37. <xsl:value-of select="$link"/>
  38. </xsl:when>
  39. <xsl:otherwise>
  40. <xsl:value-of select="$the_link"/>
  41. </xsl:otherwise>
  42. </xsl:choose>
  43. </xsl:element>
  44. <xsl:copy-of select="/html/tags" />
  45. <xsl:copy-of select="/html/author" />
  46. </xsl:element>
  47. </xsl:element>
  48. </xsl:template>
  49. </xsl:stylesheet>