2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 
   5 <xsl:output method="html"/>
 
   7 <xsl:param name="nav.graphics" select="1"/>
 
   8 <xsl:param name="nav.pointer" select="1"/>
 
   9 <xsl:param name="nav.revisionflag" select="1"/>
 
  11 <xsl:param name="toc.spacer.text">   </xsl:param>
 
  12 <xsl:param name="toc.spacer.image">graphics/blank.gif</xsl:param>
 
  14 <xsl:param name="nav.icon.path">graphics/navicons/</xsl:param>
 
  15 <xsl:param name="nav.icon.extension">.gif</xsl:param>
 
  17 <!-- styles: folder, folder16, plusminus, triangle, arrow -->
 
  18 <xsl:param name="nav.icon.style">triangle</xsl:param>
 
  20 <xsl:param name="nav.text.spacer"> </xsl:param>
 
  21 <xsl:param name="nav.text.current.open">+</xsl:param>
 
  22 <xsl:param name="nav.text.current.page">+</xsl:param>
 
  23 <xsl:param name="nav.text.other.open"> </xsl:param>
 
  24 <xsl:param name="nav.text.other.closed"> </xsl:param>
 
  25 <xsl:param name="nav.text.other.page"> </xsl:param>
 
  26 <xsl:param name="nav.text.revisionflag.added">New</xsl:param>
 
  27 <xsl:param name="nav.text.revisionflag.changed">Changed</xsl:param>
 
  28 <xsl:param name="nav.text.revisionflag.deleted"></xsl:param>
 
  29 <xsl:param name="nav.text.revisionflag.off"></xsl:param>
 
  31 <xsl:param name="nav.text.pointer"><-</xsl:param>
 
  33 <xsl:param name="toc.expand.depth" select="1"/>
 
  35 <!-- ==================================================================== --> 
 
  37 <xsl:template match="toc/title|tocentry/title|titleabbrev">
 
  38   <xsl:apply-templates/>
 
  41 <xsl:template match="toc">
 
  42   <xsl:param name="pageid" select="@id"/>
 
  44   <xsl:variable name="relpath">
 
  45     <xsl:call-template name="toc-rel-path">
 
  46       <xsl:with-param name="pageid" select="$pageid"/>
 
  50   <xsl:variable name="homebanner"
 
  51                 select="/autolayout/config[@param='homebanner-tabular'][1]"/>
 
  53   <xsl:variable name="banner"
 
  54                 select="/autolayout/config[@param='banner-tabular'][1]"/>
 
  57     <xsl:when test="$pageid = @id">
 
  58       <img align="left" border="0">
 
  59         <xsl:attribute name="src">
 
  60           <xsl:value-of select="$relpath"/>
 
  61           <xsl:value-of select="$homebanner/@value"/>
 
  63         <xsl:attribute name="alt">
 
  64           <xsl:value-of select="$homebanner/@altval"/>
 
  71       <a href="{$relpath}{@dir}{$filename-prefix}{@filename}">
 
  72         <img align="left" border="0">
 
  73           <xsl:attribute name="src">
 
  74             <xsl:value-of select="$relpath"/>
 
  75             <xsl:value-of select="$banner/@value"/>
 
  77           <xsl:attribute name="alt">
 
  78             <xsl:value-of select="$banner/@altval"/>
 
  87   <xsl:apply-templates select="tocentry">
 
  88     <xsl:with-param name="pageid" select="$pageid"/>
 
  89     <xsl:with-param name="relpath" select="$relpath"/>
 
  90   </xsl:apply-templates>
 
  94 <!-- ==================================================================== -->
 
  96 <xsl:template match="tocentry">
 
  97   <xsl:param name="pageid" select="@id"/>
 
  98   <xsl:param name="toclevel" select="count(ancestor::*)"/>
 
  99   <xsl:param name="relpath" select="''"/>
 
 100   <xsl:param name="revisionflag" select="@revisionflag"/>
 
 102   <xsl:variable name="page" select="."/>
 
 103   <xsl:variable name="target"
 
 104                 select="($page/descendant-or-self::tocentry[not(@tocskip) or @tocskip = '0']
 
 105                        |$page/following::tocentry[@tocskip and @tocskip='0'])[1]"/>
 
 107   <xsl:variable name="depth" select="count(ancestor::*)-1"/>
 
 109   <xsl:variable name="isdescendant">
 
 111       <xsl:when test="ancestor::*[@id=$pageid]">1</xsl:when>
 
 112       <xsl:otherwise>0</xsl:otherwise>
 
 116   <xsl:variable name="hasdescendant">
 
 118       <xsl:when test="descendant::tocentry != ''">1</xsl:when>
 
 119       <xsl:otherwise>0</xsl:otherwise>
 
 123   <xsl:variable name="isancestor">
 
 125       <xsl:when test="descendant::*[@id=$pageid]">1</xsl:when>
 
 126       <xsl:otherwise>0</xsl:otherwise>
 
 130   <xsl:variable name="use.toc.expand.depth">
 
 131     <xsl:variable name="config-param" select="ancestor::autolayout/config[@param='toc.expand.depth']/@value"/>
 
 133       <!-- toc.expand.depth attribute is not in DTD -->
 
 134       <xsl:when test="ancestor::toc/@toc.expand.depth">
 
 135         <xsl:value-of select="ancestor::toc/@toc.expand.depth"/>
 
 137       <xsl:when test="floor($config-param) > 0">
 
 138         <xsl:value-of select="$config-param"/>
 
 141         <xsl:value-of select="$toc.expand.depth"/>
 
 146   <xsl:variable name="is.open">
 
 148       <xsl:when test="$pageid = @id
 
 150                       or $depth < $use.toc.expand.depth">1</xsl:when>
 
 151       <xsl:otherwise>0</xsl:otherwise>
 
 155   <!-- For any entry in the TOC:
 
 156        1. It is the current page
 
 157           a. it is a leaf             current/leaf
 
 158           b. it is an open page       current/open
 
 159        2. It is not the current page
 
 160           a. it is a leaf             other/leaf
 
 161           b. it is an open page       other/open
 
 162           c. it is a closed page      other/closed
 
 165   <xsl:variable name="preceding-icon">
 
 166     <xsl:value-of select="$relpath"/>
 
 167     <xsl:value-of select="$nav.icon.path"/>
 
 168     <xsl:value-of select="$nav.icon.style"/>
 
 170       <xsl:when test="$pageid=@id">
 
 172           <xsl:when test="$hasdescendant != 0">
 
 173             <xsl:text>/current/open</xsl:text>
 
 176             <xsl:text>/current/leaf</xsl:text>
 
 182           <xsl:when test="$hasdescendant = 0">
 
 183             <xsl:text>/other/leaf</xsl:text>
 
 185           <xsl:when test="$is.open != 0">
 
 186             <xsl:text>/other/open</xsl:text>
 
 189             <xsl:text>/other/closed</xsl:text>
 
 194     <xsl:value-of select="$nav.icon.extension"/>
 
 197   <xsl:variable name="preceding-text">
 
 199       <xsl:when test="$pageid=@id">
 
 201           <xsl:when test="$hasdescendant != 0">
 
 202             <xsl:value-of select="$nav.text.current.open"/>
 
 205             <xsl:value-of select="$nav.text.current.page"/>
 
 211           <xsl:when test="$isancestor != 0">
 
 212             <xsl:value-of select="$nav.text.other.open"/>
 
 214           <xsl:when test="$hasdescendant != 0">
 
 215             <xsl:value-of select="$nav.text.other.closed"/>
 
 218             <xsl:value-of select="$nav.text.other.page"/>
 
 225   <xsl:variable name="following-icon">
 
 226     <xsl:value-of select="$relpath"/>
 
 227     <xsl:value-of select="$nav.icon.path"/>
 
 228     <xsl:value-of select="$nav.icon.style"/>
 
 229     <xsl:text>/current/pointer</xsl:text>
 
 230     <xsl:value-of select="$nav.icon.extension"/>
 
 233   <xsl:variable name="following-text">
 
 234     <xsl:value-of select="$nav.text.pointer"/>
 
 237   <xsl:variable name="revisionflag-icon">
 
 238     <xsl:value-of select="$relpath"/>
 
 239     <xsl:value-of select="$nav.icon.path"/>
 
 240     <xsl:value-of select="$nav.icon.style"/>
 
 241     <xsl:text>/</xsl:text>
 
 242     <xsl:value-of select="$revisionflag"/>
 
 243     <xsl:value-of select="$nav.icon.extension"/>
 
 246   <xsl:variable name="revisionflag-text">
 
 248       <xsl:when test="$revisionflag = 'changed'">
 
 249         <xsl:value-of select="$nav.text.revisionflag.changed"/>
 
 251       <xsl:when test="$revisionflag = 'added'">
 
 252         <xsl:value-of select="$nav.text.revisionflag.added"/>
 
 254       <xsl:when test="$revisionflag = 'deleted'">
 
 255         <xsl:value-of select="$nav.text.revisionflag.deleted"/>
 
 258         <xsl:value-of select="$nav.text.revisionflag.off"/>
 
 264     <xsl:if test="$toclevel = 2">
 
 265       <xsl:attribute name="class">
 
 266         <xsl:text>toplevel</xsl:text>
 
 270     <xsl:if test="$toclevel > 2">
 
 271       <xsl:attribute name="class">
 
 272         <xsl:text>shrink</xsl:text>
 
 273         <xsl:value-of select="$toclevel - 2"/>
 
 277     <xsl:call-template name="insert.spacers">
 
 278       <xsl:with-param name="count" select="$toclevel - 1"/>
 
 279       <xsl:with-param name="relpath" select="$relpath"/>
 
 283       <xsl:when test="$nav.graphics != 0">
 
 284         <xsl:call-template name="link.to.page">
 
 285           <xsl:with-param name="href" select="@href"/>
 
 286           <xsl:with-param name="page" select="$target"/>
 
 287           <xsl:with-param name="relpath" select="$relpath"/>
 
 288           <xsl:with-param name="linktext">
 
 289             <img src="{$preceding-icon}" alt="{$preceding-text}" border="0"/>
 
 294         <xsl:value-of select="$preceding-text"/>
 
 299       <xsl:when test="$pageid = @id">
 
 300         <span class="curpage">
 
 302             <xsl:when test="titleabbrev">
 
 303               <xsl:apply-templates select="titleabbrev"/>
 
 306               <xsl:apply-templates select="title"/>
 
 310           <xsl:if test="$nav.revisionflag != '0' and $revisionflag">
 
 311             <xsl:value-of select="$nav.text.spacer"/>
 
 313               <xsl:when test="$nav.graphics = '1'">
 
 314                 <img src="{$revisionflag-icon}" alt="{$revisionflag-text}" align="bottom"/>
 
 317                 <xsl:text>(</xsl:text>
 
 318                 <xsl:value-of select="$revisionflag-text"/>
 
 319                 <xsl:text>)</xsl:text>
 
 324           <xsl:if test="$nav.pointer != '0'">
 
 325             <xsl:value-of select="$nav.text.spacer"/>
 
 327               <xsl:when test="$nav.graphics = '1'">
 
 328                 <img src="{$following-icon}" alt="{$following-text}"/>
 
 331                 <xsl:value-of select="$following-text"/>
 
 341             <xsl:when test="$isdescendant='0'">
 
 343                 <xsl:when test="$isancestor='1'">
 
 344                   <xsl:attribute name="class">ancestor</xsl:attribute>
 
 347                   <xsl:attribute name="class">otherpage</xsl:attribute>
 
 352               <!-- IS a descendant of curpage -->
 
 353               <xsl:attribute name="class">descendant</xsl:attribute>
 
 357           <xsl:call-template name="link.to.page">
 
 358             <xsl:with-param name="href" select="@href"/>
 
 359             <xsl:with-param name="page" select="$target"/>
 
 360             <xsl:with-param name="relpath" select="$relpath"/>
 
 361             <xsl:with-param name="linktext">
 
 363                 <xsl:when test="titleabbrev">
 
 364                   <xsl:apply-templates select="titleabbrev"/>
 
 367                   <xsl:apply-templates select="title"/>
 
 373           <xsl:if test="$nav.revisionflag != '0' and $revisionflag">
 
 374             <xsl:value-of select="$nav.text.spacer"/>
 
 376               <xsl:when test="$nav.graphics = '1'">
 
 377                 <img src="{$revisionflag-icon}" alt="{$revisionflag-text}"/>
 
 380                 <xsl:text>(</xsl:text>
 
 381                 <xsl:value-of select="$revisionflag-text"/>
 
 382                 <xsl:text>)</xsl:text>
 
 393   <xsl:if test="$is.open != 0">
 
 394     <xsl:apply-templates select="tocentry">
 
 395       <xsl:with-param name="pageid" select="$pageid"/>
 
 396       <xsl:with-param name="relpath" select="$relpath"/>
 
 397     </xsl:apply-templates>
 
 401 <xsl:template name="insert.spacers">
 
 402   <xsl:param name="count" select="0"/>
 
 403   <xsl:param name="relpath"/>
 
 404   <xsl:if test="$count>0">
 
 406       <xsl:when test="$nav.graphics != 0">
 
 407         <img src="{$relpath}{$toc.spacer.image}" alt="{$toc.spacer.text}"/>
 
 410         <xsl:value-of select="$toc.spacer.text"/>
 
 413     <xsl:call-template name="insert.spacers">
 
 414       <xsl:with-param name="count" select="$count - 1"/>
 
 415       <xsl:with-param name="relpath" select="$relpath"/>
 
 420 <xsl:template match="toc|tocentry|notoc" mode="toc-rel-path">
 
 421   <xsl:call-template name="toc-rel-path"/>
 
 424 <xsl:template name="toc-rel-path">
 
 425   <xsl:param name="pageid" select="@id"/>
 
 426   <xsl:variable name="entry" select="$autolayout//*[@id=$pageid]"/>
 
 427   <xsl:variable name="filename" select="concat($entry/@dir,$entry/@filename)"/>
 
 429   <xsl:variable name="slash-count">
 
 430     <xsl:call-template name="toc-directory-depth">
 
 431       <xsl:with-param name="filename" select="$filename"/>
 
 435   <xsl:variable name="depth">
 
 437       <xsl:when test="starts-with($filename, '/')">
 
 438         <xsl:value-of select="$slash-count - 1"/>
 
 441         <xsl:value-of select="$slash-count"/>
 
 448     <xsl:value-of select="$filename"/>
 
 449     <xsl:text> depth=</xsl:text>
 
 450     <xsl:value-of select="$depth"/>
 
 454   <xsl:if test="$depth > 0">
 
 455     <xsl:call-template name="copy-string">
 
 456       <xsl:with-param name="string">../</xsl:with-param>
 
 457       <xsl:with-param name="count" select="$depth"/>
 
 462 <xsl:template name="toc-directory-depth">
 
 463   <xsl:param name="filename"></xsl:param>
 
 464   <xsl:param name="count" select="0"/>
 
 467     <xsl:when test='contains($filename,"/")'>
 
 468       <xsl:call-template name="toc-directory-depth">
 
 469         <xsl:with-param name="filename"
 
 470                         select="substring-after($filename,'/')"/>
 
 471         <xsl:with-param name="count" select="$count + 1"/>
 
 475       <xsl:value-of select="$count"/>