source: documentation/tags/2.81rc/tutorials/processing/xml-to-one-workshop.xsl@ 18845

Last change on this file since 18845 was 17494, checked in by anna, 16 years ago

Updated tutorials and associated files.

  • Property svn:keywords set to Author Date Id Revision
File size: 6.7 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
15 <xsl:template match="/">
16 <html>
17 <head>
18 <title><xsl:value-of select="$manifest/Title"/></title>
19 <style type="text/css">
20 h1.pagebreak {page-break-before: always}
21 </style>
22 </head>
23 <body>
24 <a name="index"/>
25 <h1><xsl:value-of select="$manifest/Title"/></h1>
26 <xsl:apply-templates select="$manifest/Section" mode="index"/>
27 <xsl:apply-templates select="$manifest/Section"/>
28
29 <div style="text-align:center;"><xsl:apply-templates select="/TutorialList/SupplementaryText/Text[@id='copyright']"/></div>
30
31 </body>
32 </html>
33 </xsl:template>
34
35
36 <xsl:template match="Section" mode="index">
37 <xsl:variable name="secnum" select="@number"/>
38 <div style="page-break-after: always;">
39 <h2><a href="#{@id}"><xsl:value-of select="Heading"/></a></h2>
40 <xsl:for-each select="TutorialRef|SplitTutorialRef">
41 <dl>
42 <xsl:variable name="id" select="@id"/>
43 <xsl:variable name="pos" select="position()"/>
44 <xsl:if test="self::TutorialRef">
45 <xsl:apply-templates select="$tutorial/Tutorial[@id=$id]" mode="index">
46 <xsl:with-param name="number">
47 <xsl:value-of select="$pos"/>
48 <!--<xsl:value-of select="$secnum"/>.<xsl:value-of select="$pos"/>-->
49 </xsl:with-param>
50 </xsl:apply-templates>
51 </xsl:if>
52 <xsl:if test="self::SplitTutorialRef">
53 <xsl:apply-templates select="$tutorial/Tutorial[@id=$id]" mode="splitindex">
54 <xsl:with-param name="number">
55 <xsl:value-of select="$pos"/>
56 <!--<xsl:value-of select="$secnum"/>.<xsl:value-of select="$pos"/>-->
57 </xsl:with-param>
58 <xsl:with-param name="split" select="@split"/>
59 <xsl:with-param name="type" select="@type"/>
60 <xsl:with-param name="current" select="@current"/>
61 <xsl:with-param name="titleextra" select="@titleextra"/>
62 </xsl:apply-templates>
63 </xsl:if>
64 </dl>
65 </xsl:for-each>
66 </div>
67 </xsl:template>
68
69 <xsl:template match="Section">
70 <xsl:variable name="secnum" select="@number"/>
71 <a name="{@id}"/>
72 <h1 class="pagebreak"><xsl:value-of select="Heading"/></h1>
73 <xsl:for-each select="TutorialRef|SplitTutorialRef">
74 <xsl:variable name="id" select="@id"/>
75 <xsl:variable name="pos" select="position()"/>
76 <xsl:if test="self::TutorialRef">
77 <xsl:apply-templates select="$tutorial/Tutorial[@id=$id]">
78 <xsl:with-param name="number">
79 <!-- for just one section -->
80 <xsl:value-of select="$pos"/>
81 <!-- for more than one sections -->
82 <!--<xsl:value-of select="$secnum"/>.<xsl:value-of select="$pos"/>-->
83 </xsl:with-param>
84 </xsl:apply-templates>
85 </xsl:if>
86 <xsl:if test="self::SplitTutorialRef">
87 <xsl:apply-templates select="$tutorial/Tutorial[@id=$id]" mode="split">
88 <xsl:with-param name="number">
89 <xsl:value-of select="$pos"/>
90 <!--<xsl:value-of select="$secnum"/>.<xsl:value-of select="$pos"/>-->
91 </xsl:with-param>
92 <xsl:with-param name="split" select="@split"/>
93 <xsl:with-param name="type" select="@type"/>
94 <xsl:with-param name="current" select="@current"/>
95 <xsl:with-param name="titleextra" select="@titleextra"/>
96 <xsl:with-param name="beginnotes" select="BeginNotes"/>
97 <xsl:with-param name="endnotes" select="EndNotes"/>
98 </xsl:apply-templates>
99 </xsl:if>
100 </xsl:for-each>
101 </xsl:template>
102
103 <xsl:template match="Tutorial">
104 <xsl:param name="number"/>
105 <div style="page-break-after: always;">
106 <h2><xsl:value-of select="$number"/>. <xsl:apply-templates select="Title/Text"/></h2>
107 <xsl:apply-templates select="Content/*"/>
108 </div>
109 </xsl:template>
110
111 <xsl:template match="Tutorial" mode="index">
112 <xsl:param name="number"/>
113 <dt><b><xsl:value-of select="$number"/>. <xsl:apply-templates select="Title/Text"/></b></dt>
114 <dd><xsl:for-each select="Content/Heading">
115 <xsl:apply-templates/><br/>
116 </xsl:for-each>
117 </dd>
118 </xsl:template>
119
120 <xsl:template match="Tutorial" mode="split">
121 <xsl:param name="number"/>
122 <xsl:param name="split"/>
123 <xsl:param name="type"/>
124 <xsl:param name="current"/>
125 <xsl:param name="titleextra"/>
126 <xsl:param name="beginnotes"/>
127 <xsl:param name="endnotes"/>
128
129 <div style="page-break-after: always;">
130 <h2><xsl:value-of select="$number"/>. <xsl:apply-templates select="Title/Text"/><xsl:value-of select="$titleextra"/></h2>
131 <xsl:apply-templates select="$beginnotes"/>
132 <xsl:variable name="splitnode" select="xalan:evaluate(concat('Content/',$split))"/>
133 <xsl:if test="$type='preceding'">
134 <xsl:for-each select="$splitnode">
135 <xsl:apply-templates select="preceding-sibling::node()"/>
136 </xsl:for-each>
137 </xsl:if>
138 <xsl:if test="$current='true'">
139 <xsl:apply-templates select="$splitnode"/>
140 </xsl:if>
141 <xsl:if test="$type='following'">
142 <xsl:for-each select="$splitnode">
143 <xsl:apply-templates select="following-sibling::node()"/>
144 </xsl:for-each>
145 </xsl:if>
146 <xsl:apply-templates select="$endnotes"/>
147 </div>
148 </xsl:template>
149
150 <xsl:template match="Tutorial" mode="splitindex">
151 <xsl:param name="number"/>
152 <xsl:param name="split"/>
153 <xsl:param name="type"/>
154 <xsl:param name="current"/>
155 <xsl:param name="titleextra"/>
156
157 <dt><b><xsl:value-of select="$number"/>. <xsl:apply-templates select="Title/Text"/><xsl:value-of select="$titleextra"/></b></dt>
158 <dd>
159 <xsl:variable name="splitnode" select="xalan:evaluate(concat('Content/',$split))"/>
160 <xsl:if test="$type='preceding'">
161 <xsl:for-each select="$splitnode">
162 <xsl:for-each select="preceding-sibling::Heading">
163 <xsl:apply-templates/><br/>
164 </xsl:for-each>
165 </xsl:for-each>
166 </xsl:if>
167 <xsl:if test="$current='true'">
168 <xsl:for-each select="$splitnode">
169 <xsl:apply-templates/><br/>
170 </xsl:for-each>
171 </xsl:if>
172 <xsl:if test="$type='following'">
173 <xsl:for-each select="$splitnode">
174 <xsl:for-each select="following-sibling::Heading">
175 <xsl:apply-templates/><br/>
176 </xsl:for-each>
177 </xsl:for-each>
178 </xsl:if>
179 </dd>
180 </xsl:template>
181
182 <xsl:template match="TutorialRef" priority="2">
183 <xsl:variable name="ref" select="@id"/>
184 <b><xsl:value-of select="/TutorialList/Tutorial[@id=$ref]/Title/Text"/></b>
185 </xsl:template>
186
187</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.