Changeset f4f631d for BOOK/stylesheets


Ignore:
Timestamp:
May 13, 2006, 11:52:09 AM (19 years ago)
Author:
Jim Gifford <clfs@…>
Branches:
clfs-1.2, clfs-2.1, clfs-3.0.0-systemd, clfs-3.0.0-sysvinit, master, systemd, sysvinit
Children:
96fbea0
Parents:
2476d0e
Message:

r3442@server (orig r1581): manuel | 2006-05-13 10:05:45 -0700
Automatized "Total size of these packages" calculation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BOOK/stylesheets/xhtml/lfs-mixed.xsl

    r2476d0e rf4f631d  
    267267  </xsl:template>
    268268
     269    <!-- Total packages size calculation -->
     270  <xsl:template match="returnvalue">
     271    <xsl:call-template name="calculation">
     272     <xsl:with-param name="scope" select="../../variablelist"/>
     273    </xsl:call-template>
     274  </xsl:template>
     275
     276  <xsl:template name="calculation">
     277    <xsl:param name="scope"/>
     278    <xsl:param name="total">0</xsl:param>
     279    <xsl:param name="position">1</xsl:param>
     280    <xsl:variable name="tokens" select="count($scope/varlistentry)"/>
     281    <xsl:variable name="token" select="$scope/varlistentry[$position]/term/token"/>
     282    <xsl:variable name="size" select="substring-before($token,' KB')"/>
     283    <xsl:variable name="rawsize">
     284      <xsl:choose>
     285        <xsl:when test="contains($size,',')">
     286          <xsl:value-of select="concat(substring-before($size,','),substring-after($size,','))"/>
     287        </xsl:when>
     288        <xsl:otherwise>
     289          <xsl:value-of select="$size"/>
     290        </xsl:otherwise>
     291      </xsl:choose>
     292    </xsl:variable>
     293    <xsl:choose>
     294      <xsl:when test="$position &lt;= $tokens">
     295        <xsl:call-template name="calculation">
     296          <xsl:with-param name="scope" select="$scope"/>
     297          <xsl:with-param name="position" select="$position +1"/>
     298          <xsl:with-param name="total" select="$total + $rawsize"/>
     299        </xsl:call-template>
     300      </xsl:when>
     301      <xsl:otherwise>
     302        <xsl:choose>
     303          <xsl:when test="$total &lt; '1000'">
     304            <xsl:value-of select="$total"/>
     305            <xsl:text>  KB</xsl:text>
     306          </xsl:when>
     307          <xsl:when test="$total &gt; '1000' and $total &lt; '5000'">
     308            <xsl:value-of select="substring($total,1,1)"/>
     309            <xsl:text>,</xsl:text>
     310            <xsl:value-of select="substring($total,2)"/>
     311            <xsl:text>  KB</xsl:text>
     312          </xsl:when>
     313          <xsl:otherwise>
     314            <xsl:value-of select="round($total div 1024)"/>
     315            <xsl:text>  MB</xsl:text>
     316          </xsl:otherwise>
     317        </xsl:choose>
     318      </xsl:otherwise>
     319    </xsl:choose>
     320  </xsl:template>
     321
    269322</xsl:stylesheet>
Note: See TracChangeset for help on using the changeset viewer.