diff options
author | Matthew Burgess <matthew@linuxfromscratch.org> | 2013-10-08 20:03:29 +0000 |
---|---|---|
committer | Matthew Burgess <matthew@linuxfromscratch.org> | 2013-10-08 20:03:29 +0000 |
commit | 15c7d39533a1eb1da0748011f3378fd0f02ed14d (patch) | |
tree | a7ed12df60c5ffd4d00a570804c51470bfb8b0f5 /stylesheets/lfs-xsl/docbook-xsl-1.78.1/website/toc.xsl | |
parent | 09a35dd7178070f01a7961d2ded39e11ba2aac83 (diff) |
Update stylesheets to docbook-xsl-1.78.1.
git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@10355 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689
Diffstat (limited to 'stylesheets/lfs-xsl/docbook-xsl-1.78.1/website/toc.xsl')
-rw-r--r-- | stylesheets/lfs-xsl/docbook-xsl-1.78.1/website/toc.xsl | 286 |
1 files changed, 286 insertions, 0 deletions
diff --git a/stylesheets/lfs-xsl/docbook-xsl-1.78.1/website/toc.xsl b/stylesheets/lfs-xsl/docbook-xsl-1.78.1/website/toc.xsl new file mode 100644 index 000000000..0252ea922 --- /dev/null +++ b/stylesheets/lfs-xsl/docbook-xsl-1.78.1/website/toc.xsl @@ -0,0 +1,286 @@ +<?xml version="1.0"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + version="1.0"> + +<xsl:output method="html"/> + +<xsl:param name="max.toc.width" select="7"/> + +<xsl:template match="toc/title|tocentry/title|titleabbrev"> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="toc"> + <xsl:param name="pageid" select="@id"/> + + <xsl:variable name="relpath"> + <xsl:call-template name="toc-rel-path"> + <xsl:with-param name="pageid" select="$pageid"/> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="homebanner" + select="/autolayout/config[@param='homebanner'][1]"/> + + <xsl:variable name="banner" + select="/autolayout/config[@param='banner'][1]"/> + + <xsl:variable name="homebannertext" + select="/autolayout/config[@param='homebannertext'][1]"/> + + <xsl:variable name="bannertext" + select="/autolayout/config[@param='bannertext'][1]"/> + + <xsl:choose> + <xsl:when test="$pageid = @id"> + <xsl:choose> + <xsl:when test="$homebanner"> + <img border="0"> + <xsl:attribute name="src"> + <xsl:value-of select="$relpath"/> + <xsl:value-of select="$homebanner/@value"/> + </xsl:attribute> + <xsl:attribute name="alt"> + <xsl:value-of select="$homebanner/@altval"/> + </xsl:attribute> + </img> + <xsl:value-of select="$currentpage.marker"/> + </xsl:when> + <xsl:when test="$homebannertext"> + <xsl:value-of select="$homebannertext/@value"/> + <xsl:value-of select="$currentpage.marker"/> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="gentext.nav.home"/> + <xsl:value-of select="$currentpage.marker"/> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <a href="{$relpath}{@dir}{$filename-prefix}{@filename}"> + <xsl:choose> + <xsl:when test="$banner"> + <img border="0"> + <xsl:attribute name="src"> + <xsl:value-of select="$relpath"/> + <xsl:value-of select="$banner/@value"/> + </xsl:attribute> + <xsl:attribute name="alt"> + <xsl:value-of select="$banner/@altval"/> + </xsl:attribute> + </img> + </xsl:when> + <xsl:when test="$bannertext"> + <xsl:value-of select="$bannertext/@value"/> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="gentext.nav.home"/> + </xsl:otherwise> + </xsl:choose> + </a> + </xsl:otherwise> + </xsl:choose> + + <xsl:text> | </xsl:text> + + <xsl:call-template name="process-children"> + <xsl:with-param name="pageid" select="$pageid"/> + <xsl:with-param name="relpath" select="$relpath"/> + </xsl:call-template> +</xsl:template> + +<xsl:template match="tocentry"> + <xsl:param name="pageid" select="@id"/> + <xsl:param name="relpath" select="''"/> + + <xsl:if test="preceding-sibling::tocentry"> + <xsl:text> | </xsl:text> + </xsl:if> + + <xsl:choose> + <xsl:when test="$pageid = @id"> + <xsl:choose> + <xsl:when test="titleabbrev"> + <xsl:apply-templates select="titleabbrev"/> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates select="title"/> + </xsl:otherwise> + </xsl:choose> + <xsl:value-of select="$currentpage.marker"/> + </xsl:when> + <xsl:otherwise> + <a> + <xsl:attribute name="href"> + <xsl:choose> + <xsl:when test="@href"> + <xsl:value-of select="@href"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$relpath"/> + <xsl:value-of select="@dir"/> + <xsl:value-of select="$filename-prefix"/> + <xsl:value-of select="@filename"/> + </xsl:otherwise> + </xsl:choose> + </xsl:attribute> + <xsl:choose> + <xsl:when test="titleabbrev"> + <xsl:apply-templates select="titleabbrev"/> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates select="title"/> + </xsl:otherwise> + </xsl:choose> + </a> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template match="toc|tocentry|notoc" mode="toc-rel-path"> + <xsl:call-template name="toc-rel-path"/> +</xsl:template> + +<xsl:template name="toc-rel-path"> + <xsl:param name="pageid" select="@id"/> + <xsl:variable name="entry" select="$autolayout//*[@id=$pageid]"/> + <xsl:variable name="filename" select="concat($entry/@dir,$entry/@filename)"/> + + <xsl:variable name="depth"> + <xsl:call-template name="toc-directory-depth"> + <xsl:with-param name="filename" select="$filename"/> + </xsl:call-template> + </xsl:variable> + + <xsl:if test="$depth > 0"> + <xsl:call-template name="copy-string"> + <xsl:with-param name="string">../</xsl:with-param> + <xsl:with-param name="count" select="$depth"/> + </xsl:call-template> + </xsl:if> +</xsl:template> + +<xsl:template name="toc-directory-depth"> + <xsl:param name="filename"></xsl:param> + <xsl:param name="count" select="0"/> + + <xsl:choose> + <xsl:when test='contains($filename,"/")'> + <xsl:call-template name="toc-directory-depth"> + <xsl:with-param name="filename" + select="substring-after($filename,'/')"/> + <xsl:with-param name="count" select="$count + 1"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$count"/> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template name="process-children"> + <xsl:param name="pageid" select="@id"/> + <xsl:param name="relpath" select="''"/> + + <xsl:choose> + <xsl:when test="tocentry[descendant-or-self::*[@id=$pageid]]"> + <xsl:call-template name="process-tocentry-children"> + <xsl:with-param name="pageid" select="$pageid"/> + <xsl:with-param name="relpath" select="$relpath"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="process-toc-children"> + <xsl:with-param name="pageid" select="$pageid"/> + <xsl:with-param name="relpath" select="$relpath"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template name="process-tocentry-children"> + <xsl:param name="pageid" select="@id"/> + <xsl:param name="relpath" select="''"/> + + <xsl:choose> + <xsl:when test="count(tocentry) > $max.toc.width"> + <xsl:variable name="cur" + select="tocentry[descendant-or-self::*[@id=$pageid]]"/> + + <xsl:variable name="half" select="$max.toc.width div 2"/> + + <xsl:variable name="all-nodes" + select="$cur/preceding-sibling::tocentry[position() < $half] + | $cur + | $cur/following-sibling::tocentry"/> + + <xsl:variable name="nodes" + select="$all-nodes[position() < $max.toc.width]"/> + + <xsl:if test="count($cur/preceding-sibling::tocentry) > $half"> + <xsl:text>...</xsl:text> + </xsl:if> + <xsl:apply-templates select="$nodes"> + <xsl:with-param name="pageid" select="$pageid"/> + <xsl:with-param name="relpath" select="$relpath"/> + </xsl:apply-templates> + <xsl:if test="count($all-nodes) > $max.toc.width"> + <xsl:text> | ...</xsl:text> + </xsl:if> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates select="tocentry"> + <xsl:with-param name="pageid" select="$pageid"/> + <xsl:with-param name="relpath" select="$relpath"/> + </xsl:apply-templates> + </xsl:otherwise> + </xsl:choose> + + <br/> + + <!-- if the current page isn't in this list, keep digging... --> + <xsl:if test="not(tocentry[$pageid=@id])"> + <xsl:for-each select="tocentry"> + <xsl:if test="descendant::*[@id=$pageid]"> + <xsl:call-template name="process-children"> + <xsl:with-param name="pageid" select="$pageid"/> + <xsl:with-param name="relpath" select="$relpath"/> + </xsl:call-template> + </xsl:if> + </xsl:for-each> + </xsl:if> +</xsl:template> + +<xsl:template name="process-toc-children"> + <xsl:param name="pageid" select="@id"/> + <xsl:param name="relpath" select="''"/> + + <xsl:choose> + <xsl:when test="count(tocentry) > $max.toc.width"> + <xsl:variable name="half" select="$max.toc.width div 2"/> + + <xsl:variable name="all-nodes" select="tocentry"/> + <xsl:variable name="nodes" + select="$all-nodes[position() < $max.toc.width]"/> + + <xsl:apply-templates select="$nodes"> + <xsl:with-param name="pageid" select="$pageid"/> + <xsl:with-param name="relpath" select="$relpath"/> + </xsl:apply-templates> + + <xsl:if test="count($all-nodes) > $max.toc.width"> + <xsl:text> | ...</xsl:text> + </xsl:if> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates select="tocentry"> + <xsl:with-param name="pageid" select="$pageid"/> + <xsl:with-param name="relpath" select="$relpath"/> + </xsl:apply-templates> + </xsl:otherwise> + </xsl:choose> + + <br/> +</xsl:template> + +</xsl:stylesheet> |