source: documentation/stable/tutorials/processing/common.xsl@ 20741

Last change on this file since 20741 was 13638, checked in by kjdon, 17 years ago

xsl transform files copied from gsdl-tutorials repository

  • Property svn:keywords set to Author Date Id Revision
File size: 7.5 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:dict="http://xml.apache.org/xalan/java/Dictionary"
5 exclude-result-prefixes="dict">
6
7 <xsl:variable name="diction" select="dict:new('en')"/>
8
9 <xsl:template match="Heading">
10 <p><b><i><xsl:apply-templates select="Text"/></i></b></p>
11 </xsl:template>
12
13 <xsl:template match="NumberedItem">
14 <ol><xsl:attribute name="start"><xsl:number/></xsl:attribute>
15 <li>
16 <xsl:for-each select="node()">
17 <xsl:apply-templates select="."/><!--<xsl:if test="self::Text and preceding-sibling::Text"><p/></xsl:if>-->
18 </xsl:for-each>
19 </li>
20 </ol>
21 </xsl:template>
22
23 <xsl:template match="BulletList">
24 <ul style="list-style-type: disc;">
25 <xsl:for-each select="Bullet">
26 <li><xsl:apply-templates/></li>
27 </xsl:for-each>
28 </ul>
29 <p/>
30 </xsl:template>
31
32 <xsl:template match="Text">
33 <xsl:apply-templates/><xsl:if test="parent::Content|parent::NumberedItem"><p/></xsl:if>
34 </xsl:template>
35
36 <xsl:template match="Comment">
37 <p><i><xsl:apply-templates/></i></p>
38 </xsl:template>
39
40 <xsl:template match="Indent">
41 <p><div style="margin-left: 2em;">
42 <xsl:apply-templates/>
43 </div></p>
44 </xsl:template>
45
46 <xsl:template match="span|img|table|b|br|td|tr|u">
47 <xsl:copy><xsl:for-each select="@*"><xsl:copy/></xsl:for-each>
48 <xsl:apply-templates/>
49 </xsl:copy>
50 </xsl:template>
51
52 <xsl:template match="i">
53 <xsl:choose>
54 <xsl:when test="ancestor::Comment">
55 <span style="font-style:normal;"><xsl:apply-templates/></span>
56 </xsl:when>
57 <xsl:otherwise>
58 <i><xsl:apply-templates/></i>
59 </xsl:otherwise>
60 </xsl:choose>
61 </xsl:template>
62
63 <xsl:template match="Link">
64 <xsl:choose>
65 <xsl:when test="not(parent::Text)">
66 <p><div style="margin-left: 2em;">
67 <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>
68 </div></p>
69 </xsl:when>
70 <xsl:otherwise>
71 <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>
72 </xsl:otherwise>
73 </xsl:choose>
74 </xsl:template>
75
76 <xsl:template match="TutorialRef">
77 <xsl:variable name="ref" select="@id"/>
78 <a href="{@id}.htm"><xsl:value-of select="/TutorialList/Tutorial[@id=$ref]/Title/Text"/></a>
79 </xsl:template>
80
81 <xsl:template match="Path">
82 <xsl:choose>
83 <xsl:when test="not(parent::Text)">
84 <p><div style="margin-left: 2em;">
85 <i><xsl:value-of select="."/></i>
86 </div></p>
87 </xsl:when>
88 <xsl:otherwise>
89 <i><xsl:value-of select="."/></i>
90 </xsl:otherwise>
91 </xsl:choose>
92 </xsl:template>
93
94
95 <xsl:template match="Menu">
96 <xsl:choose>
97 <xsl:when test="not(parent::Text)">
98 <p><div style="margin-left: 2em;">
99 <b><xsl:apply-templates/></b>
100 </div></p>
101 </xsl:when>
102 <xsl:otherwise>
103 <b><xsl:apply-templates/></b>
104 </xsl:otherwise>
105 </xsl:choose>
106 </xsl:template>
107
108
109 <xsl:template match="Format|Command">
110 <xsl:choose>
111 <xsl:when test="not(parent::Text)">
112 <p><div style="margin-left: 2em;">
113 <small><tt><xsl:apply-templates/></tt></small>
114 </div></p>
115 </xsl:when>
116 <xsl:otherwise>
117 <small><tt><xsl:apply-templates/></tt></small>
118 </xsl:otherwise>
119 </xsl:choose>
120 </xsl:template>
121
122 <xsl:template match="Indent">
123 <div style="margin-left: 2em;">
124 <xsl:apply-templates/>
125 </div>
126 <p/>
127 </xsl:template>
128
129 <xsl:template match="highlight">
130 <span style="background-color: lightgrey;"><xsl:apply-templates/></span>
131 </xsl:template>
132
133<!-- old question and answer templates
134 <xsl:template match="Question">
135 <span style="float:right;text-align:right;"><i><xsl:apply-templates select="following-sibling::Answer" mode="output"/></i></span><xsl:apply-templates/>
136 </xsl:template>
137
138 <xsl:template match="Answer" mode="output">
139 <xsl:apply-templates/>
140 </xsl:template>
141-->
142
143 <!-- Don't output the Answers, or the Updated tags-->
144 <xsl:template match="Answer|Updated"/>
145
146 <!-- the supplementary bits -->
147 <xsl:template match="Prerequisite" mode="individual">
148 <xsl:variable name="ref" select="@id"/>
149 <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/>
150 </xsl:template>
151
152 <xsl:template match="Prerequisite" mode="combined">
153 <xsl:variable name="ref" select="@id"/>
154 <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/>
155 </xsl:template>
156
157 <xsl:template match="Version">
158 <xsl:apply-templates select="/TutorialList/SupplementaryText/Text[@id='original']"/><xsl:text> </xsl:text><xsl:value-of select="@initial"/><br/>
159 <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>
160 </xsl:template>
161
162 <xsl:template name="SampleFiles">
163 <xsl:param name="mode">web</xsl:param>
164 <xsl:choose><xsl:when test="$mode='wiki'">
165 <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/>
166 </xsl:when>
167 <xsl:otherwise>
168 <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/>
169 </xsl:otherwise>
170 </xsl:choose>
171 </xsl:template>
172
173 <xsl:template name="IndexLink">
174 <xsl:param name="mode">individual</xsl:param>
175 <xsl:choose><xsl:when test="$mode='individual'">
176 <a href="index.html"><xsl:apply-templates select="/TutorialList/SupplementaryText/Text[@id='index']"/></a><br/>
177 </xsl:when>
178 <xsl:otherwise>
179 <a href="#index"><xsl:apply-templates select="/TutorialList/SupplementaryText/Text[@id='index']"/></a><br/>
180 </xsl:otherwise>
181 </xsl:choose>
182
183 </xsl:template>
184
185 <xsl:template name="WikiLink">
186 <a href="http://greenstone.sourceforge.net/wiki/index.php/Tutorial_exercises"><xsl:apply-templates select="/TutorialList/SupplementaryText/Text[@id='wiki']"/></a><br/>
187 </xsl:template>
188
189 <xsl:template match="AutoText">
190 <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>
191 <xsl:choose>
192 <xsl:when test="@type='button'">
193 <b>&lt;<xsl:value-of select="$value"/>&gt;</b>
194 </xsl:when>
195 <xsl:when test="@type='quoted'">
196 <xsl:text>"</xsl:text><xsl:value-of select="$value"/><xsl:text>"</xsl:text>
197 </xsl:when>
198 <xsl:when test="@type='italics'">
199 <i><xsl:value-of select="$value"/></i>
200 </xsl:when>
201 <xsl:when test="@type='plain'">
202 <xsl:value-of select="$value"/>
203 </xsl:when>
204 <xsl:otherwise>
205 <b><xsl:value-of select="$value"/></b>
206 </xsl:otherwise>
207 </xsl:choose>
208 </xsl:template>
209
210</xsl:stylesheet>
211
Note: See TracBrowser for help on using the repository browser.