map2TOC.xsl 3.2 KB

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