source: rfc2629xslt/rfc2629toHhc.xslt @ 830

Last change on this file since 830 was 230, checked in by julian.reschke@…, 12 years ago

Update to xml2rfc 1.33 (only affects Makefiles), update to latest version of rfc2629.xslt, change Makefile to allow Saxon to keep line numbers from source files.

  • Property svn:eol-style set to native
File size: 9.7 KB
Line 
1<!--
2    XSLT transformation from RFC2629 XML format to Microsoft HTML Help TOC File
3
4    Copyright (c) 2008, Julian Reschke (julian.reschke@greenbytes.de)
5    All rights reserved.
6
7    Redistribution and use in source and binary forms, with or without
8    modification, are permitted provided that the following conditions are met:
9
10    * Redistributions of source code must retain the above copyright notice,
11      this list of conditions and the following disclaimer.
12    * Redistributions in binary form must reproduce the above copyright notice,
13      this list of conditions and the following disclaimer in the documentation
14      and/or other materials provided with the distribution.
15    * Neither the name of Julian Reschke nor the names of its contributors
16      may be used to endorse or promote products derived from this software
17      without specific prior written permission.
18
19    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22    ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29    POSSIBILITY OF SUCH DAMAGE.
30-->
31
32<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
33                xmlns:exslt="http://exslt.org/common"
34                xmlns:myns="mailto:julian.reschke@greenbytes.de?subject=rcf2629.xslt"
35                version="1.0"
36                exclude-result-prefixes="exslt myns"
37>
38
39<xsl:param name="basename" />
40
41<xsl:include href="rfc2629.xslt" />
42
43<xsl:output indent="yes"/>
44
45<!-- define exslt:node-set for msxml -->       
46<msxsl:script language="JScript" implements-prefix="exslt" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
47  this['node-set'] = function (x) {
48    return x;
49  }
50</msxsl:script>
51
52<xsl:template match="/" priority="9">
53<html>
54  <head>
55    <!-- generator -->
56    <meta name="generator" content="rfc2629toHhc.xslt $Id: rfc2629toHhc.xslt,v 1.14 2008-03-01 14:27:31 jre Exp $" />
57  </head>
58  <body>
59    <object type="text/site properties">
60        <param name="ImageType" value="Folder" />
61        <param name="Window Styles" value="0x800025" />
62    </object>
63    <ul>
64      <li>
65        <object type="text/sitemap">
66          <param name="Name" value="{/rfc/front/title}" />
67          <param name="Local" value="{$basename}.html" />
68        </object>
69        <ul>
70          <xsl:apply-templates mode="hhc" />
71        </ul>
72      </li>
73    </ul>
74  </body>
75</html>
76</xsl:template>
77
78<xsl:template match="node()" mode="hhc">
79  <xsl:apply-templates mode="hhc"/>
80</xsl:template>
81
82<xsl:template match="abstract" mode="hhc">
83  <li>
84    <object type="text/sitemap">
85      <param name="Name" value="Abstract" />
86      <param name="Local" value="{$basename}.html#{$anchor-prefix}.abstract" />
87    </object>
88  </li>
89  <ul>
90    <xsl:apply-templates mode="hhc"/>
91  </ul>
92</xsl:template>
93
94<xsl:template match="note" mode="hhc">
95  <li>
96    <object type="text/sitemap">
97      <param name="Name" value="{@title}" />
98      <xsl:variable name="num"><xsl:number/></xsl:variable>
99      <param name="Local" value="{$basename}.html#{$anchor-prefix}.note.{$num}" />
100    </object>
101  </li>
102  <ul>
103    <xsl:apply-templates mode="hhc"/>
104  </ul>
105</xsl:template>
106
107<xsl:template match="section[@myns:unnumbered]" mode="hhc">
108  <li>
109    <object type="text/sitemap">
110      <param name="Name" value="{@title}" />
111      <param name="Local" value="{$basename}.html#{@anchor}" />
112    </object>
113  </li>
114  <ul>
115    <xsl:apply-templates mode="hhc"/>
116  </ul>
117</xsl:template>
118
119<xsl:template match="section[not(@myns:unnumbered)]" mode="hhc">
120  <xsl:variable name="sectionNumber"><xsl:call-template name="get-section-number" /></xsl:variable>
121  <li>
122    <object type="text/sitemap">
123      <param name="Name" value="{$sectionNumber} {@title}" />
124      <param name="Local" value="{$basename}.html#{$anchor-prefix}.section.{$sectionNumber}" />
125    </object>
126  </li>
127  <ul>
128    <xsl:apply-templates mode="hhc"/>
129  </ul>
130</xsl:template>
131
132
133<xsl:template name="references-toc-hhc">
134
135  <!-- distinguish two cases: (a) single references element (process
136  as toplevel section; (b) multiple references sections (add one toplevel
137  container with subsection) -->
138
139  <xsl:variable name="number">
140    <xsl:call-template name="get-references-section-number"/>
141  </xsl:variable>
142
143  <xsl:choose>
144    <xsl:when test="count(/*/back/references) = 1">
145      <xsl:for-each select="/*/back/references">
146        <xsl:variable name="title">
147          <xsl:choose>
148            <xsl:when test="@title!=''"><xsl:value-of select="@title" /></xsl:when>
149            <xsl:otherwise>References</xsl:otherwise>
150          </xsl:choose>
151        </xsl:variable>
152     
153        <li>
154          <object type="text/sitemap">
155            <param name="Name" value="{$number} {$title}" />
156            <param name="Local" value="{$basename}.html#{$anchor-prefix}.references" />
157          </object>
158        </li>
159      </xsl:for-each>
160    </xsl:when>
161    <xsl:otherwise>
162      <!-- insert pseudo container -->   
163      <li>
164        <object type="text/sitemap">
165          <param name="Name" value="{$number} References" />
166          <param name="Local" value="{$basename}.html#{$anchor-prefix}.references" />
167        </object>
168        <ul>
169          <!-- ...with subsections... -->   
170          <xsl:for-each select="/*/back/references">
171            <xsl:variable name="title">
172              <xsl:choose>
173                <xsl:when test="@title!=''"><xsl:value-of select="@title" /></xsl:when>
174                <xsl:otherwise>References</xsl:otherwise>
175              </xsl:choose>
176            </xsl:variable>
177         
178            <xsl:variable name="sectionNumber">
179              <xsl:call-template name="get-section-number" />
180            </xsl:variable>
181   
182            <xsl:variable name="num">
183              <xsl:number/>
184            </xsl:variable>
185   
186            <li>
187              <object type="text/sitemap">
188                <param name="Name" value="{$sectionNumber} {$title}" />
189                <param name="Local" value="{$basename}.html#{$anchor-prefix}.references.{$num}" />
190              </object>
191            </li>
192          </xsl:for-each>
193        </ul>
194      </li>
195    </xsl:otherwise>
196  </xsl:choose>
197</xsl:template>
198
199<xsl:template match="references" mode="hhc">
200
201  <xsl:variable name="num">
202    <xsl:choose>
203      <xsl:when test="not(preceding::references)" />
204      <xsl:otherwise>
205        <xsl:text>.</xsl:text><xsl:number/>     
206      </xsl:otherwise>
207    </xsl:choose>
208  </xsl:variable>
209
210  <xsl:variable name="title">
211    <xsl:choose>
212      <xsl:when test="@title"><xsl:value-of select="@title" /></xsl:when>
213      <xsl:otherwise>References</xsl:otherwise>
214    </xsl:choose>
215  </xsl:variable>
216
217  <li>
218    <object type="text/sitemap">
219      <param name="Name" value="{$title}" />
220      <param name="Local" value="{$basename}.html#{$anchor-prefix}.references{$num}" />
221    </object>
222  </li>
223
224</xsl:template>
225
226<xsl:template match="back" mode="hhc">
227
228  <!-- <xsl:apply-templates select="references" mode="hhc" /> -->
229  <xsl:apply-templates select="*[not(self::references)]" mode="hhc" />
230  <xsl:apply-templates select="/rfc/front" mode="hhc" />
231
232  <xsl:if test="not($xml2rfc-private)">
233    <!-- copyright statements -->
234    <li>
235      <object type="text/sitemap">
236        <param name="Name" value="Intellectual Property and Copyright Statements" />
237        <param name="Local" value="{$basename}.html#{$anchor-prefix}.ipr" />
238      </object>
239    </li>
240  </xsl:if>
241
242  <!-- insert the index if index entries exist -->
243  <xsl:if test="//iref">
244    <li>
245      <object type="text/sitemap">
246        <param name="Name" value="Index" />
247        <param name="Local" value="{$basename}.html#{$anchor-prefix}.index" />
248      </object>
249    </li>
250  </xsl:if>
251</xsl:template>
252
253<xsl:template match="front" mode="hhc">
254
255  <xsl:variable name="title">
256    <xsl:if test="count(author)=1">Author's Address</xsl:if>
257    <xsl:if test="count(author)!=1">Author's Addresses</xsl:if>
258  </xsl:variable>
259
260  <li>
261    <object type="text/sitemap">
262      <param name="Name" value="{$title}" />
263      <param name="Local" value="{$basename}.html#{$anchor-prefix}.authors" />
264    </object>
265  </li>
266</xsl:template>
267
268<xsl:template match="rfc" mode="hhc">
269  <xsl:if test="not($xml2rfc-private)">
270    <!-- Get status info formatted as per RFC2629-->
271    <xsl:variable name="preamble"><xsl:call-template name="insertPreamble" /></xsl:variable>
272
273    <!-- emit it -->
274    <xsl:choose>
275      <xsl:when test="function-available('exslt:node-set')">
276        <xsl:apply-templates select="exslt:node-set($preamble)/node()" mode="hhc"/>
277      </xsl:when>
278      <xsl:otherwise>
279        <xsl:apply-templates select="$preamble/node()" mode="hhc"/>
280      </xsl:otherwise>
281    </xsl:choose>
282  </xsl:if>
283 
284  <xsl:apply-templates select="front/abstract" mode="hhc"/>
285  <xsl:apply-templates select="front/note" mode="hhc"/>
286
287  <xsl:if test="$xml2rfc-toc">
288    <bookmark xmlns="http://www.renderx.com/XSL/Extensions" internal-destination="{concat($anchor-prefix,'.toc')}">
289      <bookmark-label>Table of Contents</bookmark-label>
290    </bookmark>
291  </xsl:if>
292
293  <xsl:apply-templates select="middle|back" mode="hhc" />
294</xsl:template>
295
296
297<xsl:template match="middle" mode="hhc">
298
299  <xsl:apply-templates mode="hhc"/>
300  <xsl:call-template name="references-toc-hhc"/>
301</xsl:template>
302
303   
304</xsl:transform>
Note: See TracBrowser for help on using the repository browser.