You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

anakia2forrest.xsl 4.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  2. <!--
  3. A little bit of automated transformation to help conversion
  4. from Anakia to Forrest/Cocoon docs.
  5. This is purely experimental, it hem...should work, well mostly
  6. but it should manage to break a couple of things so you will
  7. need a manual pass to fix things after that.
  8. Stephane Bailliez, sbailliez@apache.org
  9. -->
  10. <xsl:output method="xml" indent="yes" doctype-system="document-v11.dtd"
  11. doctype-public="-//APACHE//DTD Documentation V1.1//EN" encoding="ISO-8859-1"/>
  12. <!-- properties = header in Forrest language -->
  13. <xsl:template match="properties">
  14. <header>
  15. <xsl:apply-templates select="*[ local-name() != 'author']"/>
  16. <author>
  17. <xsl:apply-templates select="author"/>
  18. </author>
  19. </header>
  20. </xsl:template>
  21. <xsl:template match="author">
  22. <person id="{text()}">
  23. <!--
  24. not everyone gives his mail in order not to receive too much spam... or be
  25. assimilated as 24/24 7/7 support
  26. -->
  27. <xsl:if test="@email"><xsl:attribute name="email"><xsl:value-of select="@email"/></xsl:attribute></xsl:if>
  28. </person>
  29. </xsl:template>
  30. <!-- section = subsection with forrest and the title is an element -->
  31. <xsl:template match="section|subsection">
  32. <section>
  33. <title><xsl:value-of select="@name"/></title>
  34. <xsl:apply-templates/>
  35. </section>
  36. </xsl:template>
  37. <!-- Ignore those tags they should not be here, this will clean up
  38. some but will break others, anyways. br is evil :) -->
  39. <xsl:template match="br|nobr">
  40. <xsl:apply-templates/>
  41. </xsl:template>
  42. <!-- font should not be there, it was used to do a source (or code ?)-->
  43. <xsl:template match="font">
  44. <source>
  45. <xsl:apply-templates/>
  46. </source>
  47. </xsl:template>
  48. <!-- assumes img = icon rather than figure -->
  49. <xsl:template match="img">
  50. <icon>
  51. <xsl:apply-templates select="@alt|@src|@width|@height"/>
  52. </icon>
  53. </xsl:template>
  54. <!-- assume every anchor with a name is an anchor -->
  55. <xsl:template match="a[@name]">
  56. <anchor>
  57. <xsl:apply-templates select="@*"/>
  58. <xsl:apply-templates/>
  59. </anchor>
  60. </xsl:template>
  61. <!-- try to be super smart to detect link/anchor/jump -->
  62. <xsl:template match="a[@href]">
  63. <xsl:choose>
  64. <!-- something with a hashmark is a jump -->
  65. <xsl:when test="starts-with(@href, '#')">
  66. <jump>
  67. <xsl:apply-templates select="@*"/>
  68. <xsl:apply-templates/>
  69. </jump>
  70. </xsl:when>
  71. <!--
  72. assume everything out of apache domain would be better with a fork
  73. This is really a life style, I hate windows forking all over my
  74. desktop but it's quite convenient sometimes when too lazy to shift.
  75. One super thing would be to do like Microsoft.com and put an
  76. extra icon via forrest after the link when it send outside
  77. the apache site.
  78. -->
  79. <xsl:when test="starts-with(@href, 'http://') and not(contains(@href, 'apache.org'))">
  80. <fork>
  81. <xsl:apply-templates select="@*"/>
  82. <xsl:apply-templates/>
  83. </fork>
  84. </xsl:when>
  85. <!-- fallback to a basic link -->
  86. <xsl:otherwise>
  87. <link>
  88. <xsl:apply-templates select="@*"/>
  89. <xsl:apply-templates/>
  90. </link>
  91. </xsl:otherwise>
  92. </xsl:choose>
  93. </xsl:template>
  94. <!---
  95. Ugly hack to define an axial table
  96. The css could be defined as text-align:right !important;
  97. -->
  98. <xsl:template match="table">
  99. <table>
  100. <!--
  101. (tr[1]/th and tr[1]/td) would give the same result
  102. but I'm using following-sibbling to sound super smart
  103. and obfuscate my code. It hard to write, so it should
  104. be hard to understand ;-)
  105. -->
  106. <xsl:if test="tr[1]/th[following-sibling::td]">
  107. <xsl:attribute name="class">axial</xsl:attribute>
  108. </xsl:if>
  109. <xsl:apply-templates select="@*"/>
  110. <xsl:apply-templates/>
  111. </table>
  112. </xsl:template>
  113. <!-- wide rule, copy all nodes and attributes -->
  114. <xsl:template match="node()|@*" priority="-1">
  115. <xsl:copy>
  116. <xsl:apply-templates select="@*"/>
  117. <xsl:apply-templates/>
  118. </xsl:copy>
  119. </xsl:template>
  120. </xsl:stylesheet>