maketoc.xsl 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?xml version="1.0" encoding="ASCII"?>
  2. <!--This file was created automatically by html2xhtml-->
  3. <!--from the HTML stylesheets.-->
  4. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" xmlns="http://www.w3.org/1999/xhtml" version="1.0" exclude-result-prefixes="doc">
  5. <!-- ********************************************************************
  6. $Id: maketoc.xsl 6910 2007-06-28 23:23:30Z xmldoc $
  7. ********************************************************************
  8. This file is part of the XSL DocBook Stylesheet distribution.
  9. See ../README or http://docbook.sf.net/release/xsl/current/ for
  10. copyright and other information.
  11. ******************************************************************** -->
  12. <!-- ==================================================================== -->
  13. <xsl:import href="docbook.xsl"/>
  14. <xsl:import href="chunk.xsl"/>
  15. <xsl:output method="xml" indent="no" encoding="UTF-8" doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"/>
  16. <xsl:param name="toc.list.type" select="'tocentry'"/>
  17. <!-- refentry in autotoc.xsl does not use subtoc, so must
  18. handle it explicitly here. -->
  19. <xsl:template match="refentry" mode="toc">
  20. <xsl:param name="toc-context" select="."/>
  21. <xsl:call-template name="subtoc">
  22. <xsl:with-param name="toc-context" select="$toc-context"/>
  23. </xsl:call-template>
  24. </xsl:template>
  25. <xsl:template name="subtoc">
  26. <xsl:param name="nodes" select="NOT-AN-ELEMENT"/>
  27. <xsl:variable name="filename">
  28. <xsl:apply-templates select="." mode="chunk-filename"/>
  29. </xsl:variable>
  30. <xsl:variable name="chunk">
  31. <xsl:call-template name="chunk"/>
  32. </xsl:variable>
  33. <xsl:if test="$chunk != 0">
  34. <xsl:call-template name="indent-spaces"/>
  35. <xsl:variable name="id">
  36. <xsl:call-template name="object.id"/>
  37. </xsl:variable>
  38. <tocentry linkend="{$id}">
  39. <xsl:processing-instruction name="dbhtml">
  40. <xsl:text>filename="</xsl:text>
  41. <xsl:value-of select="$filename"/>
  42. <xsl:text>"</xsl:text>
  43. </xsl:processing-instruction>
  44. <xsl:text>
  45. </xsl:text>
  46. <xsl:apply-templates mode="toc" select="$nodes"/>
  47. <xsl:call-template name="indent-spaces"/>
  48. </tocentry>
  49. <xsl:text>
  50. </xsl:text>
  51. </xsl:if>
  52. </xsl:template>
  53. <xsl:template name="indent-spaces">
  54. <xsl:param name="node" select="."/>
  55. <xsl:text> </xsl:text>
  56. <xsl:if test="$node/parent::*">
  57. <xsl:call-template name="indent-spaces">
  58. <xsl:with-param name="node" select="$node/parent::*"/>
  59. </xsl:call-template>
  60. </xsl:if>
  61. </xsl:template>
  62. <!-- ==================================================================== -->
  63. <xsl:template match="/" priority="-1">
  64. <xsl:text>
  65. </xsl:text>
  66. <toc role="chunk-toc">
  67. <xsl:text>
  68. </xsl:text>
  69. <xsl:apply-templates select="/" mode="toc"/>
  70. </toc>
  71. <xsl:text>
  72. </xsl:text>
  73. </xsl:template>
  74. </xsl:stylesheet>