Bläddra i källkod

Revised xhtml/lfs-navigational.xsl

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/new-xsl@7992 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689
Manuel Canales Esparcia 18 år sedan
förälder
incheckning
9b69780249
1 ändrade filer med 170 tillägg och 214 borttagningar
  1. 170 214
      xhtml/lfs-navigational.xsl

+ 170 - 214
xhtml/lfs-navigational.xsl

@@ -4,7 +4,14 @@
                 xmlns="http://www.w3.org/1999/xhtml"
                 version="1.0">
 
-    <!-- Dropping the HEAD links -->
+   <!-- REVISED -->
+
+  <!-- This stylesheet controls how page header and navigational links
+       are generated. -->
+
+    <!-- html.head:
+           Drop all navigational links from inside head xhtml output. -->
+    <!-- The original template is in {docbook-xsl}/xhtml/chink-common.xsl -->
   <xsl:template name="html.head">
     <head>
       <xsl:call-template name="system.head.content"/>
@@ -13,243 +20,192 @@
     </head>
   </xsl:template>
 
-    <!-- Header Navigation-->
+    <!-- header.navigation:
+           Self-made template that full replaces the original one -->
+    <!-- The original template is in {docbook-xsl}/xhtml/chink-common.xsl -->
   <xsl:template name="header.navigation">
     <xsl:param name="prev" select="/foo"/>
     <xsl:param name="next" select="/foo"/>
-    <xsl:param name="nav.context"/>
-    <xsl:variable name="home" select="/*[1]"/>
     <xsl:variable name="up" select="parent::*"/>
+    <xsl:variable name="home" select="/*[1]"/>
     <xsl:variable name="row" select="count($prev) &gt; 0 or (count($up) &gt; 0
             and generate-id($up) != generate-id($home)) or count($next) &gt; 0"/>
+      <!-- Don't generate the header in index.html -->
     <xsl:if test="$row and $home != .">
       <div class="navheader">
-        <xsl:if test="$home != .">
-          <div class="headertitles">
-            <h4>
-              <xsl:apply-templates select="$home" mode="object.title.markup"/>
-              <xsl:text> - </xsl:text>
-              <xsl:apply-templates select="$home" mode="object.subtitle.markup"/>
-            </h4>
-            <xsl:if test="$up != $home">
-              <h3>
-                <xsl:apply-templates select="$up" mode="object.title.markup"/>
-              </h3>
-            </xsl:if>
-          </div>
-        </xsl:if>
-        <ul class="headerlinks">
-          <xsl:if test="count($prev)&gt;0 and $prev != $home">
-            <li class="prev">
-              <a accesskey="p">
-                <xsl:attribute name="href">
-                  <xsl:call-template name="href.target">
-                    <xsl:with-param name="object" select="$prev"/>
-                  </xsl:call-template>
-                </xsl:attribute>
-                <xsl:attribute name="title">
-                  <xsl:value-of select="$prev/title"/>
-                </xsl:attribute>
-                <xsl:call-template name="navig.content">
-                  <xsl:with-param name="direction" select="'prev'"/>
-                </xsl:call-template>
-              </a>
-              <p>
-                <xsl:value-of select="$prev/title"/>
-              </p>
-            </li>
-          </xsl:if>
-          <xsl:if test="count($next)&gt;0">
-            <li class="next">
-              <a accesskey="n">
-                <xsl:attribute name="href">
-                  <xsl:call-template name="href.target">
-                    <xsl:with-param name="object" select="$next"/>
-                  </xsl:call-template>
-                </xsl:attribute>
-                <xsl:attribute name="title">
-                  <xsl:choose>
-                    <xsl:when test="local-name($next)='index'">
-                      <xsl:call-template name="gentext">
-                        <xsl:with-param name="key">Index</xsl:with-param>
-                      </xsl:call-template>
-                    </xsl:when>
-                    <xsl:otherwise>
-                      <xsl:value-of select="$next/title"/>
-                    </xsl:otherwise>
-                  </xsl:choose>
-                </xsl:attribute>
-                <xsl:call-template name="navig.content">
-                  <xsl:with-param name="direction" select="'next'"/>
-                </xsl:call-template>
-              </a>
-              <p>
-                <xsl:choose>
-                  <xsl:when test="local-name($next)='index'">
-                    <xsl:call-template name="gentext">
-                      <xsl:with-param name="key">Index</xsl:with-param>
-                    </xsl:call-template>
-                  </xsl:when>
-                  <xsl:otherwise>
-                    <xsl:value-of select="$next/title"/>
-                  </xsl:otherwise>
-                </xsl:choose>
-              </p>
-            </li>
+          <!-- Add common titles -->
+        <div class="headertitles">
+           <!-- Book title and version -->
+          <h4>
+            <xsl:apply-templates select="$home" mode="object.title.markup"/>
+            <xsl:text> - </xsl:text>
+            <xsl:apply-templates select="$home" mode="object.subtitle.markup"/>
+          </h4>
+            <!-- Except for preface, part, and index, add the title of the parent -->
+          <xsl:if test="$up != $home">
+            <h3>
+              <xsl:apply-templates select="$up" mode="object.title.markup"/>
+            </h3>
           </xsl:if>
-            <li class="up">
-              <xsl:if test="count($up)&gt;0 and $up != $home">
-                <a accesskey="u">
-                  <xsl:attribute name="href">
-                    <xsl:call-template name="href.target">
-                      <xsl:with-param name="object" select="$up"/>
-                    </xsl:call-template>
-                  </xsl:attribute>
-                  <xsl:attribute name="title">
-                    <xsl:apply-templates select="$up" mode="object.title.markup"/>
-                  </xsl:attribute>
-                  <xsl:call-template name="navig.content">
-                    <xsl:with-param name="direction" select="'up'"/>
-                  </xsl:call-template>
-                </a>
-              </xsl:if>
-              <xsl:text>.</xsl:text>
-            </li>
-          <li class="home">
-            <a accesskey="h">
-              <xsl:attribute name="href">
-                <xsl:call-template name="href.target">
-                  <xsl:with-param name="object" select="$home"/>
-                </xsl:call-template>
-              </xsl:attribute>
-                <xsl:attribute name="title">
-                  <xsl:value-of select="$home/bookinfo/title"/>
-                  <xsl:text> - </xsl:text>
-                  <xsl:value-of select="$home/bookinfo/subtitle"/>
-                </xsl:attribute>
-                <xsl:call-template name="navig.content">
-                  <xsl:with-param name="direction" select="'home'"/>
-                </xsl:call-template>
-            </a>
-          </li>
-        </ul>
+        </div>
+          <!-- Create header navigational links -->
+        <xsl:call-template name="navigational.links">
+          <xsl:with-param name="prev" select="$prev"/>
+          <xsl:with-param name="next" select="$next"/>
+          <xsl:with-param name="up" select="$up"/>
+          <xsl:with-param name="home" select="$home"/>
+        </xsl:call-template>
       </div>
     </xsl:if>
   </xsl:template>
 
-    <!-- Footer Navigation-->
+    <!-- footer.navigation:
+           Self-made template that full replaces the original one -->
+    <!-- The original template is in {docbook-xsl}/xhtml/chink-common.xsl -->
   <xsl:template name="footer.navigation">
     <xsl:param name="prev" select="/foo"/>
     <xsl:param name="next" select="/foo"/>
-    <xsl:param name="nav.context"/>
-    <xsl:variable name="home" select="/*[1]"/>
     <xsl:variable name="up" select="parent::*"/>
+    <xsl:variable name="home" select="/*[1]"/>
     <xsl:variable name="row" select="count($prev) &gt; 0 or count($up) &gt; 0
             or count($next) &gt; 0 or generate-id($home) != generate-id(.)"/>
     <xsl:if test="$row">
       <div class="navfooter">
-        <ul>
-          <xsl:if test="count($prev)&gt;0 and $prev != $home">
-            <li class="prev">
-              <a accesskey="p">
-                <xsl:attribute name="href">
-                  <xsl:call-template name="href.target">
-                    <xsl:with-param name="object" select="$prev"/>
+          <!-- Create footer navigational links -->
+        <xsl:call-template name="navigational.links">
+          <xsl:with-param name="prev" select="$prev"/>
+          <xsl:with-param name="next" select="$next"/>
+          <xsl:with-param name="up" select="$up"/>
+          <xsl:with-param name="home" select="$home"/>
+        </xsl:call-template>
+      </div>
+    </xsl:if>
+  </xsl:template>
+
+    <!-- navigational.links:
+           Self-made template to generate navigational links.
+           Most of the code come from the original header.navigation and
+           footer.navigation templates, with this changes:
+             Changed the output format from table to ul.
+             Placed the same links on both header and footer.
+             Added a title attribute to the link containing the target title
+               (it content is displayed when placing the mouse over the link)
+             For "Prev" and "Next" links, added the target title under it.
+             When "Next" target is the Index, added gettext support for the
+               Index title. -->
+  <xsl:template name="navigational.links">
+    <xsl:param name="prev"/>
+    <xsl:param name="next"/>
+    <xsl:param name="up"/>
+    <xsl:param name="home"/>
+    <ul>
+      <xsl:if test="count($prev)&gt;0 and $prev != $home">
+        <li class="prev">
+          <a accesskey="p">
+            <xsl:attribute name="href">
+              <xsl:call-template name="href.target">
+                <xsl:with-param name="object" select="$prev"/>
+              </xsl:call-template>
+            </xsl:attribute>
+            <xsl:attribute name="title">
+              <xsl:value-of select="$prev/title"/>
+            </xsl:attribute>
+            <xsl:call-template name="navig.content">
+              <xsl:with-param name="direction" select="'prev'"/>
+            </xsl:call-template>
+          </a>
+          <p>
+            <xsl:value-of select="$prev/title"/>
+          </p>
+        </li>
+      </xsl:if>
+      <xsl:if test="count($next)&gt;0">
+        <li class="next">
+          <a accesskey="n">
+            <xsl:attribute name="href">
+              <xsl:call-template name="href.target">
+                <xsl:with-param name="object" select="$next"/>
+              </xsl:call-template>
+            </xsl:attribute>
+            <xsl:attribute name="title">
+              <xsl:choose>
+                <xsl:when test="local-name($next)='index'">
+                  <xsl:call-template name="gentext">
+                    <xsl:with-param name="key">Index</xsl:with-param>
                   </xsl:call-template>
-                </xsl:attribute>
-                <xsl:attribute name="title">
-                  <xsl:value-of select="$prev/title"/>
-                </xsl:attribute>
-                <xsl:call-template name="navig.content">
-                  <xsl:with-param name="direction" select="'prev'"/>
+                </xsl:when>
+                <xsl:otherwise>
+                  <xsl:value-of select="$next/title"/>
+                </xsl:otherwise>
+              </xsl:choose>
+            </xsl:attribute>
+            <xsl:call-template name="navig.content">
+              <xsl:with-param name="direction" select="'next'"/>
+            </xsl:call-template>
+          </a>
+          <p>
+            <xsl:choose>
+              <xsl:when test="local-name($next)='index'">
+                <xsl:call-template name="gentext">
+                  <xsl:with-param name="key">Index</xsl:with-param>
                 </xsl:call-template>
-              </a>
-              <p>
-                <xsl:value-of select="$prev/title"/>
-              </p>
-            </li>
-          </xsl:if>
-          <xsl:if test="count($next)&gt;0">
-            <li class="next">
-              <a accesskey="n">
-                <xsl:attribute name="href">
-                  <xsl:call-template name="href.target">
-                    <xsl:with-param name="object" select="$next"/>
-                  </xsl:call-template>
-                </xsl:attribute>
-                <xsl:attribute name="title">
-                  <xsl:choose>
-                    <xsl:when test="local-name($next)='index'">
-                      <xsl:call-template name="gentext">
-                        <xsl:with-param name="key">Index</xsl:with-param>
-                      </xsl:call-template>
-                    </xsl:when>
-                    <xsl:otherwise>
-                      <xsl:value-of select="$next/title"/>
-                    </xsl:otherwise>
-                  </xsl:choose>
-                </xsl:attribute>
-                <xsl:call-template name="navig.content">
-                  <xsl:with-param name="direction" select="'next'"/>
+              </xsl:when>
+              <xsl:otherwise>
+                <xsl:value-of select="$next/title"/>
+              </xsl:otherwise>
+            </xsl:choose>
+          </p>
+        </li>
+      </xsl:if>
+      <li class="up">
+        <xsl:choose>
+          <xsl:when test="count($up)&gt;0 and $up != $home">
+            <a accesskey="u">
+              <xsl:attribute name="href">
+                <xsl:call-template name="href.target">
+                  <xsl:with-param name="object" select="$up"/>
                 </xsl:call-template>
-              </a>
-              <p>
-                <xsl:choose>
-                  <xsl:when test="local-name($next)='index'">
-                    <xsl:call-template name="gentext">
-                      <xsl:with-param name="key">Index</xsl:with-param>
-                    </xsl:call-template>
-                  </xsl:when>
-                  <xsl:otherwise>
-                    <xsl:value-of select="$next/title"/>
-                  </xsl:otherwise>
-                </xsl:choose>
-              </p>
-            </li>
-          </xsl:if>
-            <li class="up">
-              <xsl:if test="count($up)&gt;0 and $up != $home">
-                <a accesskey="u">
-                  <xsl:attribute name="href">
-                    <xsl:call-template name="href.target">
-                      <xsl:with-param name="object" select="$up"/>
-                    </xsl:call-template>
-                  </xsl:attribute>
-                  <xsl:attribute name="title">
-                    <xsl:apply-templates select="$up" mode="object.title.markup"/>
-                  </xsl:attribute>
-                  <xsl:call-template name="navig.content">
-                    <xsl:with-param name="direction" select="'up'"/>
-                  </xsl:call-template>
-                </a>
-              </xsl:if>
-              <xsl:text>.</xsl:text>
-            </li>
-            <li class="home">
-              <xsl:if  test="$home != .">
-                <a accesskey="h">
-                  <xsl:attribute name="href">
-                    <xsl:call-template name="href.target">
-                      <xsl:with-param name="object" select="$home"/>
-                    </xsl:call-template>
-                  </xsl:attribute>
-                  <xsl:attribute name="title">
-                    <xsl:value-of select="$home/bookinfo/title"/>
-                    <xsl:text> - </xsl:text>
-                    <xsl:value-of select="$home/bookinfo/subtitle"/>
-                  </xsl:attribute>
-                  <xsl:call-template name="navig.content">
-                    <xsl:with-param name="direction" select="'home'"/>
-                  </xsl:call-template>
-                </a>
-              </xsl:if>
-              <xsl:text>.</xsl:text>
-            </li>
-        </ul>
-      </div>
-    </xsl:if>
+              </xsl:attribute>
+              <xsl:attribute name="title">
+                <xsl:apply-templates select="$up" mode="object.title.markup"/>
+              </xsl:attribute>
+              <xsl:call-template name="navig.content">
+                <xsl:with-param name="direction" select="'up'"/>
+              </xsl:call-template>
+            </a>
+          </xsl:when>
+            <!-- Hack to let the CSS code do its work when there is no up link -->
+          <xsl:otherwise>
+            <xsl:text>.</xsl:text>
+          </xsl:otherwise>
+        </xsl:choose>
+      </li>
+      <li class="home">
+        <xsl:choose>
+          <xsl:when test="$home != .">
+            <a accesskey="h">
+              <xsl:attribute name="href">
+                <xsl:call-template name="href.target">
+                  <xsl:with-param name="object" select="$home"/>
+                </xsl:call-template>
+              </xsl:attribute>
+              <xsl:attribute name="title">
+                <xsl:value-of select="$home/bookinfo/title"/>
+                <xsl:text> - </xsl:text>
+                <xsl:value-of select="$home/bookinfo/subtitle"/>
+              </xsl:attribute>
+              <xsl:call-template name="navig.content">
+                <xsl:with-param name="direction" select="'home'"/>
+              </xsl:call-template>
+            </a>
+          </xsl:when>
+            <!-- Hack to let the CSS code do its work when there is no home link -->
+          <xsl:otherwise>
+            <xsl:text>.</xsl:text>
+          </xsl:otherwise>
+        </xsl:choose>
+      </li>
+    </ul>
   </xsl:template>
 
 </xsl:stylesheet>
-
-