chunkfast.xsl 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  2. xmlns:exsl="http://exslt.org/common"
  3. xmlns:cf="http://docbook.sourceforge.net/xmlns/chunkfast/1.0"
  4. version="1.0"
  5. exclude-result-prefixes="cf exsl">
  6. <!-- ********************************************************************
  7. $Id: chunkfast.xsl 8345 2009-03-16 06:44:07Z bobstayton $
  8. ********************************************************************
  9. This file is part of the XSL DocBook Stylesheet distribution.
  10. See ../README or http://docbook.sf.net/release/xsl/current/ for
  11. copyright and other information.
  12. ******************************************************************** -->
  13. <!-- ==================================================================== -->
  14. <xsl:import href="chunk.xsl"/>
  15. <xsl:param name="chunk.fast" select="1"/>
  16. <xsl:variable name="chunks" select="exsl:node-set($chunk.hierarchy)//cf:div"/>
  17. <!-- ==================================================================== -->
  18. <xsl:template name="process-chunk-element">
  19. <xsl:choose>
  20. <xsl:when test="$chunk.fast != 0 and $exsl.node.set.available != 0">
  21. <xsl:variable name="genid" select="generate-id()"/>
  22. <xsl:variable name="div" select="$chunks[@id=$genid or @xml:id=$genid]"/>
  23. <xsl:variable name="prevdiv"
  24. select="($div/preceding-sibling::cf:div|$div/preceding::cf:div|$div/parent::cf:div)[last()]"/>
  25. <xsl:variable name="prev" select="key('genid', ($prevdiv/@id|$prevdiv/@xml:id)[1])"/>
  26. <xsl:variable name="nextdiv"
  27. select="($div/following-sibling::cf:div|$div/following::cf:div|$div/cf:div)[1]"/>
  28. <xsl:variable name="next" select="key('genid', ($nextdiv/@id|$nextdiv/@xml:id)[1])"/>
  29. <xsl:choose>
  30. <xsl:when test="$onechunk != 0 and parent::*">
  31. <xsl:apply-imports/>
  32. </xsl:when>
  33. <xsl:otherwise>
  34. <xsl:call-template name="process-chunk">
  35. <xsl:with-param name="prev" select="$prev"/>
  36. <xsl:with-param name="next" select="$next"/>
  37. </xsl:call-template>
  38. </xsl:otherwise>
  39. </xsl:choose>
  40. </xsl:when>
  41. <xsl:otherwise>
  42. <xsl:choose>
  43. <xsl:when test="$onechunk != 0 and not(parent::*)">
  44. <xsl:call-template name="chunk-all-sections"/>
  45. </xsl:when>
  46. <xsl:when test="$onechunk != 0">
  47. <xsl:apply-imports/>
  48. </xsl:when>
  49. <xsl:when test="$chunk.first.sections = 0">
  50. <xsl:call-template name="chunk-first-section-with-parent"/>
  51. </xsl:when>
  52. <xsl:otherwise>
  53. <xsl:call-template name="chunk-all-sections"/>
  54. </xsl:otherwise>
  55. </xsl:choose>
  56. </xsl:otherwise>
  57. </xsl:choose>
  58. </xsl:template>
  59. </xsl:stylesheet>