lfs-chunked.xsl 2.6 KB

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