cvs commit: BLFS/BOOK/stylesheets/xhtml blfs-index.xsl blfs-toc.xsl

larry at linuxfromscratch.org larry at linuxfromscratch.org
Thu May 6 20:51:34 PDT 2004


larry       04/05/06 21:51:34

  Modified:    BOOK/stylesheets blfs-chunked.xsl blfs.css
  Added:       BOOK/stylesheets/xhtml blfs-index.xsl blfs-toc.xsl
  Log:
  updated stylesheets to match LFS
  
  Revision  Changes    Path
  1.2       +5 -1      BLFS/BOOK/stylesheets/blfs-chunked.xsl
  
  Index: blfs-chunked.xsl
  ===================================================================
  RCS file: /home/cvsroot/BLFS/BOOK/stylesheets/blfs-chunked.xsl,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- blfs-chunked.xsl	13 Apr 2004 01:59:18 -0000	1.1
  +++ blfs-chunked.xsl	7 May 2004 03:51:34 -0000	1.2
  @@ -4,11 +4,15 @@
                   version="1.0">
   
     <!-- We use XHTML -->
  -  <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/xhtml/chunk.xsl"/>
  +  <xsl:import href="http://docbook.sourceforge.net/release/xsl/1.65.1/xhtml/chunk.xsl"/>
     <xsl:param name="chunker.output.encoding" select="'ISO-8859-1'"/>
   
     <!-- The CSS Stylesheet -->
     <xsl:param name="html.stylesheet" select="'../stylesheets/blfs.css'"/>
  +
  +  <!-- Include our customised templates -->
  +  <xsl:include href="xhtml/blfs-toc.xsl"/>
  +  <xsl:include href="xhtml/blfs-index.xsl"/>
   
     <!-- Use graphics in admonitions -->
     <xsl:param name="admon.graphics" select="1"/>
  
  
  
  1.2       +15 -0     BLFS/BOOK/stylesheets/blfs.css
  
  Index: blfs.css
  ===================================================================
  RCS file: /home/cvsroot/BLFS/BOOK/stylesheets/blfs.css,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- blfs.css	13 Apr 2004 01:59:18 -0000	1.1
  +++ blfs.css	7 May 2004 03:51:34 -0000	1.2
  @@ -107,3 +107,18 @@
   .command {
       font-family: courier, monospace;
   }
  +
  +.item {
  +    width: 15em;
  +    float: left;
  +}
  +
  +.secitem {
  +    font-weight: normal;
  +    width: 12.5em;
  +    float: left;
  +}
  +
  +.toc ul, .index ul, .navheader ul, .navfooter ul {
  +	list-style: none;
  +}
  
  
  
  1.1                  BLFS/BOOK/stylesheets/xhtml/blfs-index.xsl
  
  Index: blfs-index.xsl
  ===================================================================
  <?xml version='1.0' encoding='ISO-8859-1'?>
  <!DOCTYPE xsl:stylesheet [
  <!ENTITY lowercase "'abcdefghijklmnopqrstuvwxyz'">
  <!ENTITY uppercase "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'">
  <!ENTITY primary   'normalize-space(concat(primary/@sortas, primary[not(@sortas)]))'>
  <!ENTITY scope 'count(ancestor::node()|$scope) = count(ancestor::node())'>
  ]>
  
  <!-- Version 0.8.0 - Manuel Canales Esparcia <macana at lfs-es.org> -->
  
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  xmlns="http://www.w3.org/1999/xhtml"
                  version="1.0">
  
  	<!--Index Stuff-->
  
      <!--Filename-->
    <xsl:template match="index" mode="recursive-chunk-filename">
      <xsl:text>longindex.html</xsl:text>
    </xsl:template>
  
      <!--Title-->
    <xsl:template match="index" mode="title.markup">
    	<xsl:param name="allow-anchors" select="0"/>
      <xsl:text>Index of packages and important installed files</xsl:text>
  	</xsl:template>
  
    	<!--Divisions-->
    <xsl:template match="indexterm" mode="index-div">
      <xsl:param name="scope" select="."/>
      <xsl:variable name="key" select="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
      <xsl:variable name="divtitle" select="translate($key, &lowercase;, &uppercase;)"/>
      	<!-- Make sure that we don't generate a div if there are no terms in scope -->
      <xsl:if test="key('letter', $key)[&scope;] [count(.|key('primary', &primary;)[&scope;][1]) = 1]">
        <div class="indexdiv">
          <xsl:if test="contains(concat(&lowercase;, &uppercase;), $key)">
            <h2>
            	<xsl:choose>
              	<xsl:when test="$divtitle = 'A'">
                	<xsl:text>Packages</xsl:text>
               </xsl:when>
               <xsl:when test="$divtitle = 'B'">
                	<xsl:text>Programs</xsl:text>
               </xsl:when>
               <xsl:when test="$divtitle = 'C'">
                	<xsl:text>Libraries</xsl:text>
               </xsl:when>
               <xsl:when test="$divtitle = 'D'">
                	<xsl:text>Scripts</xsl:text>
               </xsl:when>
                <xsl:when test="$divtitle = 'E'">
                    <xsl:text>Others</xsl:text>
                </xsl:when>
               <xsl:otherwise>
            		<xsl:value-of select="$divtitle"/>
  						</xsl:otherwise>
             </xsl:choose>
            </h2>
          </xsl:if>
          <ul>
            <xsl:apply-templates select="key('letter', $key)[&scope;]
            				[count(.|key('primary', &primary;)[&scope;][1])=1]" mode="index-primary">
              <xsl:with-param name="scope" select="$scope"/>
              <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
            </xsl:apply-templates>
          </ul>
        </div>
      </xsl:if>
    </xsl:template>
  
    	<!-- Dropping the separator from here-->
    <xsl:template match="indexterm" mode="reference">
      <xsl:param name="scope" select="."/>
        <xsl:call-template name="reference">
          <xsl:with-param name="zones" select="normalize-space(@zone)"/>
          <xsl:with-param name="scope" select="$scope"/>
        </xsl:call-template>
  	</xsl:template>
  
    	<!-- Changing the output tags and re-addind the separator-->
    <xsl:template match="indexterm" mode="index-primary">
      <xsl:param name="scope" select="."/>
      <xsl:variable name="key" select="&primary;"/>
      <xsl:variable name="refs" select="key('primary', $key)[&scope;]"/>
      <li>
      	<strong class="item">
        	<xsl:value-of select="primary"/>
          <xsl:text>: </xsl:text>
  			</strong>
        <xsl:for-each select="$refs[generate-id() = generate-id(key('primary-section',
        				concat($key, " ", generate-id((ancestor-or-self::book |ancestor-or-self::part
                |ancestor-or-self::chapter |ancestor-or-self::appendix |ancestor-or-self::preface
                |ancestor-or-self::sect1 |ancestor-or-self::sect2 |ancestor-or-self::sect3
                |ancestor-or-self::sect4 |ancestor-or-self::sect5 |ancestor-or-self::index)[last()])))[&scope;][1])]">
          <xsl:apply-templates select="." mode="reference">
            <xsl:with-param name="scope" select="$scope"/>
          </xsl:apply-templates>
        </xsl:for-each>
      	<xsl:if test="$refs/secondary">
          <ul>
            <xsl:apply-templates select="$refs[secondary and count(.|key('secondary', 
            				concat($key, " ", normalize-space(concat(secondary/@sortas,
                    secondary[not(@sortas)]))))[&scope;][1]) = 1]" mode="index-secondary">
              <xsl:with-param name="scope" select="$scope"/>
              <xsl:sort select="translate(normalize-space(concat(secondary/@sortas, 
              				secondary[not(@sortas)])), &lowercase;, &uppercase;)"/>
            </xsl:apply-templates>
       		</ul>
      	</xsl:if>
      </li>
    </xsl:template>
    <xsl:template match="indexterm" mode="index-secondary">
      <xsl:param name="scope" select="."/>
      <xsl:variable name="key" select="concat(&primary;, " ",
      				normalize-space(concat(secondary/@sortas, secondary[not(@sortas)])))"/>
      <xsl:variable name="refs" select="key('secondary', $key)[&scope;]"/>
      <li>
      	<strong class="secitem">
        	<xsl:value-of select="secondary"/>
          <xsl:text>: </xsl:text>
  			</strong>
        <xsl:for-each select="$refs[generate-id() = generate-id(key('secondary-section',
        				concat($key, " ", generate-id((ancestor-or-self::book |ancestor-or-self::part
                |ancestor-or-self::chapter |ancestor-or-self::appendix |ancestor-or-self::preface
                |ancestor-or-self::sect1 |ancestor-or-self::sect2 |ancestor-or-self::sect3
                |ancestor-or-self::sect4 |ancestor-or-self::sect5 |ancestor-or-self::index)[last()])))[&scope;][1])]">
          <xsl:apply-templates select="." mode="reference">
            <xsl:with-param name="scope" select="$scope"/>
          </xsl:apply-templates>
        </xsl:for-each>
      </li>
    </xsl:template>
  
      <!--Links (This template also fix a bug in the original code)-->
    <xsl:template name="reference">
      <xsl:param name="scope" select="."/>
      <xsl:param name="zones"/>
      <xsl:choose>
        <xsl:when test="contains($zones, ' ')">
          <xsl:variable name="zone" select="substring-before($zones, ' ')"/>
          <xsl:variable name="zone2" select="substring-after($zones, ' ')"/>
          <xsl:variable name="target" select="key('sections', $zone)[&scope;]"/>
          <xsl:variable name="target2" select="key('sections', $zone2)[&scope;]"/>
          <a>
            <xsl:attribute name="href">
              <xsl:call-template name="href.target.uri">
                <xsl:with-param name="object" select="$target[1]"/>
              </xsl:call-template>
            </xsl:attribute>
            <xsl:apply-templates select="$target[1]" mode="index-title-content"/>
          </a>
          <xsl:text> -- </xsl:text>
          <a>
            <xsl:attribute name="href">
              <xsl:call-template name="href.target.uri">
                <xsl:with-param name="object" select="$target2[1]"/>
              </xsl:call-template>
            </xsl:attribute>
            <xsl:text>description</xsl:text>
          </a>
        </xsl:when>
        <xsl:otherwise>
          <xsl:variable name="zone" select="$zones"/>
          <xsl:variable name="target" select="key('sections', $zone)[&scope;]"/>
          <a>
            <xsl:attribute name="href">
              <xsl:call-template name="href.target.uri">
                <xsl:with-param name="object" select="$target[1]"/>
              </xsl:call-template>
            </xsl:attribute>
            <xsl:apply-templates select="$target[1]" mode="index-title-content"/>
          </a>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  BLFS/BOOK/stylesheets/xhtml/blfs-toc.xsl
  
  Index: blfs-toc.xsl
  ===================================================================
  <?xml version='1.0' encoding='ISO-8859-1'?>
  
  <!-- Version 0.8.0 - Manuel Canales Esparcia <macana at lfs-es.org> -->
  
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  xmlns="http://www.w3.org/1999/xhtml"
                  version="1.0">
  
  
  <!--TOC stuff-->
    <xsl:param name="generate.toc">
      appendix  toc
      book      toc,title,figure,table,example,equation
      chapter   nop
      part      toc
      preface   nop
      qandadiv  nop
      qandaset  nop
      reference nop
      sect1     nop
      sect2     nop
      sect3     nop
      sect4     nop
      sect5     nop
      section   nop
      set       nop
    </xsl:param>
  
    <xsl:param name="toc.section.depth">1</xsl:param>
  
    <xsl:param name="toc.max.depth">3</xsl:param>
  
      <!-- Type of list-->
    <xsl:param name="toc.list.type">ul</xsl:param>
  
      <!--Adding the h* tags and dropping redundats links-->
    <xsl:template name="toc.line">
      <xsl:param name="toc-context" select="."/>
      <xsl:param name="depth" select="1"/>
      <xsl:param name="depth.from.context" select="8"/>
      <xsl:choose>
        <xsl:when test="local-name(.) = 'sect1'">
          <span>
            <xsl:attribute name="class"><xsl:value-of select="local-name(.)"/></xsl:attribute>
            <a>
              <xsl:attribute name="href">
                <xsl:call-template name="href.target">
                  <xsl:with-param name="context" select="$toc-context"/>
                </xsl:call-template>
              </xsl:attribute>
              <xsl:apply-templates select="." mode="titleabbrev.markup"/>
            </a>
          </span>
        </xsl:when>
        <xsl:when test="local-name(.) = 'chapter' or local-name(.) = 'preface'">
          <h4>
            <span>
              <xsl:attribute name="class"><xsl:value-of select="local-name(.)"/></xsl:attribute>
              <xsl:variable name="label">
                <xsl:apply-templates select="." mode="label.markup"/>
              </xsl:variable>
              <xsl:copy-of select="$label"/>
              <xsl:if test="$label != ''">
                <xsl:value-of select="$autotoc.label.separator"/>
              </xsl:if>
              <xsl:apply-templates select="." mode="titleabbrev.markup"/>
            </span>
          </h4>
        </xsl:when>
        <xsl:when test="local-name(.) = 'part'">
          <h3>
            <span>
              <xsl:attribute name="class"><xsl:value-of select="local-name(.)"/></xsl:attribute>
              <xsl:variable name="label">
                <xsl:apply-templates select="." mode="label.markup"/>
              </xsl:variable>
              <xsl:copy-of select="$label"/>
              <xsl:if test="$label != ''">
                <xsl:value-of select="$autotoc.label.separator"/>
              </xsl:if>
              <xsl:apply-templates select="." mode="titleabbrev.markup"/>
            </span>
          </h3>
        </xsl:when>
        <xsl:otherwise>
          <h3>
            <span>
              <xsl:attribute name="class"><xsl:value-of select="local-name(.)"/></xsl:attribute>
              <a>
                <xsl:attribute name="href">
                  <xsl:call-template name="href.target">
                    <xsl:with-param name="context" select="$toc-context"/>
                  </xsl:call-template>
                </xsl:attribute>
                <xsl:variable name="label">
                  <xsl:apply-templates select="." mode="label.markup"/>
                </xsl:variable>
                <xsl:copy-of select="$label"/>
                <xsl:if test="$label != ''">
                  <xsl:value-of select="$autotoc.label.separator"/>
                </xsl:if>
                <xsl:apply-templates select="." mode="titleabbrev.markup"/>
              </a>
            </span>
          </h3>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:template>
  
  </xsl:stylesheet>
  
  
  



More information about the blfs-book mailing list