1 | <!-- |
---|
2 | XSLT transformation from RFC2629 XML format to Microsoft HTML Help TOC File |
---|
3 | |
---|
4 | Copyright (c) 2003 Julian F. Reschke (julian.reschke@greenbytes.de) |
---|
5 | |
---|
6 | placed into the public domain |
---|
7 | |
---|
8 | change history: |
---|
9 | |
---|
10 | 2003-11-16 julian.reschke@greenbytes.de |
---|
11 | |
---|
12 | Initial release. |
---|
13 | |
---|
14 | 2003-04-04 julian.reschke@greenbytes.de |
---|
15 | |
---|
16 | Add updated handling of references sections. |
---|
17 | --> |
---|
18 | |
---|
19 | <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
---|
20 | xmlns:msxsl="urn:schemas-microsoft-com:xslt" |
---|
21 | xmlns:exslt="http://exslt.org/common" |
---|
22 | xmlns:myns="mailto:julian.reschke@greenbytes.de?subject=rcf2629.xslt" |
---|
23 | version="1.0" |
---|
24 | exclude-result-prefixes="msxsl exslt myns" |
---|
25 | > |
---|
26 | |
---|
27 | <xsl:param name="basename" /> |
---|
28 | |
---|
29 | <xsl:include href="rfc2629.xslt" /> |
---|
30 | |
---|
31 | <xsl:output indent="yes"/> |
---|
32 | |
---|
33 | <xsl:template match="/" priority="9"> |
---|
34 | <html> |
---|
35 | <head> |
---|
36 | <!-- generator --> |
---|
37 | <meta name="generator" content="rfc2629toHhc.xslt $Id: rfc2629toHhc.xslt,v 1.13 2005/01/30 15:46:34 jre Exp $" /> |
---|
38 | </head> |
---|
39 | <body> |
---|
40 | <object type="text/site properties"> |
---|
41 | <param name="ImageType" value="Folder" /> |
---|
42 | <param name="Window Styles" value="0x800025" /> |
---|
43 | </object> |
---|
44 | <ul> |
---|
45 | <li> |
---|
46 | <object type="text/sitemap"> |
---|
47 | <param name="Name" value="{/rfc/front/title}" /> |
---|
48 | <param name="Local" value="{$basename}.html" /> |
---|
49 | </object> |
---|
50 | <ul> |
---|
51 | <xsl:apply-templates mode="hhc" /> |
---|
52 | </ul> |
---|
53 | </li> |
---|
54 | </ul> |
---|
55 | </body> |
---|
56 | </html> |
---|
57 | </xsl:template> |
---|
58 | |
---|
59 | <xsl:template match="node()" mode="hhc"> |
---|
60 | <xsl:apply-templates mode="hhc"/> |
---|
61 | </xsl:template> |
---|
62 | |
---|
63 | <xsl:template match="abstract" mode="hhc"> |
---|
64 | <li> |
---|
65 | <object type="text/sitemap"> |
---|
66 | <param name="Name" value="Abstract" /> |
---|
67 | <param name="Local" value="{$basename}.html#{$anchor-prefix}.abstract" /> |
---|
68 | </object> |
---|
69 | </li> |
---|
70 | <ul> |
---|
71 | <xsl:apply-templates mode="hhc"/> |
---|
72 | </ul> |
---|
73 | </xsl:template> |
---|
74 | |
---|
75 | <xsl:template match="note" mode="hhc"> |
---|
76 | <li> |
---|
77 | <object type="text/sitemap"> |
---|
78 | <param name="Name" value="{@title}" /> |
---|
79 | <xsl:variable name="num"><xsl:number/></xsl:variable> |
---|
80 | <param name="Local" value="{$basename}.html#{$anchor-prefix}.note.{$num}" /> |
---|
81 | </object> |
---|
82 | </li> |
---|
83 | <ul> |
---|
84 | <xsl:apply-templates mode="hhc"/> |
---|
85 | </ul> |
---|
86 | </xsl:template> |
---|
87 | |
---|
88 | <xsl:template match="section[@myns:unnumbered]" mode="hhc"> |
---|
89 | <li> |
---|
90 | <object type="text/sitemap"> |
---|
91 | <param name="Name" value="{@title}" /> |
---|
92 | <param name="Local" value="{$basename}.html#{@anchor}" /> |
---|
93 | </object> |
---|
94 | </li> |
---|
95 | <ul> |
---|
96 | <xsl:apply-templates mode="hhc"/> |
---|
97 | </ul> |
---|
98 | </xsl:template> |
---|
99 | |
---|
100 | <xsl:template match="section[not(@myns:unnumbered)]" mode="hhc"> |
---|
101 | <xsl:variable name="sectionNumber"><xsl:call-template name="get-section-number" /></xsl:variable> |
---|
102 | <li> |
---|
103 | <object type="text/sitemap"> |
---|
104 | <param name="Name" value="{$sectionNumber} {@title}" /> |
---|
105 | <param name="Local" value="{$basename}.html#{$anchor-prefix}.section.{$sectionNumber}" /> |
---|
106 | </object> |
---|
107 | </li> |
---|
108 | <ul> |
---|
109 | <xsl:apply-templates mode="hhc"/> |
---|
110 | </ul> |
---|
111 | </xsl:template> |
---|
112 | |
---|
113 | |
---|
114 | <xsl:template name="references-toc"> |
---|
115 | |
---|
116 | <!-- distinguish two cases: (a) single references element (process |
---|
117 | as toplevel section; (b) multiple references sections (add one toplevel |
---|
118 | container with subsection) --> |
---|
119 | |
---|
120 | <xsl:variable name="number"> |
---|
121 | <xsl:call-template name="get-references-section-number"/> |
---|
122 | </xsl:variable> |
---|
123 | |
---|
124 | <xsl:choose> |
---|
125 | <xsl:when test="count(/*/back/references) = 1"> |
---|
126 | <xsl:for-each select="/*/back/references"> |
---|
127 | <xsl:variable name="title"> |
---|
128 | <xsl:choose> |
---|
129 | <xsl:when test="@title!=''"><xsl:value-of select="@title" /></xsl:when> |
---|
130 | <xsl:otherwise>References</xsl:otherwise> |
---|
131 | </xsl:choose> |
---|
132 | </xsl:variable> |
---|
133 | |
---|
134 | <li> |
---|
135 | <object type="text/sitemap"> |
---|
136 | <param name="Name" value="{$number} {$title}" /> |
---|
137 | <param name="Local" value="{$basename}.html#{$anchor-prefix}.references" /> |
---|
138 | </object> |
---|
139 | </li> |
---|
140 | </xsl:for-each> |
---|
141 | </xsl:when> |
---|
142 | <xsl:otherwise> |
---|
143 | <!-- insert pseudo container --> |
---|
144 | <li> |
---|
145 | <object type="text/sitemap"> |
---|
146 | <param name="Name" value="{$number} References" /> |
---|
147 | <param name="Local" value="{$basename}.html#{$anchor-prefix}.references" /> |
---|
148 | </object> |
---|
149 | <ul> |
---|
150 | <!-- ...with subsections... --> |
---|
151 | <xsl:for-each select="/*/back/references"> |
---|
152 | <xsl:variable name="title"> |
---|
153 | <xsl:choose> |
---|
154 | <xsl:when test="@title!=''"><xsl:value-of select="@title" /></xsl:when> |
---|
155 | <xsl:otherwise>References</xsl:otherwise> |
---|
156 | </xsl:choose> |
---|
157 | </xsl:variable> |
---|
158 | |
---|
159 | <xsl:variable name="sectionNumber"> |
---|
160 | <xsl:call-template name="get-section-number" /> |
---|
161 | </xsl:variable> |
---|
162 | |
---|
163 | <xsl:variable name="num"> |
---|
164 | <xsl:number/> |
---|
165 | </xsl:variable> |
---|
166 | |
---|
167 | <li> |
---|
168 | <object type="text/sitemap"> |
---|
169 | <param name="Name" value="{$sectionNumber} {$title}" /> |
---|
170 | <param name="Local" value="{$basename}.html#{$anchor-prefix}.references.{$num}" /> |
---|
171 | </object> |
---|
172 | </li> |
---|
173 | </xsl:for-each> |
---|
174 | </ul> |
---|
175 | </li> |
---|
176 | </xsl:otherwise> |
---|
177 | </xsl:choose> |
---|
178 | </xsl:template> |
---|
179 | |
---|
180 | <xsl:template match="references" mode="hhc"> |
---|
181 | |
---|
182 | <xsl:variable name="num"> |
---|
183 | <xsl:choose> |
---|
184 | <xsl:when test="not(preceding::references)" /> |
---|
185 | <xsl:otherwise> |
---|
186 | <xsl:text>.</xsl:text><xsl:number/> |
---|
187 | </xsl:otherwise> |
---|
188 | </xsl:choose> |
---|
189 | </xsl:variable> |
---|
190 | |
---|
191 | <xsl:variable name="title"> |
---|
192 | <xsl:choose> |
---|
193 | <xsl:when test="@title"><xsl:value-of select="@title" /></xsl:when> |
---|
194 | <xsl:otherwise>References</xsl:otherwise> |
---|
195 | </xsl:choose> |
---|
196 | </xsl:variable> |
---|
197 | |
---|
198 | <li> |
---|
199 | <object type="text/sitemap"> |
---|
200 | <param name="Name" value="{$title}" /> |
---|
201 | <param name="Local" value="{$basename}.html#{$anchor-prefix}.references{$num}" /> |
---|
202 | </object> |
---|
203 | </li> |
---|
204 | |
---|
205 | </xsl:template> |
---|
206 | |
---|
207 | <xsl:template match="back" mode="hhc"> |
---|
208 | |
---|
209 | <!-- <xsl:apply-templates select="references" mode="hhc" /> --> |
---|
210 | <xsl:apply-templates select="*[not(self::references)]" mode="hhc" /> |
---|
211 | <xsl:apply-templates select="/rfc/front" mode="hhc" /> |
---|
212 | |
---|
213 | <xsl:if test="not($xml2rfc-private)"> |
---|
214 | <!-- copyright statements --> |
---|
215 | <li> |
---|
216 | <object type="text/sitemap"> |
---|
217 | <param name="Name" value="Intellectual Property and Copyright Statements" /> |
---|
218 | <param name="Local" value="{$basename}.html#{$anchor-prefix}.ipr" /> |
---|
219 | </object> |
---|
220 | </li> |
---|
221 | </xsl:if> |
---|
222 | |
---|
223 | <!-- insert the index if index entries exist --> |
---|
224 | <xsl:if test="//iref"> |
---|
225 | <li> |
---|
226 | <object type="text/sitemap"> |
---|
227 | <param name="Name" value="Index" /> |
---|
228 | <param name="Local" value="{$basename}.html#{$anchor-prefix}.index" /> |
---|
229 | </object> |
---|
230 | </li> |
---|
231 | </xsl:if> |
---|
232 | </xsl:template> |
---|
233 | |
---|
234 | <xsl:template match="front" mode="hhc"> |
---|
235 | |
---|
236 | <xsl:variable name="title"> |
---|
237 | <xsl:if test="count(author)=1">Author's Address</xsl:if> |
---|
238 | <xsl:if test="count(author)!=1">Author's Addresses</xsl:if> |
---|
239 | </xsl:variable> |
---|
240 | |
---|
241 | <li> |
---|
242 | <object type="text/sitemap"> |
---|
243 | <param name="Name" value="{$title}" /> |
---|
244 | <param name="Local" value="{$basename}.html#{$anchor-prefix}.authors" /> |
---|
245 | </object> |
---|
246 | </li> |
---|
247 | </xsl:template> |
---|
248 | |
---|
249 | <xsl:template match="rfc" mode="hhc"> |
---|
250 | <xsl:if test="not($xml2rfc-private)"> |
---|
251 | <!-- Get status info formatted as per RFC2629--> |
---|
252 | <xsl:variable name="preamble"><xsl:call-template name="insertPreamble" /></xsl:variable> |
---|
253 | |
---|
254 | <!-- emit it --> |
---|
255 | <xsl:choose> |
---|
256 | <xsl:when test="function-available('msxsl:node-set')"> |
---|
257 | <xsl:apply-templates select="msxsl:node-set($preamble)/node()" mode="hhc"/> |
---|
258 | </xsl:when> |
---|
259 | <xsl:when test="function-available('exslt:node-set')"> |
---|
260 | <xsl:apply-templates select="exslt:node-set($preamble)/node()" mode="hhc"/> |
---|
261 | </xsl:when> |
---|
262 | <xsl:otherwise> |
---|
263 | <xsl:apply-templates select="$preamble/node()" mode="hhc"/> |
---|
264 | </xsl:otherwise> |
---|
265 | </xsl:choose> |
---|
266 | </xsl:if> |
---|
267 | |
---|
268 | <xsl:apply-templates select="front/abstract" mode="hhc"/> |
---|
269 | <xsl:apply-templates select="front/note" mode="hhc"/> |
---|
270 | |
---|
271 | <xsl:if test="$xml2rfc-toc"> |
---|
272 | <bookmark xmlns="http://www.renderx.com/XSL/Extensions" internal-destination="{concat($anchor-prefix,'.toc')}"> |
---|
273 | <bookmark-label>Table of Contents</bookmark-label> |
---|
274 | </bookmark> |
---|
275 | </xsl:if> |
---|
276 | |
---|
277 | <xsl:apply-templates select="middle|back" mode="hhc" /> |
---|
278 | </xsl:template> |
---|
279 | |
---|
280 | |
---|
281 | <xsl:template match="middle" mode="hhc"> |
---|
282 | |
---|
283 | <xsl:apply-templates mode="hhc"/> |
---|
284 | <xsl:call-template name="references-toc"/>> |
---|
285 | </xsl:template> |
---|
286 | |
---|
287 | |
---|
288 | </xsl:transform> |
---|