瀏覽代碼

Updated XSL PDF code to match current packages and patches pages tagging.

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/6.2/BOOK@7715 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689
Manuel Canales Esparcia 19 年之前
父節點
當前提交
8035189ca6
共有 1 個文件被更改,包括 54 次插入0 次删除
  1. 54 0
      stylesheets/pdf/lfs-mixed.xsl

+ 54 - 0
stylesheets/pdf/lfs-mixed.xsl

@@ -16,6 +16,7 @@
     and to remove vertical space in pachages and patches pages. -->
  <xsl:template match="para">
     <xsl:choose>
+      <xsl:when test="child::ulink[@url=' ']"/>
       <xsl:when test="./@remap='verbatim'">
         <fo:block wrap-option="no-wrap"
                     white-space-collapse="false"
@@ -254,4 +255,57 @@
     </xsl:choose>
   </xsl:template>
 
+    <!-- Total packages size calculation -->
+  <xsl:template match="returnvalue">
+    <xsl:call-template name="calculation">
+     <xsl:with-param name="scope" select="../../variablelist"/>
+    </xsl:call-template>
+  </xsl:template>
+
+  <xsl:template name="calculation">
+    <xsl:param name="scope"/>
+    <xsl:param name="total">0</xsl:param>
+    <xsl:param name="position">1</xsl:param>
+    <xsl:variable name="tokens" select="count($scope/varlistentry)"/>
+    <xsl:variable name="token" select="$scope/varlistentry[$position]/term/token"/>
+    <xsl:variable name="size" select="substring-before($token,' KB')"/>
+    <xsl:variable name="rawsize">
+      <xsl:choose>
+        <xsl:when test="contains($size,',')">
+          <xsl:value-of select="concat(substring-before($size,','),substring-after($size,','))"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select="$size"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+    <xsl:choose>
+      <xsl:when test="$position &lt;= $tokens">
+        <xsl:call-template name="calculation">
+          <xsl:with-param name="scope" select="$scope"/>
+          <xsl:with-param name="position" select="$position +1"/>
+          <xsl:with-param name="total" select="$total + $rawsize"/>
+        </xsl:call-template>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:choose>
+          <xsl:when test="$total &lt; '1000'">
+            <xsl:value-of select="$total"/>
+            <xsl:text>  KB</xsl:text>
+          </xsl:when>
+          <xsl:when test="$total &gt; '1000' and $total &lt; '5000'">
+            <xsl:value-of select="substring($total,1,1)"/>
+            <xsl:text>,</xsl:text>
+            <xsl:value-of select="substring($total,2)"/>
+            <xsl:text>  KB</xsl:text>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:value-of select="round($total div 1024)"/>
+            <xsl:text>  MB</xsl:text>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
 </xsl:stylesheet>