section.title.xsl 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <xsl:stylesheet version="1.0"
  2. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:d="http://docbook.org/ns/docbook"
  4. xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="d">
  5. <xsl:template name="section.title">
  6. <xsl:variable name="section"
  7. select="(ancestor::section |
  8. ancestor::simplesect|
  9. ancestor::sect1|
  10. ancestor::sect2|
  11. ancestor::sect3|
  12. ancestor::sect4|
  13. ancestor::sect5)[last()]"/>
  14. <xsl:variable name="renderas">
  15. <xsl:choose>
  16. <xsl:when test="$section/@renderas = 'sect1'">1</xsl:when>
  17. <xsl:when test="$section/@renderas = 'sect2'">2</xsl:when>
  18. <xsl:when test="$section/@renderas = 'sect3'">3</xsl:when>
  19. <xsl:when test="$section/@renderas = 'sect4'">4</xsl:when>
  20. <xsl:when test="$section/@renderas = 'sect5'">5</xsl:when>
  21. <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
  22. </xsl:choose>
  23. </xsl:variable>
  24. <xsl:variable name="level">
  25. <xsl:choose>
  26. <xsl:when test="$renderas != ''">
  27. <xsl:value-of select="$renderas"/>
  28. </xsl:when>
  29. <xsl:otherwise>
  30. <xsl:call-template name="section.level">
  31. <xsl:with-param name="node" select="$section"/>
  32. </xsl:call-template>
  33. </xsl:otherwise>
  34. </xsl:choose>
  35. </xsl:variable>
  36. <xsl:call-template name="section.heading">
  37. <xsl:with-param name="section" select="$section"/>
  38. <xsl:with-param name="level" select="$level"/>
  39. <xsl:with-param name="title">
  40. <xsl:apply-templates select="$section" mode="object.title.markup">
  41. <xsl:with-param name="allow-anchors" select="1"/>
  42. </xsl:apply-templates>
  43. <xsl:if test="$level &gt; 0">
  44. <xsl:call-template name="permalink">
  45. <xsl:with-param name="node" select="$section"/>
  46. </xsl:call-template>
  47. </xsl:if>
  48. </xsl:with-param>
  49. </xsl:call-template>
  50. </xsl:template>
  51. </xsl:stylesheet>