]> granicus.if.org Git - docbook-dsssl/commitdiff
Output LINK elements in the HEAD for prev/next/up/first/last/etc. (works great in...
authorNorman Walsh <ndw@nwalsh.com>
Sun, 12 May 2002 11:49:55 +0000 (11:49 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Sun, 12 May 2002 11:49:55 +0000 (11:49 +0000)
website/xsl/head.xsl
website/xsl/website-common.xsl

index ad1e213290177613d0b4a06cebd46acf6ad35545..566f6ec352570fc48f081958d6b678b50b7507ec 100644 (file)
        </xsl:if>
       </link>
     </xsl:if>
+
+    <xsl:variable name="thisid" select="ancestor-or-self::webpage/@id"/>
+    <xsl:variable name="thisrelpath">
+      <xsl:apply-templates select="$autolayout//*[@id=$thisid]" mode="toc-rel-path"/>
+    </xsl:variable>
+
+    <xsl:variable name="topid">
+      <xsl:call-template name="top.page"/>
+    </xsl:variable>
+
+    <xsl:if test="$topid != ''">
+      <link rel="home">
+        <xsl:attribute name="href">
+          <xsl:call-template name="page.uri">
+            <xsl:with-param name="page" select="$autolayout//*[@id=$topid]"/>
+            <xsl:with-param name="relpath" select="$thisrelpath"/>
+          </xsl:call-template>
+        </xsl:attribute>
+        <xsl:attribute name="title">
+          <xsl:value-of select="$autolayout//*[@id=$topid]/title"/>
+        </xsl:attribute>
+      </link>
+    </xsl:if>
+
+    <xsl:variable name="upid">
+      <xsl:call-template name="up.page"/>
+    </xsl:variable>
+
+    <xsl:if test="$upid != ''">
+      <link rel="up">
+        <xsl:attribute name="href">
+          <xsl:call-template name="page.uri">
+            <xsl:with-param name="page" select="$autolayout//*[@id=$upid]"/>
+            <xsl:with-param name="relpath" select="$thisrelpath"/>
+          </xsl:call-template>
+        </xsl:attribute>
+        <xsl:attribute name="title">
+          <xsl:value-of select="$autolayout//*[@id=$upid]/title"/>
+        </xsl:attribute>
+      </link>
+    </xsl:if>
+
+    <xsl:variable name="previd">
+      <xsl:call-template name="prev.page"/>
+    </xsl:variable>
+
+    <xsl:if test="$previd != ''">
+      <link rel="previous">
+        <xsl:attribute name="href">
+          <xsl:call-template name="page.uri">
+            <xsl:with-param name="page" select="$autolayout//*[@id=$previd]"/>
+            <xsl:with-param name="relpath" select="$thisrelpath"/>
+          </xsl:call-template>
+        </xsl:attribute>
+        <xsl:attribute name="title">
+          <xsl:value-of select="$autolayout//*[@id=$previd]/title"/>
+        </xsl:attribute>
+      </link>
+    </xsl:if>
+
+    <xsl:variable name="nextid">
+      <xsl:call-template name="next.page"/>
+    </xsl:variable>
+
+    <xsl:if test="$nextid != ''">
+      <link rel="next">
+        <xsl:attribute name="href">
+          <xsl:call-template name="page.uri">
+            <xsl:with-param name="page" select="$autolayout//*[@id=$nextid]"/>
+            <xsl:with-param name="relpath" select="$thisrelpath"/>
+          </xsl:call-template>
+        </xsl:attribute>
+        <xsl:attribute name="title">
+          <xsl:value-of select="$autolayout//*[@id=$nextid]/title"/>
+        </xsl:attribute>
+      </link>
+    </xsl:if>
+
+    <xsl:variable name="firstid">
+      <xsl:call-template name="first.page"/>
+    </xsl:variable>
+
+    <xsl:if test="$firstid != ''">
+      <link rel="first">
+        <xsl:attribute name="href">
+          <xsl:call-template name="page.uri">
+            <xsl:with-param name="page" select="$autolayout//*[@id=$firstid]"/>
+            <xsl:with-param name="relpath" select="$thisrelpath"/>
+          </xsl:call-template>
+        </xsl:attribute>
+        <xsl:attribute name="title">
+          <xsl:value-of select="$autolayout//*[@id=$firstid]/title"/>
+        </xsl:attribute>
+      </link>
+    </xsl:if>
+
+    <xsl:variable name="lastid">
+      <xsl:call-template name="last.page"/>
+    </xsl:variable>
+
+    <xsl:if test="$lastid != ''">
+      <link rel="last">
+        <xsl:attribute name="href">
+          <xsl:call-template name="page.uri">
+            <xsl:with-param name="page" select="$autolayout//*[@id=$lastid]"/>
+            <xsl:with-param name="relpath" select="$thisrelpath"/>
+          </xsl:call-template>
+        </xsl:attribute>
+        <xsl:attribute name="title">
+          <xsl:value-of select="$autolayout//*[@id=$lastid]/title"/>
+        </xsl:attribute>
+      </link>
+    </xsl:if>
+
     <xsl:apply-templates select="$autolayout/autolayout/style
                                  |$autolayout/autolayout/script"
                          mode="head.mode">
index b165881f7c1232740d272c44df6b001b77df8388..2fa82186feb41ede3a619c2c8f2db63cf83723a1 100644 (file)
@@ -563,16 +563,19 @@ node.</para>
 
 <!-- ==================================================================== -->
 
-<xsl:template name="link.to.page">
+<xsl:template name="page.uri">
   <xsl:param name="href" select="''"/>
   <xsl:param name="page" select="ancestor-or-self::tocentry"/>
-  <xsl:param name="linktext" select="'???'"/>
   <xsl:param name="relpath">
     <xsl:call-template name="toc-rel-path">
       <xsl:with-param name="pageid" select="$page/@id"/>
     </xsl:call-template>
   </xsl:param>
 
+<!--
+  <xsl:message><xsl:value-of select="$page/@id"/>: <xsl:value-of select="$relpath"/></xsl:message>
+-->
+
   <xsl:variable name="dir">
     <xsl:choose>
       <xsl:when test="starts-with($page/@dir, '/')">
@@ -596,7 +599,27 @@ node.</para>
     </xsl:choose>
   </xsl:variable>
 
-  <a href="{$html.href}">
+  <xsl:value-of select="$html.href"/>
+</xsl:template>
+
+<xsl:template name="link.to.page">
+  <xsl:param name="href" select="''"/>
+  <xsl:param name="page" select="ancestor-or-self::tocentry"/>
+  <xsl:param name="relpath">
+    <xsl:call-template name="toc-rel-path">
+      <xsl:with-param name="pageid" select="$page/@id"/>
+    </xsl:call-template>
+  </xsl:param>
+  <xsl:param name="linktext" select="'???'"/>
+
+  <a>
+    <xsl:attribute name="href">
+      <xsl:call-template name="page.uri">
+        <xsl:with-param name="href" select="$href"/>
+        <xsl:with-param name="page" select="$page"/>
+        <xsl:with-param name="relpath" select="$relpath"/>
+      </xsl:call-template>
+    </xsl:attribute>
     <xsl:if test="summary">
       <xsl:attribute name="title">
         <xsl:value-of select="summary"/>
@@ -606,7 +629,6 @@ node.</para>
   </a>
 </xsl:template>
 
-
 <xsl:template name="next.page">
   <xsl:param name="page" select="ancestor-or-self::webpage"/>
   <xsl:variable name="id" select="$page/@id"/>
@@ -656,4 +678,51 @@ node.</para>
   <xsl:value-of select="$previd"/>
 </xsl:template>
 
+<xsl:template name="top.page">
+  <xsl:param name="page" select="ancestor-or-self::webpage"/>
+  <xsl:variable name="id" select="$page/@id"/>
+  <xsl:variable name="tocentry"
+                select="$autolayout//*[@id=$id]"/>
+
+  <xsl:value-of select="$tocentry/ancestor::toc/@id"/>
+</xsl:template>
+
+<xsl:template name="up.page">
+  <xsl:param name="page" select="ancestor-or-self::webpage"/>
+  <xsl:variable name="id" select="$page/@id"/>
+  <xsl:variable name="tocentry"
+                select="$autolayout//*[@id=$id]"/>
+
+  <xsl:choose>
+    <xsl:when test="$tocentry/ancestor::tocentry">
+      <xsl:value-of select="$tocentry/ancestor::tocentry[1]/@id"/>
+    </xsl:when>
+    <xsl:when test="$tocentry/ancestor::toc">
+      <xsl:value-of select="$tocentry/ancestor::toc[1]/@id"/>
+    </xsl:when>
+    <xsl:otherwise></xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template name="first.page">
+  <xsl:param name="page" select="ancestor-or-self::webpage"/>
+  <xsl:variable name="id" select="$page/@id"/>
+  <xsl:variable name="tocentry"
+                select="$autolayout//*[@id=$id]"/>
+
+  <xsl:value-of select="$tocentry/preceding-sibling::tocentry[last()]/@id"/>
+</xsl:template>
+
+<xsl:template name="last.page">
+  <xsl:param name="page" select="ancestor-or-self::webpage"/>
+  <xsl:variable name="id" select="$page/@id"/>
+  <xsl:variable name="tocentry"
+                select="$autolayout//*[@id=$id]"/>
+
+  <xsl:variable name="prev-sibling"
+                select="$tocentry/preceding-sibling::tocentry[1]"/>
+
+  <xsl:value-of select="$tocentry/following-sibling::tocentry[last()]/@id"/>
+</xsl:template>
+
 </xsl:stylesheet>