Эх сурвалжийг харах

Added chunk.fast code to improve chunked XHTML output rendering time.
This requires Makefile changes due that now profiling must be done in two steps.

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/new-xsl@8124 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

Manuel Canales Esparcia 18 жил өмнө
parent
commit
f0c37eb55f
2 өөрчлөгдсөн 103 нэмэгдсэн , 35 устгасан
  1. 56 35
      lfs-chunked.xsl
  2. 47 0
      lfs-chunked1.xsl

+ 56 - 35
lfs-chunked.xsl

@@ -2,44 +2,65 @@
 
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 xmlns="http://www.w3.org/1999/xhtml"
-                version="1.0">
-
-   <!-- Top-level chunked output template.
-        Include customized chunks templates.
-        Replaces {docbook-xsl}/xhtml/profile-chunk.xsl -->
-
-    <!-- Our master non-chunking presentation templates -->
-  <xsl:import href="lfs-chunked2.xsl"/>
-
-    <!-- Upstream chunk code named templates -->
-  <xsl:import href="docbook-xsl-snapshot/xhtml/chunk-common.xsl"/>
-
-    <!-- Upstream profiled chunk code match templates -->
-  <xsl:include href="docbook-xsl-snapshot/xhtml/profile-chunk-code.xsl"/>
-
-    <!-- Including our customized chunks templates -->
-  <xsl:include href="xhtml/lfs-index.xsl"/>
-  <xsl:include href="xhtml/lfs-legalnotice.xsl"/>
-  <xsl:include href="xhtml/lfs-navigational.xsl"/>
-
-    <!-- sect1:
-           Prevent creation of dummy sect1 files used to emulate sub-chapters. -->
-    <!-- The original template is in {docbook-xsl}/xhtml/profile-chunk-code.xsl
-         It match also others sect* tags. The code for that tags is unchanged. -->
-  <xsl:template match="sect1">
-    <xsl:variable name="ischunk">
-      <xsl:call-template name="chunk"/>
-    </xsl:variable>
+                xmlns:exsl="http://exslt.org/common"
+                xmlns:cf="http://docbook.sourceforge.net/xmlns/chunkfast/1.0"
+                version="1.0"
+                exclude-result-prefixes="cf exsl">
+
+   <!-- Top-level chunked templates.
+        Import customized chunks templates.
+        Replaces {docbook-xsl}/xhtml/chunkfast.xsl -->
+
+    <!-- Our master chunking templates -->
+  <xsl:import href="lfs-chunked1.xsl"/>
+
+    <!-- Use chunk.fast code? 1 = yes, 0 = no -->
+  <xsl:param name="chunk.fast" select="1"/>
+
+  <!-- The code below was copied as-is from {docbook-xsl}/xhtml/chunkfast.xsl -->
+
+  <xsl:variable name="chunks" select="exsl:node-set($chunk.hierarchy)//cf:div"/>
+
+  <xsl:template name="process-chunk-element">
     <xsl:choose>
-      <xsl:when test="@role = 'dummy'"/>
-      <xsl:when test="not(parent::*)">
-        <xsl:call-template name="process-chunk-element"/>
-      </xsl:when>
-      <xsl:when test="$ischunk = 0">
-        <xsl:apply-imports/>
+      <xsl:when test="$chunk.fast != 0 and function-available('exsl:node-set')">
+        <xsl:variable name="genid" select="generate-id()"/>
+
+        <xsl:variable name="div" select="$chunks[@id=$genid or @xml:id=$genid]"/>
+
+        <xsl:variable name="prevdiv" select="($div/preceding-sibling::cf:div|$div/preceding::cf:div|$div/parent::cf:div)[last()]"/>
+        <xsl:variable name="prev" select="key('genid', ($prevdiv/@id|$prevdiv/@xml:id)[1])"/>
+
+        <xsl:variable name="nextdiv" select="($div/following-sibling::cf:div|$div/following::cf:div|$div/cf:div)[1]"/>
+        <xsl:variable name="next" select="key('genid', ($nextdiv/@id|$nextdiv/@xml:id)[1])"/>
+
+        <xsl:choose>
+          <xsl:when test="$onechunk != 0 and parent::*">
+            <xsl:apply-imports/>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:call-template name="process-chunk">
+              <xsl:with-param name="prev" select="$prev"/>
+              <xsl:with-param name="next" select="$next"/>
+            </xsl:call-template>
+          </xsl:otherwise>
+        </xsl:choose>
       </xsl:when>
       <xsl:otherwise>
-        <xsl:call-template name="process-chunk-element"/>
+        <xsl:choose>
+          <xsl:when test="$onechunk != 0 and not(parent::*)">
+            <xsl:call-template name="chunk-all-sections"/>
+          </xsl:when>
+          <xsl:when test="$onechunk != 0">
+            <xsl:apply-imports/>
+          </xsl:when>
+          <xsl:when test="$chunk.first.sections = 0">
+            <xsl:call-template name="chunk-first-section-with-parent"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:call-template name="chunk-all-sections"/>
+          </xsl:otherwise>
+        </xsl:choose>
       </xsl:otherwise>
     </xsl:choose>
   </xsl:template>

+ 47 - 0
lfs-chunked1.xsl

@@ -0,0 +1,47 @@
+<?xml version='1.0' encoding='ISO-8859-1'?>
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns="http://www.w3.org/1999/xhtml"
+                version="1.0">
+
+   <!-- Chunked output templates.
+        Include customized chunks templates.
+        Replaces {docbook-xsl}/xhtml/chunk.xsl -->
+
+    <!-- Our master non-chunking presentation templates -->
+  <xsl:import href="lfs-chunked2.xsl"/>
+
+    <!-- Upstream chunk code named templates -->
+  <xsl:import href="docbook-xsl-snapshot/xhtml/chunk-common.xsl"/>
+
+    <!-- Upstream chunk code match templates -->
+  <xsl:include href="docbook-xsl-snapshot/xhtml/chunk-code.xsl"/>
+
+    <!-- Including our customized chunks templates -->
+  <xsl:include href="xhtml/lfs-index.xsl"/>
+  <xsl:include href="xhtml/lfs-legalnotice.xsl"/>
+  <xsl:include href="xhtml/lfs-navigational.xsl"/>
+
+    <!-- sect1:
+           Prevent creation of dummy sect1 files used to emulate sub-chapters. -->
+    <!-- The original template is in {docbook-xsl}/xhtml/chunk-code.xsl
+         It match also others sect* tags. The code for that tags is unchanged. -->
+  <xsl:template match="sect1">
+    <xsl:variable name="ischunk">
+      <xsl:call-template name="chunk"/>
+    </xsl:variable>
+    <xsl:choose>
+      <xsl:when test="@role = 'dummy'"/>
+      <xsl:when test="not(parent::*)">
+        <xsl:call-template name="process-chunk-element"/>
+      </xsl:when>
+      <xsl:when test="$ischunk = 0">
+        <xsl:apply-imports/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:call-template name="process-chunk-element"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+</xsl:stylesheet>