map2javahelpset.xsl 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. 2005 All Rights Reserved. -->
  6. <xsl:stylesheet
  7. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  8. version="2.0">
  9. <xsl:param name="javahelpmap"/>
  10. <xsl:param name="javahelptoc"/>
  11. <xsl:param name="basedir"/>
  12. <xsl:param name="outputdir"/>
  13. <xsl:output
  14. method="xml"
  15. omit-xml-declaration="no"
  16. encoding="UTF-8"
  17. doctype-public="-//Sun Microsystems Inc.//DTD JavaHelp HelpSet Version 1.0//EN"
  18. doctype-system="http://java.sun.com/products/javahelp/helpset_1_0.dtd"
  19. indent="yes"/>
  20. <xsl:template match="*[contains(@class, ' map/map ')]">
  21. <helpset version="2.0">
  22. <title>
  23. <xsl:choose>
  24. <xsl:when test="*[contains(@class,' topic/title ')]">
  25. <xsl:value-of select="*[contains(@class,' topic/title ')]"/>
  26. </xsl:when>
  27. <xsl:when test="@title">
  28. <xsl:value-of select="@title"/>
  29. </xsl:when>
  30. <xsl:otherwise>
  31. <xsl:text>Sample Title</xsl:text>
  32. </xsl:otherwise>
  33. </xsl:choose>
  34. </title>
  35. <maps>
  36. <homeID>
  37. <xsl:variable name="filePath">
  38. <xsl:choose>
  39. <xsl:when
  40. test="contains($outputdir, ':\') or contains($outputdir, ':/')">
  41. <xsl:value-of select="concat('file:/', $outputdir)" />
  42. </xsl:when>
  43. <xsl:when test="starts-with($outputdir, '/')">
  44. <xsl:value-of select="concat('file://', $outputdir)" />
  45. </xsl:when>
  46. <xsl:when test="starts-with($basedir,'/')">
  47. <xsl:value-of select="concat('file://', $basedir, '/', $outputdir)" />
  48. </xsl:when>
  49. <xsl:otherwise>
  50. <xsl:value-of select="concat('file:/', $basedir, '/', $outputdir)" />
  51. </xsl:otherwise>
  52. </xsl:choose>
  53. </xsl:variable>
  54. <!--xsl:variable name="homeId" select="document(concat($filePath ,'/', $javahelpmap, '.jhm'), /)"-->
  55. <xsl:variable name="homeId">
  56. <xsl:value-of select="document(concat($filePath ,'/', $javahelpmap, '.jhm'))/map/mapID[1]/@target" />
  57. </xsl:variable>
  58. <xsl:choose>
  59. <xsl:when test="$homeId = ''">
  60. <!--xsl:when test="not(string($homeId))"-->
  61. <xsl:value-of select="'home'"/>
  62. </xsl:when>
  63. <xsl:otherwise>
  64. <xsl:value-of select="$homeId"/>
  65. </xsl:otherwise>
  66. </xsl:choose>
  67. </homeID>
  68. <mapref>
  69. <xsl:attribute name="location">
  70. <xsl:value-of select="$javahelpmap"/><xsl:text>.jhm</xsl:text>
  71. </xsl:attribute>
  72. </mapref>
  73. </maps>
  74. <view>
  75. <name>TOC</name>
  76. <label>TOC</label>
  77. <type>javax.help.TOCView</type>
  78. <data>
  79. <xsl:value-of select="$javahelptoc"/><xsl:text>.xml</xsl:text>
  80. </data>
  81. </view>
  82. <view mergetype="javax.help.AppendMerge">
  83. <name>index</name>
  84. <label>Index</label>
  85. <type>javax.help.IndexView</type>
  86. <data><xsl:value-of select="$javahelptoc"/><xsl:text>_index.xml</xsl:text></data>
  87. </view>
  88. <view>
  89. <name>Search</name>
  90. <label>Search</label>
  91. <type>javax.help.SearchView</type>
  92. <data engine="com.sun.java.help.search.DefaultSearchEngine">
  93. JavaHelpSearch </data>
  94. </view>
  95. </helpset>
  96. </xsl:template>
  97. </xsl:stylesheet>