source: trunk/gsdl-documentation/tutorials/processing/xml-to-workshop.xsl@ 13638

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

xsl transform files copied from gsdl-tutorials repository

  • 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:xalan="http://xml.apache.org/xalan">
5
6 <xsl:include href="common.xsl"/>
7
8 <xsl:output method="html"/>
9 <!-- set mode to cd/web/wiki depending on where the files will end up -->
10 <xsl:variable name="mode">cd</xsl:variable>
11
12 <xsl:variable name="manifest" select="document('manifest.xml')/Manifest"/>
13 <xsl:variable name="tutorial" select="/TutorialList"/>
14 <xsl:template match="/">
15 <xsl:call-template name="Index"/>
16 <xsl:apply-templates select="$manifest/Section"/>
17 </xsl:template>
18
19 <xsl:template name="Index">
20 <html>
21 <head>
22 <title><xsl:value-of select="$manifest/Title"/></title>
23 </head>
24 <body>
25 <a name="index"/>
26 <h1><xsl:value-of select="$manifest/Title"/></h1>
27 <xsl:apply-templates select="$manifest/Section" mode="index"/>
28 </body>
29 </html>
30 </xsl:template>
31
32 <xsl:template match="Section" mode="index">
33 <xsl:variable name="secnum" select="@number"/>
34 <h2><a href="{@id}.htm"><xsl:value-of select="Heading"/></a></h2>
35 <xsl:for-each select="TutorialRef|SplitTutorialRef">
36 <dl>
37 <xsl:variable name="id" select="@id"/>
38 <xsl:variable name="pos" select="position()"/>
39 <xsl:if test="self::TutorialRef">
40 <xsl:apply-templates select="$tutorial/Tutorial[@id=$id]" mode="index">
41 <xsl:with-param name="number"><xsl:value-of select="$secnum"/>.<xsl:value-of select="$pos"/></xsl:with-param>
42 </xsl:apply-templates>
43 </xsl:if>
44 <xsl:if test="self::SplitTutorialRef">
45 <xsl:apply-templates select="$tutorial/Tutorial[@id=$id]" mode="splitindex">
46 <xsl:with-param name="number"><xsl:value-of select="$secnum"/>.<xsl:value-of select="$pos"/></xsl:with-param>
47 <xsl:with-param name="split" select="@split"/>
48 <xsl:with-param name="type" select="@type"/>
49 <xsl:with-param name="current" select="@current"/>
50 <xsl:with-param name="titleextra" select="@titleextra"/>
51 </xsl:apply-templates>
52 </xsl:if>
53 </dl>
54 </xsl:for-each>
55 </xsl:template>
56
57 <xsl:template match="Section">
58 <xsl:variable name="secnum" select="@number"/>
59 <html>
60 <head>
61 <title><xsl:value-of select="Heading"/></title>
62 </head>
63 <body>
64 <a name="{@id}"/>
65 <h1><xsl:value-of select="Heading"/></h1>
66 <xsl:for-each select="TutorialRef|SplitTutorialRef">
67 <xsl:variable name="id" select="@id"/>
68 <xsl:variable name="pos" select="position()"/>
69 <xsl:if test="self::TutorialRef">
70 <xsl:apply-templates select="$tutorial/Tutorial[@id=$id]">
71 <xsl:with-param name="number"><xsl:value-of select="$secnum"/>.<xsl:value-of select="$pos"/></xsl:with-param>
72 </xsl:apply-templates>
73 </xsl:if>
74 <xsl:if test="self::SplitTutorialRef">
75 <xsl:apply-templates select="$tutorial/Tutorial[@id=$id]" mode="split">
76 <xsl:with-param name="number"><xsl:value-of select="$secnum"/>.<xsl:value-of select="$pos"/></xsl:with-param>
77 <xsl:with-param name="split" select="@split"/>
78 <xsl:with-param name="type" select="@type"/>
79 <xsl:with-param name="current" select="@current"/>
80 <xsl:with-param name="titleextra" select="@titleextra"/>
81 <xsl:with-param name="beginnotes" select="BeginNotes"/>
82 <xsl:with-param name="endnotes" select="EndNotes"/>
83 </xsl:apply-templates>
84 </xsl:if>
85 </xsl:for-each>
86 </body>
87 </html>
88 </xsl:template>
89
90 <xsl:template match="Tutorial">
91 <xsl:param name="number"/>
92 <h2><xsl:value-of select="$number"/>. <xsl:apply-templates select="Title/Text"/></h2>
93 <xsl:apply-templates select="Content/*"/>
94 </xsl:template>
95
96 <xsl:template match="Tutorial" mode="index">
97 <xsl:param name="number"/>
98 <dt><b><xsl:value-of select="$number"/>. <xsl:apply-templates select="Title/Text"/></b></dt>
99 <dd><xsl:for-each select="Content/Heading">
100 <xsl:apply-templates/><br/>
101 </xsl:for-each>
102 </dd>
103 </xsl:template>
104
105 <xsl:template match="Tutorial" mode="split">
106 <xsl:param name="number"/>
107 <xsl:param name="split"/>
108 <xsl:param name="type"/>
109 <xsl:param name="current"/>
110 <xsl:param name="titleextra"/>
111 <xsl:param name="beginnotes"/>
112 <xsl:param name="endnotes"/>
113 <h2><xsl:value-of select="$number"/>. <xsl:apply-templates select="Title/Text"/><xsl:value-of select="$titleextra"/></h2>
114 <xsl:apply-templates select="$beginnotes"/>
115 <xsl:variable name="splitnode" select="xalan:evaluate(concat('Content/',$split))"/>
116 <xsl:if test="$type='preceding'">
117 <xsl:for-each select="$splitnode">
118 <xsl:apply-templates select="preceding-sibling::node()"/>
119 </xsl:for-each>
120 </xsl:if>
121 <xsl:if test="$current='true'">
122 <xsl:apply-templates select="$splitnode"/>
123 </xsl:if>
124 <xsl:if test="$type='following'">
125 <xsl:for-each select="$splitnode">
126 <xsl:apply-templates select="following-sibling::node()"/>
127 </xsl:for-each>
128 </xsl:if>
129 <xsl:apply-templates select="$endnotes"/>
130 </xsl:template>
131
132 <xsl:template match="Tutorial" mode="splitindex">
133 <xsl:param name="number"/>
134 <xsl:param name="split"/>
135 <xsl:param name="type"/>
136 <xsl:param name="current"/>
137 <xsl:param name="titleextra"/>
138
139 <dt><b><xsl:value-of select="$number"/>. <xsl:apply-templates select="Title/Text"/><xsl:value-of select="$titleextra"/></b></dt>
140 <dd>
141 <xsl:variable name="splitnode" select="xalan:evaluate(concat('Content/',$split))"/>
142 <xsl:if test="$type='preceding'">
143 <xsl:for-each select="$splitnode">
144 <xsl:for-each select="preceding-sibling::Heading">
145 <xsl:apply-templates/><br/>
146 </xsl:for-each>
147 </xsl:for-each>
148 </xsl:if>
149 <xsl:if test="$current='true'">
150 <xsl:for-each select="$splitnode">
151 <xsl:apply-templates/><br/>
152 </xsl:for-each>
153 </xsl:if>
154 <xsl:if test="$type='following'">
155 <xsl:for-each select="$splitnode">
156 <xsl:for-each select="following-sibling::Heading">
157 <xsl:apply-templates/><br/>
158 </xsl:for-each>
159 </xsl:for-each>
160 </xsl:if>
161 </dd>
162 </xsl:template>
163
164 <xsl:template match="TutorialRef" priority="2">
165 <xsl:variable name="ref" select="@id"/>
166 <b><xsl:value-of select="/TutorialList/Tutorial[@id=$ref]/Title/Text"/></b>
167 </xsl:template>
168
169</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.