1
0

chunkfast.xsl 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?xml version='1.0' encoding='ISO-8859-1'?>
  2. <!--
  3. $LastChangedBy$
  4. $Date$
  5. -->
  6. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  7. xmlns="http://www.w3.org/1999/xhtml"
  8. xmlns:exsl="http://exslt.org/common"
  9. xmlns:cf="http://docbook.sourceforge.net/xmlns/chunkfast/1.0"
  10. version="1.0"
  11. exclude-result-prefixes="cf exsl">
  12. <!-- Top-level chunked code for fast processing.
  13. Import standart customized chunk code.
  14. Replaces {docbook-xsl}/xhtml/chunkfast.xsl
  15. Note: Using this file as the top-level for chunked output implies that
  16. profiling must be done on a previous step. -->
  17. <!-- Our master chunking templates -->
  18. <xsl:import href="chunk-master.xsl"/>
  19. <!-- Use chunk.fast code? 1 = yes, 0 = no -->
  20. <xsl:param name="chunk.fast" select="1"/>
  21. <!-- The code below was copied as-is from {docbook-xsl}/xhtml/chunkfast.xsl -->
  22. <xsl:variable name="chunks" select="exsl:node-set($chunk.hierarchy)//cf:div"/>
  23. <xsl:template name="process-chunk-element">
  24. <xsl:choose>
  25. <xsl:when test="$chunk.fast != 0 and function-available('exsl:node-set')">
  26. <xsl:variable name="genid" select="generate-id()"/>
  27. <xsl:variable name="div" select="$chunks[@id=$genid or @xml:id=$genid]"/>
  28. <xsl:variable name="prevdiv" select="($div/preceding-sibling::cf:div|$div/preceding::cf:div|$div/parent::cf:div)[last()]"/>
  29. <xsl:variable name="prev" select="key('genid', ($prevdiv/@id|$prevdiv/@xml:id)[1])"/>
  30. <xsl:variable name="nextdiv" select="($div/following-sibling::cf:div|$div/following::cf:div|$div/cf:div)[1]"/>
  31. <xsl:variable name="next" select="key('genid', ($nextdiv/@id|$nextdiv/@xml:id)[1])"/>
  32. <xsl:choose>
  33. <xsl:when test="$onechunk != 0 and parent::*">
  34. <xsl:apply-imports/>
  35. </xsl:when>
  36. <xsl:otherwise>
  37. <xsl:call-template name="process-chunk">
  38. <xsl:with-param name="prev" select="$prev"/>
  39. <xsl:with-param name="next" select="$next"/>
  40. </xsl:call-template>
  41. </xsl:otherwise>
  42. </xsl:choose>
  43. </xsl:when>
  44. <xsl:otherwise>
  45. <xsl:choose>
  46. <xsl:when test="$onechunk != 0 and not(parent::*)">
  47. <xsl:call-template name="chunk-all-sections"/>
  48. </xsl:when>
  49. <xsl:when test="$onechunk != 0">
  50. <xsl:apply-imports/>
  51. </xsl:when>
  52. <xsl:when test="$chunk.first.sections = 0">
  53. <xsl:call-template name="chunk-first-section-with-parent"/>
  54. </xsl:when>
  55. <xsl:otherwise>
  56. <xsl:call-template name="chunk-all-sections"/>
  57. </xsl:otherwise>
  58. </xsl:choose>
  59. </xsl:otherwise>
  60. </xsl:choose>
  61. </xsl:template>
  62. </xsl:stylesheet>