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

Last change on this file since 13638 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: 6.0 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 </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}"><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 <a name="{@id}"/>
60 <h1 class="pagebreak"><xsl:value-of select="Heading"/></h1>
61 <xsl:for-each select="TutorialRef|SplitTutorialRef">
62 <xsl:variable name="id" select="@id"/>
63 <xsl:variable name="pos" select="position()"/>
64 <xsl:if test="self::TutorialRef">
65 <xsl:apply-templates select="$tutorial/Tutorial[@id=$id]">
66 <xsl:with-param name="number"><xsl:value-of select="$secnum"/>.<xsl:value-of select="$pos"/></xsl:with-param>
67 </xsl:apply-templates>
68 </xsl:if>
69 <xsl:if test="self::SplitTutorialRef">
70 <xsl:apply-templates select="$tutorial/Tutorial[@id=$id]" mode="split">
71 <xsl:with-param name="number"><xsl:value-of select="$secnum"/>.<xsl:value-of select="$pos"/></xsl:with-param>
72 <xsl:with-param name="split" select="@split"/>
73 <xsl:with-param name="type" select="@type"/>
74 <xsl:with-param name="current" select="@current"/>
75 <xsl:with-param name="titleextra" select="@titleextra"/>
76 <xsl:with-param name="beginnotes" select="BeginNotes"/>
77 <xsl:with-param name="endnotes" select="EndNotes"/>
78 </xsl:apply-templates>
79 </xsl:if>
80 </xsl:for-each>
81 </xsl:template>
82
83 <xsl:template match="Tutorial">
84 <xsl:param name="number"/>
85 <h2><xsl:value-of select="$number"/>. <xsl:apply-templates select="Title/Text"/></h2>
86 <xsl:apply-templates select="Content/*"/>
87 </xsl:template>
88
89 <xsl:template match="Tutorial" mode="index">
90 <xsl:param name="number"/>
91 <dt><b><xsl:value-of select="$number"/>. <xsl:apply-templates select="Title/Text"/></b></dt>
92 <dd><xsl:for-each select="Content/Heading">
93 <xsl:apply-templates/><br/>
94 </xsl:for-each>
95 </dd>
96 </xsl:template>
97
98 <xsl:template match="Tutorial" mode="split">
99 <xsl:param name="number"/>
100 <xsl:param name="split"/>
101 <xsl:param name="type"/>
102 <xsl:param name="current"/>
103 <xsl:param name="titleextra"/>
104 <xsl:param name="beginnotes"/>
105 <xsl:param name="endnotes"/>
106 <h2><xsl:value-of select="$number"/>. <xsl:apply-templates select="Title/Text"/><xsl:value-of select="$titleextra"/></h2>
107 <xsl:apply-templates select="$beginnotes"/>
108 <xsl:variable name="splitnode" select="xalan:evaluate(concat('Content/',$split))"/>
109 <xsl:if test="$type='preceding'">
110 <xsl:for-each select="$splitnode">
111 <xsl:apply-templates select="preceding-sibling::node()"/>
112 </xsl:for-each>
113 </xsl:if>
114 <xsl:if test="$current='true'">
115 <xsl:apply-templates select="$splitnode"/>
116 </xsl:if>
117 <xsl:if test="$type='following'">
118 <xsl:for-each select="$splitnode">
119 <xsl:apply-templates select="following-sibling::node()"/>
120 </xsl:for-each>
121 </xsl:if>
122 <xsl:apply-templates select="$endnotes"/>
123 </xsl:template>
124
125 <xsl:template match="Tutorial" mode="splitindex">
126 <xsl:param name="number"/>
127 <xsl:param name="split"/>
128 <xsl:param name="type"/>
129 <xsl:param name="current"/>
130 <xsl:param name="titleextra"/>
131
132 <dt><b><xsl:value-of select="$number"/>. <xsl:apply-templates select="Title/Text"/><xsl:value-of select="$titleextra"/></b></dt>
133 <dd>
134 <xsl:variable name="splitnode" select="xalan:evaluate(concat('Content/',$split))"/>
135 <xsl:if test="$type='preceding'">
136 <xsl:for-each select="$splitnode">
137 <xsl:for-each select="preceding-sibling::Heading">
138 <xsl:apply-templates/><br/>
139 </xsl:for-each>
140 </xsl:for-each>
141 </xsl:if>
142 <xsl:if test="$current='true'">
143 <xsl:for-each select="$splitnode">
144 <xsl:apply-templates/><br/>
145 </xsl:for-each>
146 </xsl:if>
147 <xsl:if test="$type='following'">
148 <xsl:for-each select="$splitnode">
149 <xsl:for-each select="following-sibling::Heading">
150 <xsl:apply-templates/><br/>
151 </xsl:for-each>
152 </xsl:for-each>
153 </xsl:if>
154 </dd>
155 </xsl:template>
156
157 <xsl:template match="TutorialRef" priority="2">
158 <xsl:variable name="ref" select="@id"/>
159 <b><xsl:value-of select="/TutorialList/Tutorial[@id=$ref]/Title/Text"/></b>
160 </xsl:template>
161
162</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.