Prechádzať zdrojové kódy

Skip dummy sect1 from navigational links.

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/new-xsl@8054 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689
Manuel Canales Esparcia 18 rokov pred
rodič
commit
90b90bfdc0
1 zmenil súbory, kde vykonal 133 pridanie a 50 odobranie
  1. 133 50
      xhtml/lfs-navigational.xsl

+ 133 - 50
xhtml/lfs-navigational.xsl

@@ -89,8 +89,9 @@
              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. -->
+             When "Next" target is the Index, added gentext support for the
+               Index title.
+             Skip links to dummy sect1. -->
   <xsl:template name="navigational.links">
     <xsl:param name="prev"/>
     <xsl:param name="next"/>
@@ -99,60 +100,142 @@
     <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>
+          <xsl:choose>
+            <xsl:when test="$prev[@role='dummy'] and
+                            count(preceding-sibling::sect1)=1">
+              <a accesskey="p">
+                <xsl:attribute name="href">
+                  <xsl:call-template name="href.target">
+                    <xsl:with-param name="object" select=".."/>
+                  </xsl:call-template>
+                </xsl:attribute>
+                <xsl:attribute name="title">
+                  <xsl:value-of select="../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="../title"/>
+              </p>
+            </xsl:when>
+            <xsl:when test="$prev[@role='dummy'] and
+                            count(preceding-sibling::sect1)&gt;1">
+              <a accesskey="p">
+                <xsl:attribute name="href">
+                  <xsl:call-template name="href.target">
+                    <xsl:with-param name="object" select="preceding-sibling::sect1[position()=2]"/>
+                  </xsl:call-template>
+                </xsl:attribute>
+                <xsl:attribute name="title">
+                  <xsl:value-of select="preceding-sibling::sect1[position()=2]/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="preceding-sibling::sect1[position()=2]/title"/>
+              </p>
+            </xsl:when>
+            <xsl:otherwise>
+              <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>
+            </xsl:otherwise>
+          </xsl:choose>
         </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:choose>
+            <xsl:when test="$next[@role='dummy'] and local-name(.) = 'sect1'">
+              <a accesskey="n">
+                <xsl:attribute name="href">
+                  <xsl:call-template name="href.target">
+                    <xsl:with-param name="object" select="following-sibling::sect1[position()=2]"/>
+                  </xsl:call-template>
+                </xsl:attribute>
+                <xsl:attribute name="title">
+                  <xsl:value-of select="following-sibling::sect1[position()=2]/title"/>
+                </xsl:attribute>
+                <xsl:call-template name="navig.content">
+                  <xsl:with-param name="direction" select="'next'"/>
+                </xsl:call-template>
+              </a>
+              <p>
+                <xsl:value-of select="following-sibling::sect1[position()=2]/title"/>
+              </p>
+            </xsl:when>
+            <xsl:when test="$next[@role='dummy'] and local-name(.) = 'chapter'">
+              <a accesskey="n">
+                <xsl:attribute name="href">
+                  <xsl:call-template name="href.target">
+                    <xsl:with-param name="object" select="descendant::sect1[position()=2]"/>
+                  </xsl:call-template>
+                </xsl:attribute>
+                <xsl:attribute name="title">
+                  <xsl:value-of select="descendant::sect1[position()=2]/title"/>
+                </xsl:attribute>
+                <xsl:call-template name="navig.content">
+                  <xsl:with-param name="direction" select="'next'"/>
+                </xsl:call-template>
+              </a>
+              <p>
+                <xsl:value-of select="descendant::sect1[position()=2]/title"/>
+              </p>
+            </xsl:when>
+            <xsl:otherwise>
+              <a accesskey="n">
+                <xsl:attribute name="href">
+                  <xsl:call-template name="href.target">
+                    <xsl:with-param name="object" select="$next"/>
                   </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: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>
-              </xsl:when>
-              <xsl:otherwise>
-                <xsl:value-of select="$next/title"/>
-              </xsl:otherwise>
-            </xsl:choose>
-          </p>
+              </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>
+            </xsl:otherwise>
+          </xsl:choose>
         </li>
       </xsl:if>
       <li class="up">