1<?xml version="1.0"?>
2
3<!-- Version: $Id$ -->
4
5<!-- Stylesheet for XMLspec -->
6<!-- Author: Norman Walsh (Norman.Walsh@East.Sun.COM) -->
7<!-- Author: Chris Maden (crism@lexica.net) -->
8<!-- Author: Ben Trafford (ben@legendary.org) -->
9<!-- Author: Eve Maler (eve.maler@east.sun.com) -->
10<!-- Date Created: 1999.09.07 -->
11
12<!-- This stylesheet is copyright (c) 2000 by its authors.  Free
13     distribution and modification is permitted, including adding to
14     the list of authors and copyright holders, as long as this
15     copyright notice is maintained. -->
16
17<!-- This stylesheet attempts to implement the XML Specification V2.1
18     DTD.  Documents conforming to earlier DTDs may not be correctly
19     transformed. -->
20
21<!-- ChangeLog:
22
23     25 Sep 2000: (Norman.Walsh@East.Sun.COM)
24       - Sync'd with Eve's version:
25         o Concatenated each inline element's output all on one line
26           to avoid spurious spaces in the output. (This is really an
27           IE bug, but...) (15 Sep 2000)
28         o Updated crism's email address in header (7 Sep 2000)
29         o Changed handling of affiliation to use comma instead of
30           parentheses (9 Aug 2000)
31
32     14 Aug 2000: (Norman.Walsh@East.Sun.COM)
33
34       - Added additional.title param (for diffspec.xsl to change)
35       - Fixed URI of W3C home icon
36       - Made CSS stylesheet selection depend on the w3c-doctype attribute
37         of spec instead of the w3c-doctype element in the header
38
39     26 Jul 2000: (Norman.Walsh@East.Sun.COM)
40
41       - Improved semantics of specref. Added xsl:message for unsupported
42         cases. (I'm by no means confident that I've covered the whole
43         list.)
44       - Support @role on author.
45       - Make lhs/rhs "code" in EBNF.
46       - Fixed bug in ID/IDREF linking.
47       - More effectively disabled special markup for showing @diffed
48         versions
49
50     21 Jul 2000: (Norman.Walsh@East.Sun.COM)
51
52       - Added support for @diff change tracking, primarily through
53         the auxiliary stylesheet diffspec.xsl. However, it was
54         impractical to handle some constructions, such as DLs and TABLEs,
55         in a completely out-of-band manner. So there is some inline
56         support for @diff markup.
57
58       - Added $additional.css to allow downstream stylesheets to add
59         new markup to the <style> element.
60
61       - Added required "type" attribute to the <style> element.
62
63       - Fixed pervasive problem with nested <a> elements.
64
65       - Added doctype-public to xsl:output.
66
67       - Added $validity.hacks. If "1", then additional disable-output-escaping
68         markup may be inserted in some places to attempt to get proper,
69         valid HTML. For example, if a <glist> appears inside a <p> in the
70         xmlspec source, this creates a nested <dl> inside a <p> in the
71         HTML, which is not valid. If $validity.hacks is "1", then an
72         extra </p>, <p> pair is inserted around the <dl>.
73-->
74
75<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
76               xmlns:saxon="http://icl.com/saxon"
77               exclude-result-prefixes="saxon"
78               version="1.0">
79
80  <xsl:param name="validity.hacks">1</xsl:param>
81  <xsl:param name="show.diff.markup">0</xsl:param>
82  <xsl:param name="additional.css"></xsl:param>
83  <xsl:param name="additional.title"></xsl:param>
84  <xsl:param name="called.by.diffspec">0</xsl:param>
85  <xsl:param name="show.ednotes">1</xsl:param>
86
87  <xsl:output method="html"
88       encoding="ISO-8859-1"
89       doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
90       indent="no"/>
91
92  <xsl:strip-space elements="author"/>
93
94  <!-- not handled:
95    attribute:   unhandled IDL stuff
96    case:        unhandled IDL stuff
97    component:   unhandled IDL stuff
98    constant:    unhandled IDL stuff
99    copyright:   boilerplate notice always used instead
100    definitions: unhandled IDL stuff
101    descr:       unhandled IDL stuff
102    enum:        unhandled IDL stuff
103    enumerator:  unhandled IDL stuff
104    exception:   unhandled IDL stuff
105    group:       unhandled IDL stuff
106    interface:   unhandled IDL stuff
107    method:      unhandled IDL stuff
108    module:      unhandled IDL stuff
109    param:       unhandled IDL stuff
110    parameters:  unhandled IDL stuff
111    raises:      unhandled IDL stuff
112    reference:   unhandled IDL stuff
113    returns:     unhandled IDL stuff
114    sequence:    unhandled IDL stuff
115    struct:      unhandled IDL stuff
116    typedef:     unhandled IDL stuff
117    typename:    unhandled IDL stuff
118    union:       unhandled IDL stuff
119
120    Warning!
121    Only handles statuses of NOTE, WD, and REC.
122    -->
123
124  <!-- Template for the root node.  Creation of <html> element could
125       go here, but that doesn't feel right. -->
126  <xsl:template match="/">
127    <xsl:apply-templates/>
128  </xsl:template>
129
130  <!-- abstract: appears only in header -->
131  <!-- format as a second-level div -->
132  <!-- called in enforced order from header's template -->
133  <xsl:template match="abstract">
134    <div id="abstract">
135      <xsl:text>&#10;</xsl:text>
136      <h2>
137        <a name="abstract">Abstract</a>
138      </h2>
139      <xsl:apply-templates/>
140    </div>
141  </xsl:template>
142
143  <!-- affiliation: follows a name in author and member -->
144  <!-- put it in parens with a leading space -->
145  <xsl:template match="affiliation">
146    <xsl:text>, </xsl:text>
147    <xsl:apply-templates/>
148  </xsl:template>
149
150  <!-- arg: appears only in proto -->
151  <!-- argument in function prototype -->
152  <!-- output argument type, italicized as placeholder; separate the
153       list with commas and spaces -->
154  <xsl:template match="arg">
155    <xsl:if test="preceding-sibling::arg">
156      <xsl:text>, </xsl:text>
157    </xsl:if>
158    <var>
159      <xsl:value-of select="@type"/>
160    </var>
161    <xsl:if test="@occur = 'opt'">
162      <xsl:text>?</xsl:text>
163    </xsl:if>
164  </xsl:template>
165
166  <!-- att: attribute name -->
167  <!-- used lots of places -->
168  <!-- format as monospaced code -->
169  <xsl:template match="att">
170    <code><xsl:apply-templates/></code>
171  </xsl:template>
172
173  <!-- attribute: -->
174  <!-- IDL stuff isn't handled yet -->
175
176  <!-- attval: attribute name -->
177  <!-- used lots of places -->
178  <!-- format as quoted string -->
179  <xsl:template match="attval">
180    <xsl:text>"</xsl:text>
181    <xsl:apply-templates/>
182    <xsl:text>"</xsl:text>
183  </xsl:template>
184
185  <!-- authlist: list of authors (editors, really) -->
186  <!-- called in enforced order from header's template, in <dl>
187       context -->
188  <xsl:template match="authlist">
189    <dt>
190      <xsl:text>Editor</xsl:text>
191      <xsl:if test="count(author) > 1">
192        <xsl:text>s</xsl:text>
193      </xsl:if>
194      <xsl:text>:</xsl:text>
195    </dt>
196    <xsl:apply-templates/>
197  </xsl:template>
198
199  <!-- author: an editor of a spec -->
200  <!-- only appears in authlist -->
201  <!-- called in <dl> context -->
202  <xsl:template match="author">
203    <dd>
204      <xsl:apply-templates/>
205      <xsl:if test="@role = '2e'">
206	<xsl:text> - Second Edition</xsl:text>
207      </xsl:if>
208    </dd>
209  </xsl:template>
210
211  <!-- back: back matter for the spec -->
212  <!-- make a <div> for neatness -->
213  <!-- affects numbering of div1 children -->
214  <xsl:template match="back">
215    <div class="back">
216      <xsl:apply-templates/>
217    </div>
218  </xsl:template>
219
220  <!-- bibl: bibliographic entry -->
221  <!-- only appears in blist -->
222  <!-- called with <dl> context -->
223  <!-- if there's a key, use it in the <dt>, otherwise use the ID -->
224  <!-- if there's an href, add a ref in parens at the end of the text -->
225  <xsl:template match="bibl">
226    <dt class="label">
227      <xsl:if test="@id">
228	<a name="{@id}"/>
229      </xsl:if>
230      <xsl:choose>
231	<xsl:when test="@key">
232	  <xsl:value-of select="@key"/>
233	</xsl:when>
234	<xsl:otherwise>
235	  <xsl:value-of select="@id"/>
236	</xsl:otherwise>
237      </xsl:choose>
238    </dt>
239    <dd>
240      <xsl:apply-templates/>
241      <xsl:if test="@href">
242        <xsl:text>  (See </xsl:text>
243        <a href="{@href}">
244          <xsl:value-of select="@href"/>
245        </a>
246        <xsl:text>.)</xsl:text>
247      </xsl:if>
248    </dd>
249  </xsl:template>
250
251  <!-- bibref: reference to a bibliographic entry -->
252  <!-- make a link to the bibl -->
253  <!-- if the bibl has a key, put it in square brackets; otherwise use
254       the bibl's ID -->
255  <xsl:template match="bibref">
256    <a>
257      <xsl:attribute name="href">
258        <xsl:call-template name="href.target">
259          <xsl:with-param name="target" select="id(@ref)"/>
260        </xsl:call-template>
261      </xsl:attribute>
262      <xsl:text>[</xsl:text>
263      <xsl:choose>
264        <xsl:when test="id(@ref)/@key">
265          <xsl:value-of select="id(@ref)/@key"/>
266        </xsl:when>
267        <xsl:otherwise>
268          <xsl:value-of select="@ref"/>
269        </xsl:otherwise>
270      </xsl:choose>
271      <xsl:text>]</xsl:text>
272    </a>
273  </xsl:template>
274
275  <!-- blist: list of bibliographic entries -->
276  <!-- set up the list and process children -->
277  <xsl:template match="blist">
278    <dl>
279      <xsl:apply-templates/>
280    </dl>
281  </xsl:template>
282
283  <!-- bnf: un-marked-up BNF productions -->
284  <!-- preformatted within a table cell -->
285  <!-- scrap provides <table> context -->
286  <xsl:template match="bnf">
287    <tbody>
288      <tr>
289        <td>
290	  <xsl:if test="@diff and $show.diff.markup='1'">
291	    <xsl:attribute name="class">
292	      <xsl:text>diff-</xsl:text>
293	      <xsl:value-of select="@diff"/>
294	    </xsl:attribute>
295	  </xsl:if>
296          <pre>
297            <xsl:apply-templates/>
298          </pre>
299        </td>
300      </tr>
301    </tbody>
302  </xsl:template>
303
304  <!-- body: the meat of the spec -->
305  <!-- create a TOC and then go to work -->
306  <!-- (don't forget the TOC for the back matter and a pointer to end
307       notes) -->
308  <xsl:template match="body">
309    <div class="toc">
310      <xsl:text>&#10;</xsl:text>
311      <h2>
312        <a name="contents">Table of Contents</a>
313      </h2>
314      <p class="toc">
315        <xsl:apply-templates mode="toc" select="div1"/>
316      </p>
317      <xsl:if test="/back">
318        <xsl:text>&#10;</xsl:text>
319        <h3>
320          <xsl:text>Appendi</xsl:text>
321          <xsl:choose>
322            <xsl:when test="count(/back/div1 | /back/inform-div1) > 1">
323              <xsl:text>ces</xsl:text>
324            </xsl:when>
325            <xsl:otherwise>
326              <xsl:text>x</xsl:text>
327            </xsl:otherwise>
328          </xsl:choose>
329        </h3>
330        <p class="toc">
331          <xsl:apply-templates mode="toc"
332            select="/back/div1 | /back/inform-div1"/>
333        </p>
334      </xsl:if>
335      <xsl:if test="//footnote">
336        <p class="toc">
337          <a href="#endnotes">
338            <xsl:text>End Notes</xsl:text>
339          </a>
340        </p>
341      </xsl:if>
342    </div>
343    <hr/>
344    <div class="body">
345      <xsl:apply-templates/>
346    </div>
347  </xsl:template>
348
349  <!-- caption: see table -->
350
351  <!-- case: -->
352  <!-- IDL stuff isn't handled yet -->
353
354  <!-- code: generic computer code -->
355  <!-- output as HTML <code> for monospaced formatting -->
356  <xsl:template match="code">
357    <code><xsl:apply-templates/></code>
358  </xsl:template>
359
360  <!-- col: see table -->
361
362  <!-- colgroup: see table -->
363
364  <!-- com: formal production comment -->
365  <!-- can appear in prod or rhs -->
366  <xsl:template match="com">
367    <xsl:choose>
368      <xsl:when test="preceding-sibling::*[1][name()='rhs']">
369        <td>
370	  <xsl:if test="ancestor-or-self::*/@diff and $show.diff.markup='1'">
371	    <xsl:attribute name="class">
372	      <xsl:text>diff-</xsl:text>
373	      <xsl:value-of select="ancestor-or-self::*/@diff"/>
374	    </xsl:attribute>
375	  </xsl:if>
376          <i>
377            <xsl:text>/* </xsl:text>
378            <xsl:apply-templates/>
379            <xsl:text> */</xsl:text>
380          </i>
381        </td>
382      </xsl:when>
383      <xsl:otherwise>
384        <tr valign="baseline">
385          <td/><td/><td/><td/>
386          <td>
387	    <xsl:if test="ancestor-or-self::*/@diff and $show.diff.markup='1'">
388	      <xsl:attribute name="class">
389		<xsl:text>diff-</xsl:text>
390		<xsl:value-of select="ancestor-or-self::*/@diff"/>
391	      </xsl:attribute>
392	    </xsl:if>
393            <i>
394              <xsl:text>/* </xsl:text>
395              <xsl:apply-templates/>
396              <xsl:text> */</xsl:text>
397            </i>
398          </td>
399        </tr>
400      </xsl:otherwise>
401    </xsl:choose>
402  </xsl:template>
403
404  <!-- this could probably be handled better, but given that rhs can
405       have arbitrary text and com mixed in, I don't feel like
406       spending enough time to figure out how -->
407  <xsl:template match="rhs/com">
408    <i>
409      <xsl:text>/* </xsl:text>
410      <xsl:apply-templates/>
411      <xsl:text> */</xsl:text>
412    </i>
413  </xsl:template>
414
415  <!-- component: -->
416  <!-- IDL stuff isn't handled yet -->
417
418  <!-- constant: -->
419  <!-- IDL stuff isn't handled yet -->
420
421  <!-- constraint: a note in a formal production -->
422  <!-- refers to a constraint note -->
423  <xsl:template match="constraint">
424    <xsl:choose>
425      <xsl:when test="preceding-sibling::*[1][name()='rhs']">
426        <td>
427	  <xsl:if test="@diff and $show.diff.markup='1'">
428	    <xsl:attribute name="class">
429	      <xsl:text>diff-</xsl:text>
430	      <xsl:value-of select="@diff"/>
431	    </xsl:attribute>
432	  </xsl:if>
433          <a>
434            <xsl:attribute name="href">
435              <xsl:call-template name="href.target">
436                <xsl:with-param name="target" select="id(@def)"/>
437              </xsl:call-template>
438            </xsl:attribute>
439            <xsl:text>[Constraint: </xsl:text>
440            <xsl:apply-templates select="id(@def)/head" mode="text"/>
441            <xsl:text>]</xsl:text>
442          </a>
443        </td>
444      </xsl:when>
445      <xsl:otherwise>
446        <tr valign="baseline">
447          <td/><td/><td/><td/>
448          <td>
449	    <xsl:if test="@diff and $show.diff.markup='1'">
450	      <xsl:attribute name="class">
451		<xsl:text>diff-</xsl:text>
452		<xsl:value-of select="@diff"/>
453	      </xsl:attribute>
454	    </xsl:if>
455            <a>
456              <xsl:attribute name="href">
457                <xsl:call-template name="href.target">
458                  <xsl:with-param name="target" select="id(@def)"/>
459                </xsl:call-template>
460              </xsl:attribute>
461              <xsl:text>[Constraint: </xsl:text>
462              <xsl:apply-templates select="id(@def)/head" mode="text"/>
463              <xsl:text>]</xsl:text>
464            </a>
465          </td>
466        </tr>
467      </xsl:otherwise>
468    </xsl:choose>
469  </xsl:template>
470
471  <!-- constraintnote: note constraining a formal production -->
472  <!-- see also constraintnote/head -->
473  <xsl:template match="constraintnote">
474    <div class="constraint">
475      <xsl:apply-templates/>
476    </div>
477  </xsl:template>
478
479  <!-- copyright: notice for this document-->
480  <!-- right now, a boilerplate copyright notice is inserted by the
481       template for header; this may need to be changed -->
482
483  <!-- day: day of month of spec -->
484  <!-- only used in pudate; called directly from header template -->
485
486  <!-- def: glossary definition -->
487  <!-- already in <dl> context from glist -->
488  <xsl:template match="def">
489    <dd>
490      <xsl:apply-templates/>
491    </dd>
492  </xsl:template>
493
494  <!-- definitions: -->
495  <!-- IDL stuff isn't handled yet -->
496
497  <!-- descr: -->
498  <!-- IDL stuff isn't handled yet -->
499
500  <!-- div[n]: structural divisions -->
501  <!-- make an HTML div -->
502  <!-- see also div[n]/head -->
503  <xsl:template match="div1">
504    <div class="div1">
505      <xsl:apply-templates/>
506    </div>
507  </xsl:template>
508
509  <xsl:template match="div2">
510    <div class="div2">
511      <xsl:apply-templates/>
512    </div>
513  </xsl:template>
514
515  <xsl:template match="div3">
516    <div class="div3">
517      <xsl:apply-templates/>
518    </div>
519  </xsl:template>
520
521  <xsl:template match="div4">
522    <div class="div4">
523      <xsl:apply-templates/>
524    </div>
525  </xsl:template>
526
527  <xsl:template match="div5">
528    <div class="div5">
529      <xsl:apply-templates/>
530    </div>
531  </xsl:template>
532
533  <!-- ednote: editors' note -->
534  <xsl:template match="ednote">
535    <xsl:if test="$show.ednotes != 0">
536      <table border="1">
537        <xsl:attribute name="summary">
538          <xsl:text>Editorial note</xsl:text>
539          <xsl:if test="name">
540            <xsl:text>: </xsl:text>
541            <xsl:value-of select="name"/>
542          </xsl:if>
543        </xsl:attribute>
544        <tr>
545          <td align="left" valign="top" width="50%">
546            <b>
547              <xsl:text>Editorial note</xsl:text>
548              <xsl:if test="name">
549                <xsl:text>: </xsl:text>
550                <xsl:apply-templates select="name"/>
551              </xsl:if>
552            </b>
553          </td>
554          <td align="right" valign="top" width="50%">
555            <xsl:choose>
556              <xsl:when test="date">
557                <xsl:apply-templates select="date"/>
558              </xsl:when>
559              <xsl:otherwise>&#160;</xsl:otherwise>
560            </xsl:choose>
561          </td>
562        </tr>
563        <tr>
564          <td colspan="2" align="left" valign="top">
565            <xsl:apply-templates select="edtext"/>
566          </td>
567        </tr>
568      </table>
569    </xsl:if>
570  </xsl:template>
571
572  <xsl:template match="date">
573    <xsl:apply-templates/>
574  </xsl:template>
575
576  <!-- edtext: text of an editors' note -->
577  <!-- ednote is currently hidden -->
578
579  <!-- eg: a literal example -->
580  <!-- present as preformatted text -->
581  <xsl:template match="eg">
582    <table class="eg" cellpadding="5" border="1"
583           bgcolor="#99ffff" width="100%"
584           summary="Example">
585      <tr>
586        <td>
587	  <xsl:if test="@diff and $show.diff.markup='1'">
588	    <xsl:attribute name="class">
589	      <xsl:text>diff-</xsl:text>
590	      <xsl:value-of select="@diff"/>
591	    </xsl:attribute>
592	  </xsl:if>
593          <pre>
594            <xsl:apply-templates/>
595          </pre>
596        </td>
597      </tr>
598    </table>
599  </xsl:template>
600
601  <!-- el: an XML element -->
602  <!-- present as preformatted text, no markup -->
603  <!-- Chris's personal preference is to put pointy-brackets around
604       this, but he seems to be in the minority -->
605  <xsl:template match="el">
606    <code><xsl:apply-templates/></code>
607  </xsl:template>
608
609  <!-- email: an email address for an editor -->
610  <!-- only occurs in author -->
611  <xsl:template match="email">
612    <xsl:text> </xsl:text>
613    <a href="{@href}">
614      <xsl:text>&lt;</xsl:text>
615      <xsl:apply-templates/>
616      <xsl:text>&gt;</xsl:text>
617    </a>
618  </xsl:template>
619
620  <!-- emph: in-line emphasis -->
621  <!-- equates to HTML <em> -->
622  <!-- the role attribute could be used for multiple kinds of
623       emphasis, but that would not be kind -->
624  <xsl:template match="emph">
625    <em><xsl:apply-templates/></em>
626  </xsl:template>
627
628  <!-- enum: -->
629  <!-- IDL stuff isn't handled yet -->
630
631  <!-- enumerator: -->
632  <!-- IDL stuff isn't handled yet -->
633
634  <!-- example: what it seems -->
635  <!-- block-level with title -->
636  <!-- see also example/head -->
637  <xsl:template match="example">
638    <div class="example">
639      <xsl:apply-templates/>
640    </div>
641  </xsl:template>
642
643  <!-- exception: -->
644  <!-- IDL stuff isn't handled yet -->
645
646  <!-- footnote: format as endnote, actually -->
647  <xsl:template match="footnote">
648    <xsl:variable name="this-note-id">
649      <xsl:choose>
650        <xsl:when test="@id">
651          <xsl:value-of select="@id"/>
652        </xsl:when>
653        <xsl:otherwise>
654          <xsl:value-of select="generate-id(.)"/>
655        </xsl:otherwise>
656      </xsl:choose>
657    </xsl:variable>
658    <a name="FN-ANCH-{$this-note-id}" href="#{$this-note-id}">
659      <xsl:number level="any" format="[1]"/>
660    </a>
661  </xsl:template>
662
663  <!-- front: front matter for the spec -->
664  <!-- make a div for cleanliness -->
665  <xsl:template match="front">
666    <div class="front">
667      <xsl:apply-templates/>
668    </div>
669  </xsl:template>
670
671  <!-- function: name of a function -->
672  <!-- format as HTML <code> for monospaced presentation -->
673  <xsl:template match="function">
674    <code><xsl:apply-templates/></code>
675  </xsl:template>
676
677  <!-- gitem: glossary list entry -->
678  <!-- just pass children through for <dd>/<dt> formatting -->
679  <xsl:template match="gitem">
680    <xsl:apply-templates/>
681  </xsl:template>
682
683  <!-- glist: glossary list -->
684  <!-- create <dl> and handle children -->
685  <xsl:template match="glist">
686    <xsl:if test="$validity.hacks and local-name(..) = 'p'">
687      <xsl:text disable-output-escaping="yes">&lt;/p&gt;</xsl:text>
688    </xsl:if>
689    <dl>
690      <xsl:apply-templates/>
691    </dl>
692    <xsl:if test="$validity.hacks and local-name(..) = 'p'">
693      <xsl:text disable-output-escaping="yes">&lt;p&gt;</xsl:text>
694    </xsl:if>
695  </xsl:template>
696
697  <!-- graphic: external illustration -->
698  <!-- reference external graphic file with alt text -->
699  <xsl:template match="graphic">
700    <img src="{@source}">
701      <xsl:if test="@alt">
702        <xsl:attribute name="alt">
703          <xsl:value-of select="@alt"/>
704        </xsl:attribute>
705      </xsl:if>
706    </img>
707  </xsl:template>
708
709  <!-- group: -->
710  <!-- IDL stuff isn't handled yet -->
711
712  <!-- head: title for a variety of constructs -->
713
714  <!-- constraintnotes have different types, but they're
715       non-enumerated; nothing is done with them right now -->
716  <xsl:template match="constraintnote/head">
717    <p class="prefix">
718      <xsl:if test="../@id">
719	<a name="{../@id}"/>
720      </xsl:if>
721      <b><xsl:text>Constraint: </xsl:text><xsl:apply-templates/></b>
722    </p>
723  </xsl:template>
724
725  <xsl:template match="div1/head">
726    <xsl:text>&#10;</xsl:text>
727    <h2>
728      <a>
729        <xsl:attribute name="name">
730          <xsl:choose>
731            <xsl:when test="../@id">
732              <xsl:value-of select="../@id"/>
733            </xsl:when>
734            <xsl:otherwise>
735              <xsl:value-of select="generate-id(..)"/>
736            </xsl:otherwise>
737          </xsl:choose>
738        </xsl:attribute>
739      </a>
740      <xsl:apply-templates select=".." mode="divnum"/>
741      <xsl:apply-templates/>
742    </h2>
743  </xsl:template>
744
745  <xsl:template match="div2/head">
746    <xsl:text>&#10;</xsl:text>
747    <h3>
748      <a>
749        <xsl:attribute name="name">
750          <xsl:choose>
751            <xsl:when test="../@id">
752              <xsl:value-of select="../@id"/>
753            </xsl:when>
754            <xsl:otherwise>
755              <xsl:value-of select="generate-id(..)"/>
756            </xsl:otherwise>
757          </xsl:choose>
758        </xsl:attribute>
759      </a>
760      <xsl:apply-templates select=".." mode="divnum"/>
761      <xsl:apply-templates/>
762    </h3>
763  </xsl:template>
764
765  <xsl:template match="div3/head">
766    <xsl:text>&#10;</xsl:text>
767    <h4>
768      <a>
769	<xsl:attribute name="name">
770          <xsl:choose>
771            <xsl:when test="../@id">
772              <xsl:value-of select="../@id"/>
773            </xsl:when>
774            <xsl:otherwise>
775              <xsl:value-of select="generate-id(..)"/>
776            </xsl:otherwise>
777          </xsl:choose>
778        </xsl:attribute>
779      </a>
780      <xsl:apply-templates select=".." mode="divnum"/>
781      <xsl:apply-templates/>
782    </h4>
783  </xsl:template>
784
785  <xsl:template match="div4/head">
786    <xsl:text>&#10;</xsl:text>
787    <h5>
788      <a>
789        <xsl:attribute name="name">
790          <xsl:choose>
791            <xsl:when test="../@id">
792              <xsl:value-of select="../@id"/>
793            </xsl:when>
794            <xsl:otherwise>
795              <xsl:value-of select="generate-id(..)"/>
796            </xsl:otherwise>
797          </xsl:choose>
798        </xsl:attribute>
799      </a>
800      <xsl:apply-templates select=".." mode="divnum"/>
801      <xsl:apply-templates/>
802    </h5>
803  </xsl:template>
804
805  <xsl:template match="div5/head">
806    <xsl:text>&#10;</xsl:text>
807    <h6>
808      <a>
809        <xsl:attribute name="name">
810          <xsl:choose>
811            <xsl:when test="../@id">
812              <xsl:value-of select="../@id"/>
813            </xsl:when>
814            <xsl:otherwise>
815              <xsl:value-of select="generate-id(..)"/>
816            </xsl:otherwise>
817          </xsl:choose>
818        </xsl:attribute>
819      </a>
820      <xsl:apply-templates select=".." mode="divnum"/>
821      <xsl:apply-templates/>
822    </h6>
823  </xsl:template>
824
825  <xsl:template match="example/head">
826    <xsl:text>&#10;</xsl:text>
827    <h5>
828      <xsl:text>Example: </xsl:text>
829      <xsl:apply-templates/>
830    </h5>
831  </xsl:template>
832
833  <xsl:template match="inform-div1/head">
834    <xsl:text>&#10;</xsl:text>
835    <h2>
836      <a>
837        <xsl:attribute name="name">
838          <xsl:choose>
839            <xsl:when test="../@id">
840              <xsl:value-of select="../@id"/>
841            </xsl:when>
842            <xsl:otherwise>
843              <xsl:value-of select="generate-id(..)"/>
844            </xsl:otherwise>
845          </xsl:choose>
846        </xsl:attribute>
847      </a>
848      <xsl:apply-templates select=".." mode="divnum"/>
849      <xsl:apply-templates/>
850      <xsl:text> (Non-Normative)</xsl:text>
851    </h2>
852  </xsl:template>
853
854  <xsl:template match="issue/head">
855    <p class="prefix">
856      <b><xsl:apply-templates/></b>
857    </p>
858  </xsl:template>
859
860  <xsl:template match="scrap/head">
861    <xsl:text>&#10;</xsl:text>
862    <h5>
863      <xsl:apply-templates/>
864    </h5>
865  </xsl:template>
866
867  <xsl:template match="vcnote/head">
868    <p class="prefix">
869      <xsl:if test="../@id">
870	<a name="{../@id}"/>
871      </xsl:if>
872      <b><xsl:text>Validity constraint: </xsl:text><xsl:apply-templates/></b>
873    </p>
874  </xsl:template>
875
876  <xsl:template match="wfcnote/head">
877    <p class="prefix">
878      <xsl:if test="../@id">
879	<a name="{../@id}"/>
880      </xsl:if>
881      <b><xsl:text>Well-formedness constraint: </xsl:text><xsl:apply-templates/></b>
882    </p>
883  </xsl:template>
884
885  <!-- header: metadata about the spec -->
886  <!-- pull out information into standard W3C layout -->
887  <xsl:template match="header">
888    <div class="head">
889      <p>
890        <a href="http://www.w3.org/">
891          <img src="http://www.w3.org/Icons/w3c_home"
892            alt="W3C" height="48" width="72"/>
893        </a>
894      </p>
895      <xsl:text>&#10;</xsl:text>
896      <h1>
897        <xsl:apply-templates select="title"/>
898        <xsl:if test="version">
899          <xsl:text> </xsl:text>
900          <xsl:apply-templates select="version"/>
901        </xsl:if>
902      </h1>
903      <xsl:if test="subtitle">
904        <xsl:text>&#10;</xsl:text>
905        <h2>
906          <xsl:apply-templates select="subtitle"/>
907        </h2>
908      </xsl:if>
909      <xsl:text>&#10;</xsl:text>
910      <h2>
911        <xsl:apply-templates select="w3c-doctype"/>
912        <xsl:text> </xsl:text>
913        <xsl:if test="pubdate/day">
914          <xsl:apply-templates select="pubdate/day"/>
915          <xsl:text> </xsl:text>
916        </xsl:if>
917        <xsl:apply-templates select="pubdate/month"/>
918        <xsl:text> </xsl:text>
919        <xsl:apply-templates select="pubdate/year"/>
920      </h2>
921      <dl>
922        <xsl:apply-templates select="publoc"/>
923        <xsl:apply-templates select="latestloc"/>
924        <xsl:apply-templates select="prevlocs"/>
925        <xsl:apply-templates select="authlist"/>
926      </dl>
927      <p class="copyright">
928        <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">
929          <xsl:text>Copyright</xsl:text>
930        </a>
931        <xsl:text>&#xa0;&#xa9;&#xa0;</xsl:text>
932        <xsl:apply-templates select="pubdate/year"/>
933        <xsl:text>&#xa0;</xsl:text>
934        <a href="http://www.w3.org/">
935          <abbr title="World Wide Web Consortium">W3C</abbr>
936        </a>
937        <sup>&#xae;</sup>
938        <xsl:text> (</xsl:text>
939        <a href="http://www.lcs.mit.edu/">
940          <abbr title="Massachusetts Institute of Technology">MIT</abbr>
941        </a>
942        <xsl:text>, </xsl:text>
943        <a href="http://www.inria.fr/">
944        <abbr lang="fr"
945          title="Institut National de Recherche en Informatique et Automatique">INRIA</abbr>
946        </a>
947        <xsl:text>, </xsl:text>
948        <a href="http://www.keio.ac.jp/">Keio</a>
949        <xsl:text>), All Rights Reserved. W3C </xsl:text>
950        <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>
951        <xsl:text>, </xsl:text>
952        <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
953        <xsl:text>, </xsl:text>
954        <a href="http://www.w3.org/Consortium/Legal/copyright-documents-19990405">document use</a>
955        <xsl:text>, and </xsl:text>
956        <a href="http://www.w3.org/Consortium/Legal/copyright-software-19980720">software licensing</a>
957        <xsl:text> rules apply.</xsl:text>
958      </p>
959    </div>
960    <hr/>
961    <xsl:apply-templates select="notice"/>
962    <xsl:apply-templates select="abstract"/>
963    <xsl:apply-templates select="status"/>
964  </xsl:template>
965
966  <!-- inform-div1: non-normative back matter top-level division -->
967  <!-- treat like div1 except add "(Non-Normative)" to title -->
968  <xsl:template match="inform-div1">
969    <div class="div1">
970      <xsl:apply-templates/>
971    </div>
972  </xsl:template>
973
974  <!-- interface: -->
975  <!-- IDL stuff isn't handled yet -->
976
977  <!-- issue: open issue before the Working Group -->
978  <!-- maintain an ID for linking to it -->
979  <!-- currently generates boilerplate head plus optional head child
980       element; this should probably be cleaned up to only use the
981       head if it's present -->
982  <xsl:template match="issue">
983    <div class="issue">
984      <p class="prefix">
985	<xsl:if test="@id">
986	  <a name="{@id}"/>
987	</xsl:if>
988	<b><xsl:text>Issue (</xsl:text><xsl:value-of select="@id"/><xsl:text>):</xsl:text></b>
989      </p>
990      <xsl:apply-templates/>
991    </div>
992  </xsl:template>
993
994  <!-- item: generic list item -->
995  <xsl:template match="item">
996    <li>
997      <xsl:apply-templates/>
998    </li>
999  </xsl:template>
1000
1001  <!-- kw: keyword -->
1002  <!-- make it bold -->
1003  <xsl:template match="kw">
1004    <b><xsl:apply-templates/></b>
1005  </xsl:template>
1006
1007  <!-- label: term for defintion in glossary entry -->
1008  <!-- already in <dl> context from glist -->
1009  <xsl:template match="label">
1010    <dt class="label">
1011      <xsl:if test="@id"><a name="{@id}"/></xsl:if>
1012      <xsl:apply-templates/>
1013    </dt>
1014  </xsl:template>
1015
1016  <!-- language: -->
1017  <!-- langusage: -->
1018  <!-- identify language usage within a spec; not actually formatted -->
1019
1020  <!-- latestloc: latest location for this spec -->
1021  <!-- called in a <dl> context from header -->
1022  <xsl:template match="latestloc">
1023    <dt>Latest version:</dt>
1024    <dd>
1025      <xsl:apply-templates/>
1026    </dd>
1027  </xsl:template>
1028
1029  <!-- lhs: left-hand side of formal productions -->
1030  <!-- make a table row with the lhs and the corresponding other
1031       pieces in this crazy mixed-up content model -->
1032  <xsl:template match="lhs">
1033    <tr valign="baseline">
1034      <td>
1035	<xsl:if test="ancestor-or-self::*/@diff and $show.diff.markup='1'">
1036	  <xsl:attribute name="class">
1037	    <xsl:text>diff-</xsl:text>
1038	    <xsl:value-of select="ancestor-or-self::*/@diff"/>
1039	  </xsl:attribute>
1040	</xsl:if>
1041	<xsl:if test="../@id">
1042	  <a name="{../@id}"/>
1043	</xsl:if>
1044	<xsl:apply-templates select="ancestor::prod" mode="number"/>
1045<!--
1046  This could be done right here, but XT goes into deep space when the
1047  node to be numbered isn't the current node and level="any":
1048          <xsl:number count="prod" level="any" from="spec"
1049            format="[1]"/>
1050  -->
1051	<xsl:text>&#xa0;&#xa0;&#xa0;</xsl:text>
1052      </td>
1053      <td>
1054	<xsl:if test="ancestor-or-self::*/@diff and $show.diff.markup='1'">
1055	  <xsl:attribute name="class">
1056	    <xsl:text>diff-</xsl:text>
1057	    <xsl:value-of select="ancestor-or-self::*/@diff"/>
1058	  </xsl:attribute>
1059	</xsl:if>
1060        <code><xsl:apply-templates/></code>
1061      </td>
1062      <td>
1063	<xsl:if test="ancestor-or-self::*/@diff and $show.diff.markup='1'">
1064	  <xsl:attribute name="class">
1065	    <xsl:text>diff-</xsl:text>
1066	    <xsl:value-of select="ancestor-or-self::*/@diff"/>
1067	  </xsl:attribute>
1068	</xsl:if>
1069        <xsl:text>&#xa0;&#xa0;&#xa0;::=&#xa0;&#xa0;&#xa0;</xsl:text>
1070      </td>
1071      <xsl:apply-templates
1072        select="following-sibling::*[1][name()='rhs']"/>
1073    </tr>
1074  </xsl:template>
1075
1076  <!-- loc: a Web location -->
1077  <!-- outside the header, it's a normal cross-reference -->
1078  <xsl:template match="loc">
1079    <a href="{@href}">
1080      <xsl:apply-templates/>
1081    </a>
1082  </xsl:template>
1083
1084  <!-- member: member of an organization -->
1085  <!-- appears only in orglist, which creates <ul> context -->
1086  <xsl:template match="member">
1087    <li>
1088      <xsl:apply-templates/>
1089    </li>
1090  </xsl:template>
1091
1092  <!-- method: -->
1093  <!-- IDL stuff isn't handled yet -->
1094
1095  <!-- module: -->
1096  <!-- IDL stuff isn't handled yet -->
1097
1098  <!-- month: month of spec -->
1099  <!-- only used in pudate; called directly from header template -->
1100
1101  <!-- name: name of an editor or organization member -->
1102  <!-- only appears in author and member -->
1103  <!-- just output text -->
1104  <xsl:template match="name">
1105    <xsl:apply-templates/>
1106  </xsl:template>
1107
1108  <!-- note: a note about the spec -->
1109  <xsl:template match="note">
1110    <div class="note">
1111      <p class="prefix">
1112        <b>Note:</b>
1113      </p>
1114      <xsl:apply-templates/>
1115    </div>
1116  </xsl:template>
1117
1118  <!-- notice: a front-matter advisory about the spec's status -->
1119  <!-- make sure people notice it -->
1120  <xsl:template match="notice">
1121    <div class="notice">
1122      <p class="prefix">
1123        <b>NOTICE:</b>
1124      </p>
1125      <xsl:apply-templates/>
1126    </div>
1127  </xsl:template>
1128
1129  <!-- nt: production non-terminal -->
1130  <!-- make a link to the non-terminal's definition -->
1131  <xsl:template match="nt">
1132    <a>
1133      <xsl:attribute name="href">
1134        <xsl:call-template name="href.target">
1135          <xsl:with-param name="target" select="id(@def)"/>
1136        </xsl:call-template>
1137      </xsl:attribute>
1138      <xsl:apply-templates/>
1139    </a>
1140  </xsl:template>
1141
1142  <!-- olist: an ordered list -->
1143  <xsl:template match="olist">
1144    <ol>
1145      <xsl:apply-templates/>
1146    </ol>
1147  </xsl:template>
1148
1149  <!-- orglist: a list of an organization's members -->
1150  <xsl:template match="orglist">
1151    <ul>
1152      <xsl:apply-templates/>
1153    </ul>
1154  </xsl:template>
1155
1156  <!-- p: a standard paragraph -->
1157  <xsl:template match="p">
1158    <p>
1159      <xsl:if test="@id">
1160        <xsl:attribute name="id">
1161          <xsl:value-of select="@id"/>
1162        </xsl:attribute>
1163      </xsl:if>
1164      <xsl:if test="@role">
1165        <xsl:attribute name="class">
1166          <xsl:value-of select="@role"/>
1167        </xsl:attribute>
1168      </xsl:if>
1169      <xsl:apply-templates/>
1170    </p>
1171  </xsl:template>
1172
1173  <!-- param: -->
1174  <!-- IDL stuff isn't handled yet -->
1175
1176  <!-- parameters: -->
1177  <!-- IDL stuff isn't handled yet -->
1178
1179  <!-- phrase: semantically meaningless markup hanger -->
1180  <!-- role attributes may be used to request different formatting,
1181       which isn't currently handled -->
1182  <xsl:template match="phrase">
1183    <xsl:apply-templates/>
1184  </xsl:template>
1185
1186  <!-- prevlocs: previous locations for this spec -->
1187  <!-- called in a <dl> context from header -->
1188  <xsl:template match="prevlocs">
1189    <dt>Previous versions:</dt>
1190    <dd>
1191      <xsl:apply-templates/>
1192    </dd>
1193  </xsl:template>
1194
1195  <!-- prod: a formal grammar production -->
1196  <!-- if not in a prodgroup, needs a <tbody> -->
1197  <!-- has a weird content model; makes a table but there are no
1198       explicit rules; many different things can start a new row -->
1199  <!-- process the first child in each row, and it will process the
1200       others -->
1201  <xsl:template match="prod">
1202    <tbody>
1203      <xsl:apply-templates
1204        select="lhs |
1205                rhs[preceding-sibling::*[1][name()!='lhs']] |
1206                com[preceding-sibling::*[1][name()!='rhs']] |
1207                constraint[preceding-sibling::*[1][name()!='rhs']] |
1208                vc[preceding-sibling::*[1][name()!='rhs']] |
1209                wfc[preceding-sibling::*[1][name()!='rhs']]"/>
1210    </tbody>
1211  </xsl:template>
1212
1213  <xsl:template match="prodgroup/prod">
1214    <xsl:apply-templates
1215      select="lhs |
1216              rhs[preceding-sibling::*[1][name()!='lhs']] |
1217              com[preceding-sibling::*[1][name()!='rhs']] |
1218              constraint[preceding-sibling::*[1][name()!='rhs']] |
1219              vc[preceding-sibling::*[1][name()!='rhs']] |
1220              wfc[preceding-sibling::*[1][name()!='rhs']]"/>
1221  </xsl:template>
1222
1223  <!-- prodgroup: group of formal productions -->
1224  <!-- create one <tbody> for each group -->
1225  <xsl:template match="prodgroup">
1226    <tbody>
1227      <xsl:apply-templates/>
1228    </tbody>
1229  </xsl:template>
1230
1231  <!-- prodrecap: reiteration of a prod -->
1232  <!-- process the prod in another node that will never generate a
1233       <tbody> or a number, plus links the lhs to the original
1234       production -->
1235  <xsl:template match="prodrecap">
1236    <tbody>
1237      <xsl:apply-templates select="id(@ref)" mode="ref"/>
1238    </tbody>
1239  </xsl:template>
1240
1241  <!-- proto: function prototype -->
1242  <!-- type and name of the function, with arguments in parens -->
1243  <xsl:template match="proto">
1244    <p>
1245      <em><xsl:value-of select="@return-type"/></em>
1246      <xsl:text> </xsl:text>
1247      <b><xsl:value-of select="@name"/></b>
1248      <xsl:text>(</xsl:text>
1249      <xsl:apply-templates/>
1250      <xsl:text>)</xsl:text>
1251    </p>
1252  </xsl:template>
1253
1254  <!-- pubdate: date of spec -->
1255  <!-- called directly from header -->
1256
1257  <!-- publoc: location of current version of spec -->
1258  <!-- called from header in <dl> context -->
1259  <xsl:template match="publoc">
1260    <dt>This version:</dt>
1261    <dd>
1262      <xsl:apply-templates/>
1263    </dd>
1264  </xsl:template>
1265
1266  <!-- pubstmt: statement of publication -->
1267  <!-- not currently output -->
1268
1269  <!-- quote: a quoted string or phrase -->
1270  <!-- it would be nice to use HTML <q> elements, but browser support
1271       is abysmal -->
1272  <xsl:template match="quote">
1273    <xsl:text>"</xsl:text>
1274    <xsl:apply-templates/>
1275    <xsl:text>"</xsl:text>
1276  </xsl:template>
1277
1278  <!-- raises: -->
1279  <!-- IDL stuff isn't handled yet -->
1280
1281  <!-- reference: -->
1282  <!-- IDL stuff isn't handled yet -->
1283
1284  <!-- resolution: resolution of an issue -->
1285  <xsl:template match="resolution">
1286    <p class="prefix">
1287      <b>Resolution:</b>
1288    </p>
1289    <xsl:apply-templates/>
1290  </xsl:template>
1291
1292  <!-- returns: -->
1293  <!-- IDL stuff isn't handled yet -->
1294
1295  <!-- revisiondesc: description of spec revision -->
1296  <!-- used for internal tracking; not formatted -->
1297
1298  <!-- rhs: right-hand side of a formal production -->
1299  <!-- make a table cell; if it's not the first after an LHS, make a
1300       new row, too -->
1301  <xsl:template match="rhs">
1302    <xsl:choose>
1303      <xsl:when test="preceding-sibling::*[1][name()='lhs']">
1304        <td>
1305	  <xsl:if test="ancestor-or-self::*/@diff and $show.diff.markup='1'">
1306	    <xsl:attribute name="class">
1307	      <xsl:text>diff-</xsl:text>
1308	      <xsl:value-of select="ancestor-or-self::*/@diff"/>
1309	    </xsl:attribute>
1310	  </xsl:if>
1311          <code><xsl:apply-templates/></code>
1312        </td>
1313	<xsltdebug/>
1314        <xsl:apply-templates
1315          select="following-sibling::*[1][name()='com' or
1316                                          name()='constraint' or
1317                                          name()='vc' or
1318                                          name()='wfc']"/>
1319      </xsl:when>
1320      <xsl:otherwise>
1321        <tr valign="baseline">
1322          <td/><td/><td/>
1323          <td>
1324	    <xsl:if test="ancestor-or-self::*/@diff and $show.diff.markup='1'">
1325	      <xsl:attribute name="class">
1326		<xsl:text>diff-</xsl:text>
1327		<xsl:value-of select="ancestor-or-self::*/@diff"/>
1328	      </xsl:attribute>
1329	    </xsl:if>
1330            <code><xsl:apply-templates/></code>
1331          </td>
1332          <xsl:apply-templates
1333            select="following-sibling::*[1][name()='com' or
1334                                            name()='constraint' or
1335                                            name()='vc' or
1336                                            name()='wfc']"/>
1337        </tr>
1338      </xsl:otherwise>
1339    </xsl:choose>
1340  </xsl:template>
1341
1342  <!-- role: part played by a member of an organization -->
1343  <xsl:template match="role">
1344    <xsl:text> (</xsl:text>
1345    <i><xsl:apply-templates/></i>
1346    <xsl:text>) </xsl:text>
1347  </xsl:template>
1348
1349  <!-- scrap: series of formal grammar productions -->
1350  <!-- set up a <table> and handle children -->
1351  <xsl:template match="scrap">
1352    <xsl:apply-templates select="head"/>
1353    <table class="scrap" summary="Scrap">
1354      <xsl:apply-templates select="bnf | prod | prodgroup"/>
1355    </table>
1356  </xsl:template>
1357
1358  <!-- sequence: -->
1359  <!-- IDL stuff isn't handled yet -->
1360
1361  <!-- sitem: simple list item -->
1362  <!-- just make one paragraph with <br>s between items -->
1363  <xsl:template match="sitem[position() &gt; 1]">
1364    <br/>
1365    <xsl:apply-templates/>
1366  </xsl:template>
1367
1368  <!-- slist: simple list -->
1369  <!-- using a <blockquote> to indent the list is very wrong, but it
1370       works -->
1371  <xsl:template match="slist">
1372    <blockquote>
1373      <p>
1374        <xsl:apply-templates/>
1375      </p>
1376    </blockquote>
1377  </xsl:template>
1378
1379  <!-- source: the source of an issue -->
1380  <xsl:template match="source">
1381    <p>
1382      <b>Source</b>
1383      <xsl:text>: </xsl:text>
1384      <xsl:apply-templates/>
1385    </p>
1386  </xsl:template>
1387
1388  <!-- sourcedesc: description of spec preparation -->
1389  <!-- used for tracking the source, but not formatted -->
1390
1391  <!-- spec: the specification itself -->
1392  <xsl:template match="spec">
1393    <html>
1394      <xsl:if test="header/langusage/language">
1395        <xsl:attribute name="lang">
1396          <xsl:value-of select="header/langusage/language/@id"/>
1397        </xsl:attribute>
1398      </xsl:if>
1399      <head>
1400	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
1401        <title>
1402          <xsl:apply-templates select="header/title"/>
1403          <xsl:if test="header/version">
1404            <xsl:text> </xsl:text>
1405            <xsl:apply-templates select="header/version"/>
1406          </xsl:if>
1407          <xsl:if test="$additional.title != ''">
1408            <xsl:text> -- </xsl:text>
1409            <xsl:value-of select="$additional.title"/>
1410	  </xsl:if>
1411        </title>
1412        <xsl:call-template name="css"/>
1413      </head>
1414      <body>
1415        <xsl:apply-templates/>
1416        <xsl:if test="//footnote">
1417          <hr/>
1418          <div class="endnotes">
1419            <xsl:text>&#10;</xsl:text>
1420            <h3>
1421              <a name="endnotes">
1422                <xsl:text>End Notes</xsl:text>
1423              </a>
1424            </h3>
1425            <dl>
1426              <xsl:apply-templates select="//footnote" mode="notes"/>
1427            </dl>
1428          </div>
1429        </xsl:if>
1430      </body>
1431    </html>
1432  </xsl:template>
1433
1434  <!-- specref: reference to another part of teh current specification -->
1435  <xsl:template match="specref">
1436    <xsl:variable name="target" select="id(@ref)[1]"/>
1437    <a>
1438      <xsl:attribute name="href">
1439        <xsl:call-template name="href.target">
1440          <xsl:with-param name="target" select="id(@ref)"/>
1441        </xsl:call-template>
1442      </xsl:attribute>
1443      <xsl:choose>
1444	<xsl:when test="starts-with(local-name($target), 'div')">
1445	  <b><xsl:apply-templates select="id(@ref)" mode="divnum"/><xsl:apply-templates select="id(@ref)/head" mode="text"/></b>
1446	</xsl:when>
1447	<xsl:when test="starts-with(local-name($target), 'inform-div')">
1448	  <b><xsl:apply-templates select="id(@ref)" mode="divnum"/><xsl:apply-templates select="id(@ref)/head" mode="text"/></b>
1449	</xsl:when>
1450	<xsl:when test="local-name($target) = 'vcnote'">
1451	  <b><xsl:text>[VC: </xsl:text><xsl:apply-templates select="id(@ref)/head" mode="text"/><xsl:text>]</xsl:text></b>
1452	</xsl:when>
1453	<xsl:when test="local-name($target) = 'prod'">
1454	  <b>
1455            <xsl:text>[PROD: </xsl:text>
1456            <xsl:apply-templates select="$target" mode="number-simple"/>
1457            <xsl:text>]</xsl:text>
1458          </b>
1459	</xsl:when>
1460	<xsl:when test="local-name($target) = 'label'">
1461	  <b>
1462            <xsl:text>[</xsl:text>
1463            <xsl:value-of select="$target"/>
1464            <xsl:text>]</xsl:text>
1465          </b>
1466	</xsl:when>
1467	<xsl:otherwise>
1468	  <xsl:message>
1469	    <xsl:text>Unsupported specref to </xsl:text>
1470	    <xsl:value-of select="local-name($target)"/>
1471	    <xsl:text> [</xsl:text>
1472	    <xsl:value-of select="@ref"/>
1473	    <xsl:text>] </xsl:text>
1474	    <xsl:text> (Contact stylesheet maintainer).</xsl:text>
1475	  </xsl:message>
1476	  <b>???</b>
1477	</xsl:otherwise>
1478      </xsl:choose>
1479    </a>
1480  </xsl:template>
1481
1482  <!-- status: the status of the spec -->
1483  <xsl:template match="status">
1484    <div id="status">
1485      <xsl:text>&#10;</xsl:text>
1486      <h2>
1487        <a name="status">Status of this Document</a>
1488      </h2>
1489      <xsl:apply-templates/>
1490    </div>
1491  </xsl:template>
1492
1493  <!-- struct: -->
1494  <!-- IDL stuff isn't handled yet -->
1495
1496  <!-- sub: subscript -->
1497  <xsl:template match="sub">
1498    <sub>
1499      <xsl:apply-templates/>
1500    </sub>
1501  </xsl:template>
1502
1503  <!-- subtitle: secondary title of spec -->
1504  <!-- handled directly within header -->
1505
1506  <!-- sup: superscript -->
1507  <xsl:template match="sup">
1508    <sup>
1509      <xsl:apply-templates/>
1510    </sup>
1511  </xsl:template>
1512
1513  <!-- table: the HTML table model adopted wholesale -->
1514  <!-- tbody: -->
1515  <!-- td: -->
1516  <xsl:template
1517    match="caption | col | colgroup | table | tbody | td | tfoot | th | thead | tr">
1518    <xsl:copy>
1519      <xsl:for-each select="@*">
1520	<!-- Wait: some of these aren't HTML attributes after all... -->
1521	<xsl:if test="local-name(.) != 'diff'">
1522	  <xsl:copy>
1523	    <xsl:apply-templates/>
1524	  </xsl:copy>
1525	</xsl:if>
1526      </xsl:for-each>
1527      <xsl:apply-templates/>
1528    </xsl:copy>
1529  </xsl:template>
1530
1531  <!-- term: the actual mention of a term within a termdef -->
1532  <xsl:template match="term">
1533    <b><xsl:apply-templates/></b>
1534  </xsl:template>
1535
1536  <!-- termdef: sentence or phrase defining a term -->
1537  <xsl:template match="termdef">
1538    <xsl:text>[</xsl:text>
1539    <a name="{@id}" title="{@term}">
1540      <xsl:text>Definition</xsl:text>
1541    </a>
1542    <xsl:text>: </xsl:text>
1543    <xsl:apply-templates/>
1544    <xsl:text>]</xsl:text>
1545  </xsl:template>
1546
1547  <!-- termref: reference to a defined term -->
1548  <xsl:template match="termref">
1549    <a title="{id(@def)/@term}">
1550      <xsl:attribute name="href">
1551        <xsl:call-template name="href.target">
1552          <xsl:with-param name="target" select="id(@def)"/>
1553        </xsl:call-template>
1554      </xsl:attribute>
1555      <xsl:apply-templates/>
1556    </a>
1557  </xsl:template>
1558
1559  <!-- tfoot: see table -->
1560  <!-- th: see table -->
1561  <!-- thead: see table -->
1562
1563  <!-- title: title of the specification -->
1564  <!-- called directly within header -->
1565
1566  <!-- titleref: reference to the title of any work -->
1567  <!-- if a URL is given, link it -->
1568  <xsl:template match="titleref">
1569    <xsl:choose>
1570      <xsl:when test="@href">
1571        <a href="{@href}">
1572          <cite>
1573            <xsl:apply-templates/>
1574          </cite>
1575        </a>
1576      </xsl:when>
1577      <xsl:otherwise>
1578        <cite>
1579          <xsl:apply-templates/>
1580        </cite>
1581      </xsl:otherwise>
1582    </xsl:choose>
1583  </xsl:template>
1584
1585  <!-- tr: see table -->
1586
1587  <!-- typedef: -->
1588  <!-- IDL stuff isn't handled yet -->
1589
1590  <!-- typename: -->
1591  <!-- IDL stuff isn't handled yet -->
1592
1593  <!-- ulist: unordered list -->
1594  <xsl:template match="ulist">
1595    <ul>
1596      <xsl:apply-templates/>
1597    </ul>
1598  </xsl:template>
1599
1600  <!-- union: -->
1601  <!-- IDL stuff isn't handled yet -->
1602
1603  <!-- var: a variable -->
1604  <xsl:template match="var">
1605    <var>
1606      <xsl:apply-templates/>
1607    </var>
1608  </xsl:template>
1609
1610  <!-- vc: validity check reference in a formal production -->
1611  <xsl:template match="vc">
1612    <xsl:choose>
1613      <xsl:when test="preceding-sibling::*[1][name()='rhs']">
1614        <td>
1615	  <xsl:if test="@diff and $show.diff.markup='1'">
1616	    <xsl:attribute name="class">
1617	      <xsl:text>diff-</xsl:text>
1618	      <xsl:value-of select="@diff"/>
1619	    </xsl:attribute>
1620	  </xsl:if>
1621          <a>
1622            <xsl:attribute name="href">
1623              <xsl:call-template name="href.target">
1624                <xsl:with-param name="target" select="id(@def)"/>
1625              </xsl:call-template>
1626            </xsl:attribute>
1627            <xsl:text>[VC: </xsl:text>
1628            <xsl:apply-templates select="id(@def)/head" mode="text"/>
1629            <xsl:text>]</xsl:text>
1630          </a>
1631        </td>
1632      </xsl:when>
1633      <xsl:otherwise>
1634        <tr valign="baseline">
1635          <td/><td/><td/><td/>
1636          <td>
1637	    <xsl:if test="@diff and $show.diff.markup='1'">
1638	      <xsl:attribute name="class">
1639		<xsl:text>diff-</xsl:text>
1640		<xsl:value-of select="@diff"/>
1641	      </xsl:attribute>
1642	    </xsl:if>
1643            <a>
1644              <xsl:attribute name="href">
1645                <xsl:call-template name="href.target">
1646                  <xsl:with-param name="target" select="id(@def)"/>
1647                </xsl:call-template>
1648              </xsl:attribute>
1649              <xsl:text>[VC: </xsl:text>
1650              <xsl:apply-templates select="id(@def)/head" mode="text"/>
1651              <xsl:text>]</xsl:text>
1652            </a>
1653          </td>
1654        </tr>
1655      </xsl:otherwise>
1656    </xsl:choose>
1657  </xsl:template>
1658
1659  <!-- vcnote: validity check note after a formal production -->
1660  <xsl:template match="vcnote">
1661    <div class="constraint">
1662      <xsl:apply-templates/>
1663    </div>
1664  </xsl:template>
1665
1666  <!-- version: version of this spec -->
1667  <!-- called directly from header -->
1668
1669  <!-- w3c-designation: canonical name for this spec -->
1670  <!-- not used for formatting -->
1671
1672  <!-- w3c-doctype: type of document the specification is -->
1673  <!-- used by header template to select CSS stylesheet for output
1674       HTML -->
1675
1676  <!-- wfc: well-formedness check reference in a formal production -->
1677  <xsl:template match="wfc">
1678    <xsl:choose>
1679      <xsl:when test="preceding-sibling::*[1][name()='rhs']">
1680        <td>
1681	  <xsl:if test="@diff and $show.diff.markup='1'">
1682	    <xsl:attribute name="class">
1683	      <xsl:text>diff-</xsl:text>
1684	      <xsl:value-of select="@diff"/>
1685	    </xsl:attribute>
1686	  </xsl:if>
1687          <a>
1688            <xsl:attribute name="href">
1689              <xsl:call-template name="href.target">
1690                <xsl:with-param name="target" select="id(@def)"/>
1691              </xsl:call-template>
1692            </xsl:attribute>
1693            <xsl:text>[WFC: </xsl:text>
1694            <xsl:apply-templates select="id(@def)/head" mode="text"/>
1695            <xsl:text>]</xsl:text>
1696          </a>
1697        </td>
1698      </xsl:when>
1699      <xsl:otherwise>
1700        <tr valign="baseline">
1701          <td/><td/><td/><td/>
1702          <td>
1703	    <xsl:if test="@diff and $show.diff.markup='1'">
1704	      <xsl:attribute name="class">
1705		<xsl:text>diff-</xsl:text>
1706		<xsl:value-of select="@diff"/>
1707	      </xsl:attribute>
1708	    </xsl:if>
1709            <a>
1710              <xsl:attribute name="href">
1711                <xsl:call-template name="href.target">
1712                  <xsl:with-param name="target" select="id(@def)"/>
1713                </xsl:call-template>
1714              </xsl:attribute>
1715              <xsl:text>[WFC: </xsl:text>
1716              <xsl:apply-templates select="id(@def)/head" mode="text"/>
1717              <xsl:text>]</xsl:text>
1718            </a>
1719          </td>
1720        </tr>
1721      </xsl:otherwise>
1722    </xsl:choose>
1723  </xsl:template>
1724
1725  <!-- wfcnote: well-formedness check note after formal production -->
1726  <xsl:template match="wfcnote">
1727    <div class="constraint">
1728      <xsl:apply-templates/>
1729    </div>
1730  </xsl:template>
1731
1732  <!-- xnt: external non-terminal -->
1733  <!-- xspecref: external specification reference -->
1734  <!-- xtermref: external term reference -->
1735  <!-- just link to URI provided -->
1736  <xsl:template match="xnt | xspecref | xtermref">
1737    <a href="{@href}">
1738      <xsl:apply-templates/>
1739    </a>
1740  </xsl:template>
1741
1742  <!-- year: year of spec -->
1743  <!-- only used in pudate; called directly from header template -->
1744
1745  <!-- Silly HTML elements used for pasting stuff in; shouldn't ever
1746       show up in a spec, but they're easy to handle and you just
1747       never know. -->
1748  <xsl:template match="a|div|em|h1|h2|h3|h4|h5|h6|li|ol|pre|ul">
1749    <xsl:copy>
1750      <xsl:for-each select="@*">
1751        <xsl:copy>
1752          <xsl:apply-templates/>
1753        </xsl:copy>
1754      </xsl:for-each>
1755      <xsl:apply-templates/>
1756    </xsl:copy>
1757  </xsl:template>
1758
1759  <!-- legacy XML spec stuff -->
1760  <xsl:template match="htable">
1761    <table summary="HTML Table">
1762      <xsl:for-each select="@*">
1763        <xsl:copy>
1764          <xsl:apply-templates/>
1765        </xsl:copy>
1766      </xsl:for-each>
1767      <xsl:apply-templates/>
1768    </table>
1769  </xsl:template>
1770  <xsl:template match="htbody">
1771    <tbody>
1772      <xsl:for-each select="@*">
1773        <xsl:copy>
1774          <xsl:apply-templates/>
1775        </xsl:copy>
1776      </xsl:for-each>
1777      <xsl:apply-templates/>
1778    </tbody>
1779  </xsl:template>
1780  <xsl:template match="key-term">
1781    <b><xsl:apply-templates/></b>
1782  </xsl:template>
1783  <xsl:template match="statusp">
1784    <p>
1785      <xsl:apply-templates/>
1786    </p>
1787  </xsl:template>
1788
1789  <!-- legacy DocBook stuff -->
1790  <xsl:template match="itemizedlist">
1791    <ul>
1792      <xsl:apply-templates/>
1793    </ul>
1794  </xsl:template>
1795  <xsl:template match="listitem">
1796    <li>
1797      <xsl:apply-templates/>
1798    </li>
1799  </xsl:template>
1800  <xsl:template match="orderedlist">
1801    <ol>
1802      <xsl:apply-templates/>
1803    </ol>
1804  </xsl:template>
1805  <xsl:template match="para">
1806    <p>
1807      <xsl:apply-templates/>
1808    </p>
1809  </xsl:template>
1810
1811  <!-- mode: divnum -->
1812  <xsl:template mode="divnum" match="div1">
1813    <xsl:number format="1 "/>
1814  </xsl:template>
1815
1816  <xsl:template mode="divnum" match="back/div1 | inform-div1">
1817    <xsl:number count="div1 | inform-div1" format="A "/>
1818  </xsl:template>
1819
1820  <xsl:template mode="divnum"
1821    match="front/div1 | front//div2 | front//div3 | front//div4 | front//div5"/>
1822
1823  <xsl:template mode="divnum" match="div2">
1824    <xsl:number level="multiple" count="div1 | div2" format="1.1 "/>
1825  </xsl:template>
1826
1827  <xsl:template mode="divnum" match="back//div2">
1828    <xsl:number level="multiple" count="div1 | div2 | inform-div1"
1829      format="A.1 "/>
1830  </xsl:template>
1831
1832  <xsl:template mode="divnum" match="div3">
1833    <xsl:number level="multiple" count="div1 | div2 | div3"
1834      format="1.1.1 "/>
1835  </xsl:template>
1836
1837  <xsl:template mode="divnum" match="back//div3">
1838    <xsl:number level="multiple"
1839      count="div1 | div2 | div3 | inform-div1" format="A.1.1 "/>
1840  </xsl:template>
1841
1842  <xsl:template mode="divnum" match="div4">
1843    <xsl:number level="multiple" count="div1 | div2 | div3 | div4"
1844      format="1.1.1.1 "/>
1845  </xsl:template>
1846
1847  <xsl:template mode="divnum" match="back//div4">
1848    <xsl:number level="multiple"
1849      count="div1 | div2 | div3 | div4 | inform-div1"
1850      format="A.1.1.1 "/>
1851  </xsl:template>
1852
1853  <xsl:template mode="divnum" match="div5">
1854    <xsl:number level="multiple"
1855      count="div1 | div2 | div3 | div4 | div5" format="1.1.1.1.1 "/>
1856  </xsl:template>
1857
1858  <xsl:template mode="divnum" match="back//div5">
1859    <xsl:number level="multiple"
1860      count="div1 | div2 | div3 | div4 | div5 | inform-div1"
1861      format="A.1.1.1.1 "/>
1862  </xsl:template>
1863
1864  <!-- mode: notes -->
1865  <xsl:template mode="notes" match="footnote">
1866    <xsl:variable name="this-note-id">
1867      <xsl:choose>
1868        <xsl:when test="@id">
1869          <xsl:value-of select="@id"/>
1870        </xsl:when>
1871        <xsl:otherwise>
1872          <xsl:value-of select="generate-id(.)"/>
1873        </xsl:otherwise>
1874      </xsl:choose>
1875    </xsl:variable>
1876    <dt>
1877      <a name="{$this-note-id}" href="#FN-ANCH-{$this-note-id}">
1878        <xsl:number level="any" format="[1]"/>
1879      </a>
1880    </dt>
1881    <dd>
1882      <xsl:apply-templates/>
1883    </dd>
1884  </xsl:template>
1885
1886  <!-- mode: number -->
1887  <xsl:template mode="number" match="prod">
1888    <xsl:text>[</xsl:text>
1889    <xsl:apply-templates select="." mode="number-simple"/>
1890    <xsl:text>]</xsl:text>
1891  </xsl:template>
1892
1893  <xsl:template mode="number" match="prod[@diff='add']">
1894    <xsl:text>[</xsl:text>
1895    <xsl:apply-templates select="preceding::prod[not(@diff='add')][1]"
1896      mode="number-simple"/>
1897<!--
1898  Once again, this could be done right here, but XT won't hear of it.
1899    <xsl:number level="any" count="prod[not(@diff='add')]"/>
1900  -->
1901    <xsl:number level="any" count="prod[@diff='add']"
1902      from="prod[not(@diff='add')]" format="a"/>
1903    <xsl:text>]</xsl:text>
1904  </xsl:template>
1905
1906  <!-- mode: number-simple -->
1907  <xsl:template mode="number-simple" match="prod">
1908    <xsl:number level="any" count="prod[not(@diff='add')]"/>
1909  </xsl:template>
1910
1911  <!-- mode: ref -->
1912  <xsl:template match="lhs" mode="ref">
1913    <tr valign="baseline">
1914      <td/>
1915      <td>
1916	<xsl:if test="ancestor-or-self::*/@diff and $show.diff.markup='1'">
1917	  <xsl:attribute name="class">
1918	    <xsl:text>diff-</xsl:text>
1919	    <xsl:value-of select="ancestor-or-self::*/@diff"/>
1920	  </xsl:attribute>
1921	</xsl:if>
1922	<xsl:if test="../@id">
1923	  <a name="{../@id}"/>
1924	</xsl:if>
1925	<code><xsl:apply-templates/></code>
1926      </td>
1927      <td>
1928	<xsl:if test="ancestor-or-self::*/@diff and $show.diff.markup='1'">
1929	  <xsl:attribute name="class">
1930	    <xsl:text>diff-</xsl:text>
1931	    <xsl:value-of select="ancestor-or-self::*/@diff"/>
1932	  </xsl:attribute>
1933	</xsl:if>
1934        <xsl:text>&#xa0;&#xa0;&#xa0;::=&#xa0;&#xa0;&#xa0;</xsl:text>
1935      </td>
1936      <xsl:apply-templates
1937        select="following-sibling::*[1][name()='rhs']"/>
1938    </tr>
1939  </xsl:template>
1940
1941  <xsl:template mode="ref" match="prod">
1942    <xsl:apply-templates select="lhs" mode="ref"/>
1943    <xsl:apply-templates
1944      select="rhs[preceding-sibling::*[1][name()!='lhs']] |
1945              com[preceding-sibling::*[1][name()!='rhs']] |
1946              constraint[preceding-sibling::*[1][name()!='rhs']] |
1947              vc[preceding-sibling::*[1][name()!='rhs']] |
1948              wfc[preceding-sibling::*[1][name()!='rhs']]"/>
1949  </xsl:template>
1950
1951  <!-- mode: text -->
1952  <!-- most stuff processes just as text here, but some things should
1953       be hidden -->
1954  <xsl:template mode="text" match="ednote | footnote"/>
1955
1956  <!-- mode: toc -->
1957  <xsl:template mode="toc" match="div1">
1958    <xsl:apply-templates select="." mode="divnum"/>
1959    <a>
1960      <xsl:attribute name="href">
1961        <xsl:call-template name="href.target">
1962          <xsl:with-param name="target" select="."/>
1963        </xsl:call-template>
1964      </xsl:attribute>
1965      <xsl:apply-templates select="head" mode="text"/>
1966    </a>
1967    <br/>
1968    <xsl:apply-templates select="div2" mode="toc"/>
1969  </xsl:template>
1970
1971  <xsl:template mode="toc" match="div2">
1972    <xsl:text>&#xa0;&#xa0;&#xa0;&#xa0;</xsl:text>
1973    <xsl:apply-templates select="." mode="divnum"/>
1974    <a>
1975      <xsl:attribute name="href">
1976        <xsl:call-template name="href.target">
1977          <xsl:with-param name="target" select="."/>
1978        </xsl:call-template>
1979      </xsl:attribute>
1980      <xsl:apply-templates select="head" mode="text"/>
1981    </a>
1982    <br/>
1983    <xsl:apply-templates select="div3" mode="toc"/>
1984  </xsl:template>
1985
1986  <xsl:template mode="toc" match="div3">
1987    <xsl:text>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</xsl:text>
1988    <xsl:apply-templates select="." mode="divnum"/>
1989    <a>
1990      <xsl:attribute name="href">
1991        <xsl:call-template name="href.target">
1992          <xsl:with-param name="target" select="."/>
1993        </xsl:call-template>
1994      </xsl:attribute>
1995      <xsl:apply-templates select="head" mode="text"/>
1996    </a>
1997    <br/>
1998    <xsl:apply-templates select="div4" mode="toc"/>
1999  </xsl:template>
2000
2001  <xsl:template mode="toc" match="div4">
2002    <xsl:text>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</xsl:text>
2003    <xsl:apply-templates select="." mode="divnum"/>
2004    <a>
2005      <xsl:attribute name="href">
2006        <xsl:call-template name="href.target">
2007          <xsl:with-param name="target" select="."/>
2008        </xsl:call-template>
2009      </xsl:attribute>
2010      <xsl:apply-templates select="head" mode="text"/>
2011    </a>
2012    <br/>
2013    <xsl:apply-templates select="div5" mode="toc"/>
2014  </xsl:template>
2015
2016  <xsl:template mode="toc" match="div5">
2017    <xsl:text>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</xsl:text>
2018    <xsl:apply-templates select="." mode="divnum"/>
2019    <a>
2020      <xsl:attribute name="href">
2021        <xsl:call-template name="href.target">
2022          <xsl:with-param name="target" select="."/>
2023        </xsl:call-template>
2024      </xsl:attribute>
2025      <xsl:apply-templates select="head" mode="text"/>
2026    </a>
2027    <br/>
2028  </xsl:template>
2029
2030  <xsl:template mode="toc" match="inform-div1">
2031    <xsl:apply-templates select="." mode="divnum"/>
2032    <a>
2033      <xsl:attribute name="href">
2034        <xsl:call-template name="href.target">
2035          <xsl:with-param name="target" select="."/>
2036        </xsl:call-template>
2037      </xsl:attribute>
2038      <xsl:apply-templates select="head" mode="text"/>
2039    </a>
2040    <xsl:text> (Non-Normative)</xsl:text>
2041    <br/>
2042    <xsl:apply-templates select="div2" mode="toc"/>
2043  </xsl:template>
2044
2045  <xsl:template name="css">
2046    <style type="text/css">
2047      <xsl:text>
2048code           { font-family: monospace; }
2049
2050div.constraint,
2051div.issue,
2052div.note,
2053div.notice     { margin-left: 2em; }
2054
2055dt.label       { display: run-in; }
2056
2057li p           { margin-top: 0.3em;
2058                 margin-bottom: 0.3em; }
2059      </xsl:text>
2060      <xsl:value-of select="$additional.css"/>
2061    </style>
2062    <link rel="stylesheet" type="text/css">
2063      <xsl:attribute name="href">
2064        <xsl:text>W3C-</xsl:text>
2065        <xsl:choose>
2066          <xsl:when test="/spec/@w3c-doctype='wd'">WD</xsl:when>
2067          <xsl:when test="/spec/@w3c-doctype='rec'">REC</xsl:when>
2068          <xsl:when test="/spec/@w3c-doctype='pr'">REC</xsl:when>
2069          <xsl:when test="/spec/@w3c-doctype='cr'">REC</xsl:when>
2070          <xsl:otherwise>NOTE</xsl:otherwise>
2071        </xsl:choose>
2072        <xsl:text>.css</xsl:text>
2073      </xsl:attribute>
2074    </link>
2075  </xsl:template>
2076
2077  <xsl:template name="href.target">
2078    <xsl:param name="target" select="."/>
2079
2080    <xsl:text>#</xsl:text>
2081
2082    <xsl:choose>
2083      <xsl:when test="$target/@id">
2084        <xsl:value-of select="$target/@id"/>
2085      </xsl:when>
2086      <xsl:otherwise>
2087        <xsl:value-of select="generate-id($target)"/>
2088      </xsl:otherwise>
2089    </xsl:choose>
2090  </xsl:template>
2091
2092</xsl:transform>
2093