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:dict="http://xml.apache.org/xalan/java/Dictionary"
|
---|
5 | exclude-result-prefixes="dict">
|
---|
6 |
|
---|
7 | <!--The following strips newlines introduced by elements, in particular introduced around the MajorVersion template match
|
---|
8 | See http://stackoverflow.com/questions/3265244/removing-blank-lines-in-xslt
|
---|
9 | and http://msdn.microsoft.com/en-us/library/ms256107.aspx -->
|
---|
10 | <xsl:strip-space elements="*"/>
|
---|
11 |
|
---|
12 | <xsl:variable name="diction" select="dict:new('en')"/>
|
---|
13 |
|
---|
14 | <xsl:template match="Heading">
|
---|
15 | <p><b><i><xsl:apply-templates select="Text"/></i></b></p>
|
---|
16 | </xsl:template>
|
---|
17 |
|
---|
18 | <xsl:template match="NumberedItem">
|
---|
19 | <ol><xsl:attribute name="start"><xsl:number/></xsl:attribute>
|
---|
20 | <li>
|
---|
21 | <xsl:for-each select="node()">
|
---|
22 | <xsl:apply-templates select="."/><!--<xsl:if test="self::Text and preceding-sibling::Text"><p/></xsl:if>-->
|
---|
23 | </xsl:for-each>
|
---|
24 | </li>
|
---|
25 | </ol>
|
---|
26 | </xsl:template>
|
---|
27 |
|
---|
28 | <xsl:template match="BulletList">
|
---|
29 | <ul style="list-style-type: disc;">
|
---|
30 | <xsl:for-each select="Bullet">
|
---|
31 | <li><xsl:apply-templates/></li>
|
---|
32 | </xsl:for-each>
|
---|
33 | </ul>
|
---|
34 | <p/>
|
---|
35 | </xsl:template>
|
---|
36 |
|
---|
37 | <xsl:template match="Text">
|
---|
38 | <xsl:apply-templates/><xsl:if test="parent::Content|parent::NumberedItem"><p/></xsl:if>
|
---|
39 | </xsl:template>
|
---|
40 |
|
---|
41 | <xsl:template match="Comment">
|
---|
42 | <p><i><xsl:apply-templates/></i></p>
|
---|
43 | </xsl:template>
|
---|
44 |
|
---|
45 | <xsl:template match="Indent">
|
---|
46 | <p><div style="margin-left: 2em;">
|
---|
47 | <xsl:apply-templates/>
|
---|
48 | </div></p>
|
---|
49 | </xsl:template>
|
---|
50 |
|
---|
51 | <xsl:template match="Tab">
|
---|
52 | <xsl:variable name="tabspace" select="@n*1.5"/>
|
---|
53 | <span style="margin-left: {$tabspace}em;">
|
---|
54 | <xsl:apply-templates/>
|
---|
55 | </span>
|
---|
56 | </xsl:template>
|
---|
57 |
|
---|
58 | <xsl:template match="span|img|table|b|br|td|tr|u">
|
---|
59 | <xsl:copy><xsl:for-each select="@*"><xsl:copy/></xsl:for-each>
|
---|
60 | <xsl:apply-templates/>
|
---|
61 | </xsl:copy>
|
---|
62 | </xsl:template>
|
---|
63 |
|
---|
64 | <xsl:template match="i">
|
---|
65 | <xsl:choose>
|
---|
66 | <xsl:when test="ancestor::Comment">
|
---|
67 | <span style="font-style:normal;"><xsl:apply-templates/></span>
|
---|
68 | </xsl:when>
|
---|
69 | <xsl:otherwise>
|
---|
70 | <i><xsl:apply-templates/></i>
|
---|
71 | </xsl:otherwise>
|
---|
72 | </xsl:choose>
|
---|
73 | </xsl:template>
|
---|
74 |
|
---|
75 | <xsl:template match="Link">
|
---|
76 | <xsl:choose>
|
---|
77 | <xsl:when test="not(parent::Text)">
|
---|
78 | <p><div style="margin-left: 2em;">
|
---|
79 | <a><xsl:attribute name="href"><xsl:choose><xsl:when test="@url"><xsl:value-of select="@url"/></xsl:when><xsl:otherwise><xsl:value-of select="."/></xsl:otherwise></xsl:choose></xsl:attribute><xsl:value-of select="."/></a>
|
---|
80 | </div></p>
|
---|
81 | </xsl:when>
|
---|
82 | <xsl:otherwise>
|
---|
83 | <a><xsl:attribute name="href"><xsl:choose><xsl:when test="@url"><xsl:value-of select="@url"/></xsl:when><xsl:otherwise><xsl:value-of select="."/></xsl:otherwise></xsl:choose></xsl:attribute><xsl:value-of select="."/></a>
|
---|
84 | </xsl:otherwise>
|
---|
85 | </xsl:choose>
|
---|
86 | </xsl:template>
|
---|
87 |
|
---|
88 | <xsl:template match="TutorialRef">
|
---|
89 | <xsl:variable name="ref" select="@id"/>
|
---|
90 | <a href="{@id}.htm"><xsl:value-of select="/TutorialList/Tutorial[@id=$ref]/Title/Text"/></a>
|
---|
91 | </xsl:template>
|
---|
92 |
|
---|
93 | <xsl:template match="Path">
|
---|
94 | <xsl:choose>
|
---|
95 | <xsl:when test="not(parent::Text)">
|
---|
96 | <p><div style="margin-left: 2em;">
|
---|
97 | <i><xsl:value-of select="."/></i>
|
---|
98 | </div></p>
|
---|
99 | </xsl:when>
|
---|
100 | <xsl:otherwise>
|
---|
101 | <i><xsl:value-of select="."/></i>
|
---|
102 | </xsl:otherwise>
|
---|
103 | </xsl:choose>
|
---|
104 | </xsl:template>
|
---|
105 |
|
---|
106 |
|
---|
107 | <xsl:template match="Menu">
|
---|
108 | <xsl:choose>
|
---|
109 | <xsl:when test="not(parent::Text)">
|
---|
110 | <p><div style="margin-left: 2em;">
|
---|
111 | <b><xsl:apply-templates/></b>
|
---|
112 | </div></p>
|
---|
113 | </xsl:when>
|
---|
114 | <xsl:otherwise>
|
---|
115 | <b><xsl:apply-templates/></b>
|
---|
116 | </xsl:otherwise>
|
---|
117 | </xsl:choose>
|
---|
118 | </xsl:template>
|
---|
119 |
|
---|
120 |
|
---|
121 | <xsl:template match="Format|Command">
|
---|
122 | <xsl:choose>
|
---|
123 | <xsl:when test="not(parent::Text)">
|
---|
124 | <p><div style="margin-left: 2em;">
|
---|
125 | <small><tt><xsl:apply-templates/></tt></small>
|
---|
126 | </div></p>
|
---|
127 | </xsl:when>
|
---|
128 | <xsl:otherwise>
|
---|
129 | <small><tt><xsl:apply-templates/></tt></small>
|
---|
130 | </xsl:otherwise>
|
---|
131 | </xsl:choose>
|
---|
132 | </xsl:template>
|
---|
133 |
|
---|
134 | <xsl:template match="Indent">
|
---|
135 | <div style="margin-left: 2em;">
|
---|
136 | <xsl:apply-templates/>
|
---|
137 | </div>
|
---|
138 | <p/>
|
---|
139 | </xsl:template>
|
---|
140 |
|
---|
141 | <xsl:template match="highlight">
|
---|
142 | <span style="background-color: lightgrey;"><xsl:apply-templates/></span>
|
---|
143 | </xsl:template>
|
---|
144 |
|
---|
145 | <!-- old question and answer templates
|
---|
146 | <xsl:template match="Question">
|
---|
147 | <span style="float:right;text-align:right;"><i><xsl:apply-templates select="following-sibling::Answer" mode="output"/></i></span><xsl:apply-templates/>
|
---|
148 | </xsl:template>
|
---|
149 |
|
---|
150 | <xsl:template match="Answer" mode="output">
|
---|
151 | <xsl:apply-templates/>
|
---|
152 | </xsl:template>
|
---|
153 | -->
|
---|
154 |
|
---|
155 | <!-- Don't output the Answers, or the Updated tags-->
|
---|
156 | <xsl:template match="Answer|Updated"/>
|
---|
157 |
|
---|
158 | <!-- the supplementary bits -->
|
---|
159 | <xsl:template match="Prerequisite" mode="individual">
|
---|
160 | <xsl:variable name="ref" select="@id"/>
|
---|
161 | <xsl:apply-templates select="/TutorialList/SupplementaryText/Text[@id='prereq']"/><xsl:text> </xsl:text><a href="{@id}.htm"><xsl:value-of select="/TutorialList/Tutorial[@id=$ref]/Title/Text"/></a><br/>
|
---|
162 | </xsl:template>
|
---|
163 |
|
---|
164 | <xsl:template match="Prerequisite" mode="combined">
|
---|
165 | <xsl:variable name="ref" select="@id"/>
|
---|
166 | <xsl:apply-templates select="/TutorialList/SupplementaryText/Text[@id='prereq']"/><xsl:text> </xsl:text><a href="#{@id}"><xsl:value-of select="/TutorialList/Tutorial[@id=$ref]/Title/Text"/></a><br/>
|
---|
167 | </xsl:template>
|
---|
168 |
|
---|
169 | <xsl:template match="Version">
|
---|
170 | <xsl:apply-templates select="/TutorialList/SupplementaryText/Text[@id='original']"/><xsl:text> </xsl:text><xsl:value-of select="@initial"/><br/>
|
---|
171 | <xsl:if test="not(@current=@initial)"><xsl:apply-templates select="/TutorialList/SupplementaryText/Text[@id='current']"/><xsl:text> </xsl:text><xsl:value-of select="@current"/></xsl:if>
|
---|
172 | </xsl:template>
|
---|
173 |
|
---|
174 | <!-- Do not process any elements marked with MajorVersion and whose version does not
|
---|
175 | specifically match the requested greenstone major version (2 or 3) -->
|
---|
176 | <!--To avoid multiple lines of whitespace around output, use
|
---|
177 | <xsl:for-each select="node()"><xsl:apply-templates/></xsl:for-each>
|
---|
178 | This outputs the contents on its own separate line.
|
---|
179 | To avoid thinking about unnecessary newlines and to avoid omitting any sub-xml items
|
---|
180 | that need to be processed, we can instead have the following at the top of the file:
|
---|
181 | <xsl:strip-space elements="*"/> -->
|
---|
182 | <xsl:template match="MajorVersion">
|
---|
183 | <xsl:if test="$gs-major-version=@number">
|
---|
184 | <xsl:apply-templates/>
|
---|
185 | </xsl:if>
|
---|
186 | </xsl:template>
|
---|
187 |
|
---|
188 | <xsl:template name="SampleFiles">
|
---|
189 | <xsl:param name="mode">web</xsl:param>
|
---|
190 | <xsl:choose><xsl:when test="$mode='wiki'">
|
---|
191 | <xsl:apply-templates select="/TutorialList/SupplementaryText/Text[@id='sample']"/><xsl:text> </xsl:text><xsl:for-each select="SampleFiles"><a href="../sample_files/{@folder}.zip"><xsl:value-of select="@folder"/>.zip</a><xsl:text> </xsl:text></xsl:for-each><br/>
|
---|
192 | </xsl:when>
|
---|
193 | <xsl:otherwise>
|
---|
194 | <xsl:apply-templates select="/TutorialList/SupplementaryText/Text[@id='sample']"/><xsl:text> </xsl:text><xsl:for-each select="SampleFiles"><xsl:value-of select="@folder"/><xsl:text> </xsl:text></xsl:for-each><br/>
|
---|
195 | </xsl:otherwise>
|
---|
196 | </xsl:choose>
|
---|
197 | </xsl:template>
|
---|
198 |
|
---|
199 | <xsl:template name="IndexLink">
|
---|
200 | <xsl:param name="mode">individual</xsl:param>
|
---|
201 | <xsl:choose><xsl:when test="$mode='individual'">
|
---|
202 | <a href="index.html"><xsl:apply-templates select="/TutorialList/SupplementaryText/Text[@id='index']"/></a><br/>
|
---|
203 | </xsl:when>
|
---|
204 | <xsl:otherwise>
|
---|
205 | <a href="#index"><xsl:apply-templates select="/TutorialList/SupplementaryText/Text[@id='index']"/></a><br/>
|
---|
206 | </xsl:otherwise>
|
---|
207 | </xsl:choose>
|
---|
208 |
|
---|
209 | </xsl:template>
|
---|
210 |
|
---|
211 | <xsl:template name="WikiLink">
|
---|
212 | <a href="http://greenstone.sourceforge.net/wiki/index.php/Tutorial_exercises"><xsl:apply-templates select="/TutorialList/SupplementaryText/Text[@id='wiki']"/></a><br/>
|
---|
213 | </xsl:template>
|
---|
214 |
|
---|
215 | <xsl:template match="AutoText">
|
---|
216 | <xsl:variable name="value"><xsl:choose><xsl:when test="@key"><xsl:variable name="key" select="@key"/><xsl:variable name="args" select="@args"/><xsl:value-of select="dict:get($diction, $key, $args)"/></xsl:when><xsl:otherwise><xsl:value-of select="@text"/></xsl:otherwise></xsl:choose></xsl:variable>
|
---|
217 | <xsl:choose>
|
---|
218 | <xsl:when test="@type='button'">
|
---|
219 | <b><<xsl:value-of select="$value"/>></b>
|
---|
220 | </xsl:when>
|
---|
221 | <xsl:when test="@type='quoted'">
|
---|
222 | <xsl:text>"</xsl:text><xsl:value-of select="$value"/><xsl:text>"</xsl:text>
|
---|
223 | </xsl:when>
|
---|
224 | <xsl:when test="@type='italics'">
|
---|
225 | <i><xsl:value-of select="$value"/></i>
|
---|
226 | </xsl:when>
|
---|
227 | <xsl:when test="@type='plain'">
|
---|
228 | <xsl:value-of select="$value"/>
|
---|
229 | </xsl:when>
|
---|
230 | <xsl:otherwise>
|
---|
231 | <b><xsl:value-of select="$value"/></b>
|
---|
232 | </xsl:otherwise>
|
---|
233 | </xsl:choose>
|
---|
234 | </xsl:template>
|
---|
235 |
|
---|
236 | </xsl:stylesheet>
|
---|
237 |
|
---|