map2TOC.xsl 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!--
  3. This file is part of the DITA Open Toolkit project.
  4. Copyright 2004, 2005 IBM Corporation
  5. See the accompanying LICENSE file for applicable license.
  6. -->
  7. <xsl:stylesheet version="2.0"
  8. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  9. xmlns:html="http://www.w3.org/1999/xhtml"
  10. exclude-result-prefixes="html">
  11. <!-- stylesheet imports -->
  12. <xsl:import href="plugin:org.dita.xhtml:xsl/xslhtml/mapwalker.xsl"/>
  13. <xsl:template match="*[contains(@class,' map/map ')]">
  14. <xsl:apply-templates select="." mode="toctop"/>
  15. </xsl:template>
  16. <xsl:template match="*[contains(@class,' map/topicref ')]" mode="process">
  17. <xsl:param name="infile"/>
  18. <xsl:param name="outroot"/>
  19. <xsl:param name="outfile"/>
  20. <xsl:param name="nodeID"/>
  21. <xsl:param name="isFirst"/>
  22. <xsl:variable name="subtopicNodes"
  23. select="*[contains(@class,' map/topicref ')]"/>
  24. <xsl:variable name="title">
  25. <xsl:apply-templates select="." mode="title">
  26. <xsl:with-param name="isFirst" select="$isFirst"/>
  27. <xsl:with-param name="infile" select="$infile"/>
  28. <xsl:with-param name="nodeID" select="$nodeID"/>
  29. <xsl:with-param name="outfile" select="$outfile"/>
  30. </xsl:apply-templates>
  31. </xsl:variable>
  32. <xsl:apply-templates select="." mode="tocentry">
  33. <xsl:with-param name="infile" select="$infile"/>
  34. <xsl:with-param name="outroot" select="$outroot"/>
  35. <xsl:with-param name="outfile" select="$outfile"/>
  36. <xsl:with-param name="nodeID" select="$nodeID"/>
  37. <xsl:with-param name="isFirst" select="$isFirst"/>
  38. <xsl:with-param name="subtopicNodes" select="$subtopicNodes"/>
  39. <xsl:with-param name="title" select="$title"/>
  40. </xsl:apply-templates>
  41. </xsl:template>
  42. <!-- required overrides -->
  43. <xsl:template match="*[contains(@class,' map/map ')]" mode="toctop">
  44. <xsl:message terminate="yes">
  45. <xsl:text>no toctop rule for map</xsl:text>
  46. </xsl:message>
  47. </xsl:template>
  48. <xsl:template match="*[contains(@class,' map/topicref ')]" mode="tocentry">
  49. <xsl:param name="infile"/>
  50. <xsl:param name="outroot"/>
  51. <xsl:param name="outfile"/>
  52. <xsl:param name="nodeID"/>
  53. <xsl:param name="isFirst"/>
  54. <xsl:param name="subtopicNodes"/>
  55. <xsl:param name="title"/>
  56. <xsl:message terminate="yes">
  57. <xsl:text>no tocentry rule for topicref</xsl:text>
  58. </xsl:message>
  59. </xsl:template>
  60. <!-- topic title -->
  61. <xsl:template match="*[contains(@class,' map/topicref ')]" mode="title">
  62. <xsl:param name="isFirst"/>
  63. <xsl:param name="infile"/>
  64. <xsl:param name="nodeID"/>
  65. <xsl:param name="outfile"/>
  66. <xsl:choose>
  67. <xsl:when test="*[contains(@class,'- map/topicmeta ')]/*[contains(@class, '- topic/navtitle ')]">
  68. <xsl:value-of select="*[contains(@class,'- map/topicmeta ')]/*[contains(@class, '- topic/navtitle ')]"/>
  69. </xsl:when>
  70. <xsl:when test="not(*[contains(@class,'- map/topicmeta ')]/*[contains(@class, '- topic/navtitle ')]) and @navtitle"><xsl:value-of select="@navtitle"/></xsl:when>
  71. <xsl:otherwise>
  72. <xsl:message>
  73. <xsl:text>neither title nor href</xsl:text>
  74. </xsl:message>
  75. <xsl:text></xsl:text>
  76. </xsl:otherwise>
  77. </xsl:choose>
  78. </xsl:template>
  79. </xsl:stylesheet>