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.

document2docbook.xsl 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. version="1.0">
  4. <xsl:template match="document">
  5. <article>
  6. <articleinfo>
  7. <authorgroup>
  8. <xsl:for-each select="header/person">
  9. <author>
  10. <firstname><xsl:value-of select="@name"/></firstname>
  11. <address><email><xsl:value-of select="@email"/></email></address>
  12. </author>
  13. </xsl:for-each>
  14. </authorgroup>
  15. </articleinfo>
  16. <title><xsl:value-of select="header/title"/></title>
  17. <xsl:apply-templates select="body"/>
  18. </article>
  19. </xsl:template>
  20. <xsl:template match="changes">
  21. <revhistory>
  22. <xsl:apply-templates select="//action"/>
  23. </revhistory>
  24. </xsl:template>
  25. <xsl:template match="action">
  26. <revision>
  27. <xsl:attribute name="revisionflag">
  28. <xsl:choose>
  29. <xsl:when test="@type='add'">added</xsl:when>
  30. <xsl:when test="@type='update'">changed</xsl:when>
  31. <xsl:when test="@type='remove'">deleted</xsl:when>
  32. <xsl:when test="@type='fix'">off</xsl:when>
  33. <xsl:otherwise>changed</xsl:otherwise>
  34. </xsl:choose>
  35. </xsl:attribute>
  36. <revnumber><xsl:value-of select="../@version"/></revnumber>
  37. <date><xsl:value-of select="../@date"/></date>
  38. <authorinitials><xsl:value-of select="@dev"/></authorinitials>
  39. <revremark>
  40. <xsl:value-of select="."/>
  41. </revremark>
  42. </revision>
  43. </xsl:template>
  44. <xsl:template match="body">
  45. <xsl:apply-templates/>
  46. </xsl:template>
  47. <xsl:template match="s1">
  48. <section>
  49. <title><xsl:value-of select="@title"/></title>
  50. <xsl:apply-templates/>
  51. </section>
  52. </xsl:template>
  53. <xsl:template match="s2">
  54. <section>
  55. <title><xsl:value-of select="@title"/></title>
  56. <xsl:apply-templates/>
  57. </section>
  58. </xsl:template>
  59. <xsl:template match="s3">
  60. <section>
  61. <title><xsl:value-of select="@title"/></title>
  62. <xsl:apply-templates/>
  63. </section>
  64. </xsl:template>
  65. <xsl:template match="s4">
  66. <section>
  67. <title><xsl:value-of select="@title"/></title>
  68. <xsl:apply-templates/>
  69. </section>
  70. </xsl:template>
  71. <xsl:template match="p|br">
  72. <para>
  73. <xsl:apply-templates/>
  74. </para>
  75. </xsl:template>
  76. <xsl:template match="strong|em">
  77. <emphasis><xsl:apply-templates/></emphasis>
  78. </xsl:template>
  79. <xsl:template match="ul">
  80. <itemizedlist><xsl:apply-templates/></itemizedlist>
  81. </xsl:template>
  82. <xsl:template match="li">
  83. <listitem><xsl:apply-templates/></listitem>
  84. </xsl:template>
  85. <xsl:template match="ol">
  86. <orderedlist><xsl:apply-templates/></orderedlist>
  87. </xsl:template>
  88. <xsl:template match="link">
  89. <ulink uri="{@href}"><xsl:apply-templates/></ulink>
  90. </xsl:template>
  91. <xsl:template match="figure">
  92. <xsl:choose>
  93. <xsl:when test="@src">
  94. <figure>
  95. <title><xsl:value-of select="@alt"/></title>
  96. <graphic fileref="{@src}" srccredit="{@alt}"/>
  97. </figure>
  98. </xsl:when>
  99. <xsl:otherwise>
  100. <figure>
  101. <xsl:apply-templates/>
  102. </figure>
  103. </xsl:otherwise>
  104. </xsl:choose>
  105. </xsl:template>
  106. <xsl:template match="fixme">
  107. <warning><xsl:apply-templates/></warning>
  108. </xsl:template>
  109. <xsl:template match="note">
  110. <note><xsl:apply-templates/></note>
  111. </xsl:template>
  112. <xsl:template match="warn">
  113. <warning><xsl:apply-templates/></warning>
  114. </xsl:template>
  115. <xsl:template match="code">
  116. <classname><xsl:apply-templates/></classname>
  117. </xsl:template>
  118. <xsl:template match="source">
  119. <programlisting><xsl:apply-templates/></programlisting>
  120. </xsl:template>
  121. <xsl:template match="table">
  122. <table>
  123. <tgroup>
  124. <xsl:attribute name="cols"><xsl:value-of select="count(tr/td)"/></xsl:attribute>
  125. <xsl:if test="th">
  126. <thead>
  127. <xsl:apply-templates select="th"/>
  128. </thead>
  129. </xsl:if>
  130. <tbody>
  131. <xsl:apply-templates select="tr"/>
  132. </tbody>
  133. </tgroup>
  134. </table>
  135. </xsl:template>
  136. <xsl:template match="th|tr">
  137. <row>
  138. <xsl:apply-templates/>
  139. </row>
  140. </xsl:template>
  141. <xsl:template match="td">
  142. <entry>
  143. <xsl:apply-templates/>
  144. </entry>
  145. </xsl:template>
  146. <xsl:template match="node()|@*" priority="-1">
  147. <xsl:copy>
  148. <xsl:apply-templates select="node()|@*"/>
  149. </xsl:copy>
  150. </xsl:template>
  151. </xsl:stylesheet>