topic-maker.xsl 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <xsl:stylesheet
  3. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  4. xmlns:exsl="http://exslt.org/common"
  5. xmlns="http://docbook.org/ns/docbook"
  6. exclude-result-prefixes="exsl"
  7. version="1.0">
  8. <!-- $Id: topic-maker.xsl,v 1.3 2012-04-16 00:29:35 bobs Exp $ -->
  9. <!-- This stylesheet convert DocBook elements into topic element.
  10. The chunking takes place elsewhere. -->
  11. <xsl:import href="../xhtml/docbook.xsl"/>
  12. <xsl:param name="assembly.filename">myassembly.xml</xsl:param>
  13. <xsl:param name="chunk.section.depth" select="3"/>
  14. <xsl:param name="chunk.first.sections" select="1"/>
  15. <xsl:param name="use.id.as.filename" select="1"/>
  16. <xsl:param name="html.ext">.xml</xsl:param>
  17. <xsl:param name="base.dir">topics/</xsl:param>
  18. <xsl:param name="root.filename" select="local-name(/*)"/>
  19. <xsl:param name="html.extra.head.links" select="0"/>
  20. <xsl:param name="stylesheet.result.type">xhtml</xsl:param>
  21. <xsl:param name="navig.showtitles" select="0"/>
  22. <xsl:param name="suppress.navigation" select="1"/>
  23. <xsl:param name="chunk.append"/>
  24. <xsl:param name="chunk.quietly" select="0"/>
  25. <xsl:param name="chunker.output.method" select="'xml'"/>
  26. <xsl:param name="chunker.output.encoding" select="'UTF-8'"/>
  27. <xsl:param name="chunker.output.indent" select="'no'"/>
  28. <xsl:param name="chunker.output.omit-xml-declaration" select="'no'"/>
  29. <xsl:param name="chunker.output.standalone" select="'no'"/>
  30. <xsl:param name="chunker.output.doctype-public" select="''"/>
  31. <xsl:param name="chunker.output.doctype-system" select="''"/>
  32. <xsl:param name="namespace">http://docbook.org/ns/docbook</xsl:param>
  33. <!-- These elements are converted to topic elements -->
  34. <xsl:param name="topic.elements">preface chapter article section</xsl:param>
  35. <xsl:variable name="topic.list"
  36. select="concat(' ', normalize-space($topic.elements), ' ')"/>
  37. <!-- Default behavior is identity copy -->
  38. <xsl:template match="node()|@*">
  39. <xsl:copy>
  40. <xsl:apply-templates select="@*"/>
  41. <xsl:apply-templates/>
  42. </xsl:copy>
  43. </xsl:template>
  44. <xsl:template match="preface|chapter|appendix|section|article">
  45. <xsl:variable name="element.name">
  46. <xsl:call-template name="element.name"/>
  47. </xsl:variable>
  48. <xsl:element name="{$element.name}" namespace="{$namespace}">
  49. <xsl:apply-templates select="@*"/>
  50. <xsl:apply-templates/>
  51. </xsl:element>
  52. </xsl:template>
  53. <xsl:template name="element.name">
  54. <xsl:param name="node" select="."/>
  55. <xsl:variable name="src.element" select="concat(' ', local-name($node), ' ')"/>
  56. <xsl:choose>
  57. <xsl:when test="contains($topic.list, $src.element)">
  58. <xsl:text>topic</xsl:text>
  59. </xsl:when>
  60. <xsl:otherwise>
  61. <xsl:value-of select="local-name($node)"/>
  62. </xsl:otherwise>
  63. </xsl:choose>
  64. </xsl:template>
  65. </xsl:stylesheet>