mapwalker.xsl 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. <!-- write technique adapted from Norman Walsh's DocBook XSLT
  7. first instance technique adapted from Jeni Tennison and Steve Muench -->
  8. <xsl:stylesheet version="2.0"
  9. xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  10. <!-- stylesheet imports -->
  11. <xsl:key name="topicref"
  12. match="*[contains(@class, ' map/topicref ')]"
  13. use="@href"/>
  14. <xsl:template match="/">
  15. <xsl:apply-templates select="*[contains(@class,' map/map ')]"/>
  16. </xsl:template>
  17. <xsl:template match="*[contains(@class,' map/map ')]">
  18. <xsl:apply-templates select="*[contains(@class,' map/topicref ')]"/>
  19. </xsl:template>
  20. <xsl:template match="*[contains(@class,' map/topicref ')]">
  21. <xsl:param name="infile" select="@href"/>
  22. <xsl:param name="outroot">
  23. <xsl:choose>
  24. <xsl:when test="contains($infile, '.xml')">
  25. <xsl:value-of select="substring-before($infile, '.xml')"/>
  26. </xsl:when>
  27. <xsl:when test="contains($infile, '.dita')">
  28. <xsl:value-of select="substring-before($infile, '.dita')"/>
  29. </xsl:when>
  30. <xsl:otherwise>
  31. <xsl:value-of select="$infile"/>
  32. </xsl:otherwise>
  33. </xsl:choose>
  34. </xsl:param>
  35. <xsl:param name="outfile">
  36. <xsl:choose>
  37. <xsl:when test="contains($infile, '.xml') or contains($infile, '.dita')">
  38. <xsl:value-of select="concat($outroot, $OUTEXT)"/>
  39. </xsl:when>
  40. <xsl:otherwise>
  41. <xsl:value-of select="$infile"/>
  42. </xsl:otherwise>
  43. </xsl:choose>
  44. </xsl:param>
  45. <xsl:param name="nodeID" select="generate-id(.)"/>
  46. <xsl:param name="isFirstFile">
  47. <xsl:choose>
  48. <xsl:when test="$infile and $infile!=''">
  49. <xsl:value-of
  50. select="$nodeID = generate-id(key('topicref', $infile)[1])"/>
  51. </xsl:when>
  52. <xsl:otherwise>
  53. <xsl:value-of select="true()"/>
  54. </xsl:otherwise>
  55. </xsl:choose>
  56. </xsl:param>
  57. <xsl:param name="isFirst" select="string($isFirstFile)='true'"/>
  58. <xsl:apply-templates select="." mode="process">
  59. <xsl:with-param name="infile" select="@href"/>
  60. <xsl:with-param name="outroot" select="$outroot"/>
  61. <xsl:with-param name="outfile" select="$outfile"/>
  62. <xsl:with-param name="nodeID" select="$nodeID"/>
  63. <xsl:with-param name="isFirst" select="$isFirst"/>
  64. </xsl:apply-templates>
  65. </xsl:template>
  66. <!-- required overrides -->
  67. <xsl:template match="*[contains(@class,' map/topicref ')]" mode="process">
  68. <xsl:param name="infile"/>
  69. <xsl:param name="outroot"/>
  70. <xsl:param name="outfile"/>
  71. <xsl:param name="nodeID"/>
  72. <xsl:param name="isFirst"/>
  73. <xsl:message terminate="yes">
  74. <xsl:text>no process rule for topicref</xsl:text>
  75. </xsl:message>
  76. </xsl:template>
  77. </xsl:stylesheet>