source: greenstone3/trunk/web/sites/localsite/collect/gberg/transform/document-toc.xsl@ 17022

Last change on this file since 17022 was 17022, checked in by max, 16 years ago

Move the HTML skeleton from style.xsl to the current XSL file + make it working with both GS2 and GS3 look and feel transformations.

  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:gs3="http://www.greenstone.org/gs3"
5 xmlns:java="http://xml.apache.org/xslt/java"
6 xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
7 extension-element-prefixes="java util"
8 exclude-result-prefixes="java util">
9
10 <!-- style includes global params interface_name, library_name -->
11 <xsl:include href="style.xsl"/>
12
13 <xsl:output method="html"/>
14
15 <!-- the main page layout template is here -->
16 <xsl:template match="page">
17
18 <xsl:choose>
19 <!-- if we are using hte classic GS2 look and feel use this template otherwise use the default GS3 look and feel template -->
20 <xsl:when test="$interface_name = 'gs2'">
21 <html>
22 <head>
23 <title>
24 <!-- put a space in the title in case the actual value is missing - mozilla will not display a page with no title-->
25 <xsl:call-template name="pageTitle"/><xsl:text> </xsl:text>
26 </title>
27 <xsl:call-template name="globalStyle"/>
28 <xsl:call-template name="pageStyle"/>
29 </head>
30 <body class="bgimage">
31 <xsl:attribute name="dir"><xsl:call-template name="direction"/></xsl:attribute>
32 <div id="page">
33 <xsl:apply-templates select="pageResponse"/>
34 <xsl:call-template name="greenstoneFooter"/>
35 </div>
36 </body>
37 </html>
38 </xsl:when>
39
40 <xsl:otherwise>
41 <html>
42 <head>
43 <title>
44 <!-- put a space in the title in case the actual value is missing - mozilla will not display a page with no title-->
45 <xsl:call-template name="pageTitle"/><xsl:text> </xsl:text>
46 </title>
47 <xsl:call-template name="globalStyle"/>
48 <xsl:call-template name="pageStyle"/>
49 </head>
50 <body>
51 <div id="globalwrapper">
52 <xsl:call-template name="response" />
53 <xsl:call-template name="greenstoneFooter"/>
54 </div>
55 </body>
56 </html>
57 </xsl:otherwise>
58 </xsl:choose>
59 </xsl:template>
60
61 <xsl:template name="pageTitle">
62 <xsl:value-of select="/page/pageResponse/documentNode/metadataList/metadata[@name='root_Title']"/>: Table of Contents
63 </xsl:template>
64
65 <!-- page specific style goes here -->
66 <xsl:template name="pageStyle"/>
67
68
69 <xsl:template match="pageResponse">
70 <xsl:variable name="collName"><xsl:value-of select="/page/pageRequest/paramList/param[@name='c']/@value"/></xsl:variable>
71 <xsl:call-template name="standardPageBanner">
72 <xsl:with-param name="collName" select="$collName"/>
73 </xsl:call-template>
74 <xsl:call-template name="navigationBar">
75 <xsl:with-param name="collName" select="$collName"/>
76 </xsl:call-template>
77 <!-- display the document -->
78 <xsl:apply-templates select="documentNode">
79 <xsl:with-param name="collName" select="$collName"/>
80 </xsl:apply-templates>
81 <xsl:call-template name="dividerBar"/>
82 </xsl:template>
83
84 <xsl:template match="documentNode">
85 <xsl:param name="collName"/>
86 <xsl:variable name="docname"><xsl:choose><xsl:when test="contains(@nodeID, '.')"><xsl:value-of select="substring-before(@nodeID, '.')"/></xsl:when><xsl:otherwise><xsl:value-of select="@nodeID"/></xsl:otherwise></xsl:choose></xsl:variable>
87 <h1>
88 <center>
89 <xsl:value-of select="metadataList/metadata[@name='root_Title']"/>
90 </center>
91 </h1>
92 <xsl:apply-templates select="nodeStructure/gutbook/book"><xsl:with-param name="collName" select="$collName"/><xsl:with-param name="docName" select="$docname"/></xsl:apply-templates>
93 </xsl:template>
94
95 <xsl:template match="book">
96 <xsl:param name="collName"/>
97 <xsl:param name="docName"/>
98 <h1>
99 Contents
100 </h1>
101 <ul class="toc">
102 <xsl:if test="acknowledge">
103 <li class='toc'>
104 <a href="{$library_name}?a=xd&amp;sa=text&amp;d={$docName}.acknowledge&amp;c={$collName}">Acknowledgements</a>
105 </li>
106 </xsl:if>
107 <xsl:if test="frontmatter">
108 <li class='toc'>
109 <a href="{$library_name}?a=xd&amp;sa=text&amp;d={$docName}.frontmatter&amp;c={$collName}">About this document</a>
110 </li>
111 </xsl:if>
112 <li class='toc'><a href="{$library_name}?a=xd&amp;sa=text&amp;d={$docName}&amp;c={$collName}">Full version</a>
113 </li>
114 </ul>
115 <xsl:apply-templates select="bookbody"><xsl:with-param name="collName" select="$collName"/><xsl:with-param name="docName" select="$docName"/></xsl:apply-templates>
116 <xsl:if test="backmatter">
117 <ul class='toc'>
118 <li class='toc'>
119 <a href="{$library_name}?a=xd&amp;sa=text&amp;d={$docName}.backmatter&amp;c={$collName}">Back matter (may include appendices, index, glossary etc)</a>
120 </li>
121 </ul>
122 </xsl:if>
123 </xsl:template>
124
125 <xsl:template match="bookbody">
126 <xsl:param name="collName"/>
127 <xsl:param name="docName"/>
128 <ul class="toc">
129 <xsl:apply-templates select="part|chapter">
130 <xsl:with-param name="collName" select="$collName"/>
131 <xsl:with-param name="docName" select="$docName"/>
132 </xsl:apply-templates>
133 </ul>
134 </xsl:template>
135
136 <xsl:template match="part">
137 <xsl:param name="collName"/>
138 <xsl:param name="docName"/>
139 <li class='toc'>
140 <a href="{$library_name}?a=xd&amp;sa=text&amp;c={$collName}&amp;d={$docName}.bookbody.part.{@gs3:id}">Part <xsl:value-of select="position()"/></a>
141 <xsl:if test="chapter">
142 <ul class='toc'>
143 <xsl:apply-templates select="chapter">
144 <xsl:with-param name="collName" select="$collName"/>
145 <xsl:with-param name="docName" select="$docName"/>
146 </xsl:apply-templates>
147 </ul>
148 </xsl:if>
149 </li>
150 </xsl:template>
151
152 <xsl:template match="chapter">
153 <xsl:param name="collName"/>
154 <xsl:param name="docName"/>
155 <li class='toc'>
156 <a href="{$library_name}?a=xd&amp;sa=text&amp;c={$collName}&amp;d={$docName}.bookbody.chapter.{@gs3:id}">
157 <xsl:choose>
158 <xsl:when test="title">
159 <xsl:value-of select="title"/>
160 </xsl:when>
161 <xsl:when test="chapheader">
162 <xsl:value-of select="chapheader/chapnum"/>: <xsl:value-of select="chapheader/title"/>
163 </xsl:when>
164 <xsl:otherwise>
165 Chapter <xsl:value-of select="position()"/>
166 </xsl:otherwise>
167 </xsl:choose>
168 </a>
169 </li>
170 </xsl:template>
171
172</xsl:stylesheet>
173
174
175
176
177
178
179
Note: See TracBrowser for help on using the repository browser.