map2docbook.xsl 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. <xsl:import href="dita2docbook.xsl"/>
  9. <xsl:output
  10. method="xml"
  11. indent="yes"
  12. omit-xml-declaration="no"
  13. standalone="no"
  14. doctype-public="-//OASIS//DTD DocBook XML V4.2//EN"
  15. doctype-system="http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"/>
  16. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  17. - MAP
  18. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  19. <xsl:template match="/">
  20. <xsl:apply-templates/>
  21. </xsl:template>
  22. <xsl:template match="*[contains(@class,' map/map ')]">
  23. <article>
  24. <xsl:copy-of select="@id"/>
  25. <xsl:choose>
  26. <xsl:when test="*[contains(@class,' topic/title ')]">
  27. <title>
  28. <xsl:value-of select="*[contains(@class,' topic/title ')]"/>
  29. </title>
  30. </xsl:when>
  31. <xsl:when test="@title">
  32. <xsl:value-of select="@title"/>
  33. </xsl:when>
  34. </xsl:choose>
  35. <para/>
  36. <!-- doesn't handle reltables or topicgroups -->
  37. <xsl:apply-templates select="*[contains(@class,' map/topicref ')]"/>
  38. </article>
  39. </xsl:template>
  40. <xsl:template match="*[contains(@class,' map/topicref ')]" name="topicref">
  41. <xsl:param name="element" select="'section'"/>
  42. <xsl:variable name="hrefValue">
  43. <xsl:choose>
  44. <xsl:when test="contains(@href, '#')">
  45. <xsl:value-of select="substring-before(@href, '#')"/>
  46. </xsl:when>
  47. <xsl:otherwise>
  48. <xsl:value-of select="@href"/>
  49. </xsl:otherwise>
  50. </xsl:choose>
  51. </xsl:variable>
  52. <xsl:choose>
  53. <xsl:when test="$hrefValue and not($hrefValue='') and (empty(@scope) or @scope = 'local')">
  54. <xsl:apply-templates select="document($hrefValue, /)/*">
  55. <xsl:with-param name="element" select="$element"/>
  56. <xsl:with-param name="childrefs"
  57. select="*[contains(@class,' map/topicref ')]"/>
  58. </xsl:apply-templates>
  59. </xsl:when>
  60. <xsl:when test="@navtitle">
  61. <xsl:element name="{$element}">
  62. <title>
  63. <xsl:value-of select="@navtitle"/>
  64. </title>
  65. <xsl:apply-templates select="*[contains(@class,' map/topicref ')]"/>
  66. </xsl:element>
  67. </xsl:when>
  68. <xsl:otherwise>
  69. <xsl:apply-templates select="*[contains(@class,' map/topicref ')]"/>
  70. </xsl:otherwise>
  71. </xsl:choose>
  72. </xsl:template>
  73. </xsl:stylesheet>