forked from whatwg/webidl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WebIDL.xsl
847 lines (802 loc) · 34.9 KB
/
WebIDL.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:h='http://www.w3.org/1999/xhtml'
xmlns:x='http://mcc.id.au/ns/local'
xmlns='http://www.w3.org/1999/xhtml'
exclude-result-prefixes='h x'
version='1.0' id='xslt'>
<xsl:output method='xml' encoding='UTF-8'
omit-xml-declaration='yes'
doctype-public='-//W3C//DTD XHTML 1.0 Transitional//EN'
doctype-system='http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'
media-type='application/xhtml+xml; charset=UTF-8'/>
<xsl:variable name='options' select='/*/h:head/x:options'/>
<xsl:variable name='id' select='/*/h:head/h:meta[@name="revision"]/@content'/>
<xsl:variable name='rev' select='substring-before(substring-after(substring-after($id, " "), " "), " ")'/>
<xsl:variable name='tocpi' select='//processing-instruction("toc")[1]'/>
<xsl:param name='now'>12340506<!--
<xsl:value-of select='translate(substring-before(substring-after(substring-after(substring-after($id, " "), " "), " "), " "), "/", "")'/>-->
</xsl:param>
<xsl:template match='/'>
<xsl:text>
</xsl:text>
<xsl:if test='$options/x:maturity="ED"'>
<xsl:comment>
index.html
Web IDL
Note: This file is generated from index.xml. Run "make" to regenerate it.
</xsl:comment>
<xsl:text>
</xsl:text>
</xsl:if>
<xsl:apply-templates select='/*'/>
</xsl:template>
<xsl:template match='h:*'>
<xsl:element name="{name()}" namespace="{namespace-uri()}">
<xsl:copy-of select='@*[namespace-uri()="" or namespace-uri="http://www.w3.org/XML/1998/namespace"]'/>
<xsl:apply-templates select='node()'/>
</xsl:element>
</xsl:template>
<xsl:template match='h:head'>
<head>
<xsl:copy-of select='@*[namespace-uri()="" or namespace-uri="http://www.w3.org/XML/1998/namespace"]'/>
<xsl:apply-templates select='node()'/>
<xsl:choose>
<xsl:when test='$options/x:maturity="FPWD" or $options/x:maturity="LCWD" or $options/x:maturity="FPWDLC"'>
<link rel='stylesheet' href='https://www.w3.org/StyleSheets/TR/W3C-WD' type='text/css'/>
</xsl:when>
<xsl:otherwise>
<link rel='stylesheet' href='https://www.w3.org/StyleSheets/TR/W3C-{$options/x:maturity}' type='text/css'/>
</xsl:otherwise>
</xsl:choose>
</head>
</xsl:template>
<xsl:template match='h:span[@class="idltype"]'>
<xsl:variable name='id' select='concat("idl-", translate(., " ", "-"))'/>
<xsl:variable name='def' select='//*[@id=$id]'/>
<xsl:choose>
<xsl:when test='not(ancestor::h:a) and not(@id) and $def'>
<a class='idltype' href='#{$id}'><xsl:apply-templates select='node()'/></a>
</xsl:when>
<xsl:otherwise>
<span>
<xsl:copy-of select='@*[namespace-uri()="" or namespace-uri="http://www.w3.org/XML/1998/namespace"]'/>
<xsl:apply-templates select='node()'/>
</span>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match='h:a[not(@href)]'>
<xsl:variable name='name' select='string(.)'/>
<xsl:variable name='a-class' select='@class'/>
<xsl:variable name='term' select='$options/x:links/x:term[@name=$name]'/>
<xsl:if test='not($term)'>
<xsl:message terminate='yes'>unknown term '<xsl:value-of select='$name'/>'</xsl:message>
</xsl:if>
<xsl:variable name='ref' select='$term/@ref'/>
<xsl:variable name='section' select='$term/@section'/>
<xsl:variable name='term-class' select='$term/@class'/>
<xsl:variable name='final-class'>
<xsl:value-of select='$a-class'/>
<xsl:if test='$a-class and $term-class'>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:value-of select='$term-class'/>
</xsl:variable>
<a class="{$final-class}" href='{$term/@href}'>
<xsl:apply-templates/>
</a>
<xsl:if test='not(contains($a-class, "nocite")) and $ref'>
<xsl:if test='$section'>
<xsl:text> (</xsl:text>
</xsl:if>
<a href='#ref-{$ref}'>[<xsl:value-of select='$ref'/>]</a>
<xsl:if test='$section'>
<xsl:text>, section </xsl:text>
<xsl:value-of select='$section'/>
<xsl:text>)</xsl:text>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template name='monthName'>
<xsl:param name='n' select='1'/>
<xsl:param name='s' select='"January February March April May June July August September October November December "'/>
<xsl:choose>
<xsl:when test='string(number($n))="NaN"'>@@</xsl:when>
<xsl:when test='$n = 1'>
<xsl:value-of select='substring-before($s, " ")'/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name='monthName'>
<xsl:with-param name='n' select='$n - 1'/>
<xsl:with-param name='s' select='substring-after($s, " ")'/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match='processing-instruction("top")'>
<div class='head'>
<div><a href="http://www.w3.org/"><img src="https://www.w3.org/Icons/w3c_home" width="72" height="48" alt="W3C"></img></a></div>
<h1><xsl:value-of select='/*/h:head/h:title'/></h1>
<h2>
<xsl:text>W3C </xsl:text>
<xsl:choose>
<xsl:when test='$options/x:maturity="FPWD"'>First Public Working Draft</xsl:when>
<xsl:when test='$options/x:maturity="FPLCWD"'>First Public and Last Call Working Draft</xsl:when>
<xsl:when test='$options/x:maturity="LCWD"'>and Last Call Working Draft</xsl:when>
<xsl:when test='$options/x:maturity="WD"'>Working Draft</xsl:when>
<xsl:when test='$options/x:maturity="CR"'>Candidate Recommendation</xsl:when>
<xsl:when test='$options/x:maturity="PR"'>Proposed Recommendation</xsl:when>
<xsl:when test='$options/x:maturity="PER"'>Proposed Edited Recommendation</xsl:when>
<xsl:when test='$options/x:maturity="REC"'>Recommendation</xsl:when>
<xsl:when test='$options/x:maturity="WG-NOTE"'>Working Group Note</xsl:when>
<xsl:otherwise>Editor’s Draft</xsl:otherwise>
</xsl:choose>
<xsl:text> </xsl:text>
<em><xsl:call-template name='date'/></em>
</h2>
<dl>
<dt>This Version:</dt>
<xsl:choose>
<xsl:when test='$options/x:versions/x:cvs and $options/x:maturity="ED"'>
<xsl:variable name='href' select='$options/x:versions/x:cvs/@href'/>
<dd><a href='{$href}'><xsl:value-of select='$href'/></a></dd>
</xsl:when>
<xsl:otherwise>
<dd><a href='{$options/x:versions/x:this/@href}'><xsl:value-of select='$options/x:versions/x:this/@href'/></a></dd>
</xsl:otherwise>
</xsl:choose>
<xsl:if test='$options/x:maturity != "ED"'>
<dt>Current Editor’s Draft:</dt>
<dd>
<xsl:variable name='href' select='$options/x:versions/x:cvs/@href'/>
<a href='{$href}'><xsl:value-of select='$href'/></a>
</dd>
</xsl:if>
<xsl:if test='$options/x:versions/x:latest/@href != ""'>
<dt>Latest Version:</dt>
<dd><a href='{$options/x:versions/x:latest/@href}'><xsl:value-of select='$options/x:versions/x:latest/@href'/></a></dd>
</xsl:if>
<xsl:if test='$options/x:versions/x:previous[@href!=""]'>
<dt>Previous Version<xsl:if test='count($options/x:versions/x:previous[@href!=""]) > 1'>s</xsl:if>:</dt>
<xsl:if test='$options/x:versions/x:previous/@href != ""'>
<xsl:for-each select='$options/x:versions/x:previous/@href'>
<dd><a href='{.}'><xsl:value-of select='.'/></a></dd>
</xsl:for-each>
</xsl:if>
</xsl:if>
<xsl:variable name='list' select='$options/x:participate/x:mailing-list/@email'/>
<xsl:variable name='bugzilla' select='$options/x:participate/x:bugzilla'/>
<xsl:if test='$list or $bugzilla'>
<dt>Participate:</dt>
<dd>
<xsl:if test='$list'>
Send feedback to <a href='mailto:{$list}'><xsl:value-of select='$list'/></a>
</xsl:if>
<xsl:if test='$bugzilla'>
<xsl:choose>
<xsl:when test='$list'>
<xsl:text> or </xsl:text>
<a href='{$bugzilla/@file}'>file a bug</a>
</xsl:when>
<xsl:otherwise>
<a href='{$bugzilla/@file}'>File a bug</a>
</xsl:otherwise>
</xsl:choose>
<xsl:text> (</xsl:text>
<a href='{$bugzilla/@open}'>open bugs</a>)
</xsl:if>
</dd>
</xsl:if>
<dt>Editor<xsl:if test='count($options/x:editors/x:person) > 1'>s</xsl:if>:</dt>
<xsl:for-each select='$options/x:editors/x:person'>
<dd>
<xsl:choose>
<xsl:when test='@homepage'>
<a href='{@homepage}'><xsl:value-of select='x:name'/></a>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select='x:name'/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test='x:affiliation'>
<xsl:text>, </xsl:text>
<xsl:choose>
<xsl:when test='x:affiliation/@homepage'>
<a href='{x:affiliation/@homepage}'><xsl:value-of select='x:affiliation'/></a>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select='x:affiliation'/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:if test='@email'>
<xsl:text> <</xsl:text>
<xsl:value-of select='@email'/>
<xsl:text>></xsl:text>
</xsl:if>
</dd>
</xsl:for-each>
</dl>
<xsl:variable name='year'>
<xsl:choose>
<xsl:when test='$options/x:maturity="ED"'>
<xsl:value-of select='substring($now, 1, 4)'/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select='substring($options/x:versions/x:this/@href, string-length($options/x:versions/x:this/@href) - 8, 4)'/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<p class="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a><xsl:text disable-output-escaping='yes'> &copy; </xsl:text><xsl:value-of select='concat($year, " ")'/><a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup><xsl:text disable-output-escaping='yes'>&reg;</xsl:text></sup> (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, <a href="http://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href="http://www.keio.ac.jp/">Keio</a>, <a href="http://ev.buaa.edu.cn/">Beihang</a>), All Rights Reserved. W3C <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.</p>
</div>
<hr/>
<xsl:if test='$options/x:maturity != "WG-NOTE"'>
<script async="" src="file-bug.js"/>
</xsl:if>
</xsl:template>
<xsl:template name='date'>
<xsl:variable name='date'>
<xsl:choose>
<xsl:when test='$options/x:maturity="ED"'>
<xsl:value-of select='$now'/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select='substring($options/x:versions/x:this/@href, string-length($options/x:versions/x:this/@href) - 8, 8)'/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select='number(substring($date, 7))'/>
<xsl:text> </xsl:text>
<xsl:call-template name='monthName'>
<xsl:with-param name='n' select='number(substring($date, 5, 2))'/>
</xsl:call-template>
<xsl:text> </xsl:text>
<xsl:value-of select='substring($date, 1, 4)'/>
</xsl:template>
<xsl:template name='maturity'>
<xsl:choose>
<xsl:when test='$options/x:maturity="FPWD"'>First Public Working Draft</xsl:when>
<xsl:when test='$options/x:maturity="LCWD"'>Last Call Working Draft</xsl:when>
<xsl:when test='$options/x:maturity="FPWDLC"'>First Public and Last Call Working Draft</xsl:when>
<xsl:when test='$options/x:maturity="WD"'>Working Draft</xsl:when>
<xsl:when test='$options/x:maturity="CR"'>Candidate Recommendation</xsl:when>
<xsl:when test='$options/x:maturity="PR"'>Proposed Recommendation</xsl:when>
<xsl:when test='$options/x:maturity="PER"'>Proposed Edited Recommendation</xsl:when>
<xsl:when test='$options/x:maturity="REC"'>Recommendation</xsl:when>
<xsl:when test='$options/x:maturity="WG-NOTE"'>Working Group Note</xsl:when>
<xsl:otherwise>Editor’s Draft</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name='maturity-short'>
<xsl:choose>
<xsl:when test='$options/x:maturity="FPWD"'>a Working Draft</xsl:when>
<xsl:when test='$options/x:maturity="LCWD"'>a Working Draft</xsl:when>
<xsl:when test='$options/x:maturity="FPWDLC"'>a Working Draft</xsl:when>
<xsl:when test='$options/x:maturity="WD"'>a Working Draft</xsl:when>
<xsl:when test='$options/x:maturity="CR"'>a Candidate Recommendation</xsl:when>
<xsl:when test='$options/x:maturity="PR"'>a Proposed Recommendation</xsl:when>
<xsl:when test='$options/x:maturity="PER"'>a Proposed Edited Recommendation</xsl:when>
<xsl:when test='$options/x:maturity="REC"'>a Recommendation</xsl:when>
<xsl:when test='$options/x:maturity="WG-NOTE"'>a Working Group Note</xsl:when>
<xsl:otherwise>an Editor’s Draft</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match='processing-instruction("sotd-top")'>
<xsl:variable name='mail' select='substring-before(., " ")'/>
<xsl:variable name='temp' select='substring-after(., " ")'/>
<xsl:variable name='archive'>
<xsl:choose>
<xsl:when test='contains($temp, " ")'><xsl:value-of select='substring-before($temp, " ")'/></xsl:when>
<xsl:otherwise><xsl:value-of select='$temp'/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name='prefix'><xsl:if test='contains($temp, " ")'><xsl:value-of select='substring-after($temp, " ")'/></xsl:if></xsl:variable>
<p>
<em>
This section describes the status of this document at the time of
its publication. Other documents may supersede this document. A list
of current W3C publications and the latest revision of this technical
report can be found in the <a href="http://www.w3.org/TR/">W3C technical
reports index</a> at http://www.w3.org/TR/.
</em>
</p>
<p>
<xsl:if test='$options/x:maturity!="REC" and $options/x:maturity!="WG-NOTE"'>
This document is the <xsl:call-template name='date'/><xsl:text> </xsl:text>
<b><xsl:call-template name='maturity'/></b> of the
<cite><xsl:value-of select='/*/h:head/h:title'/></cite> specification.
</xsl:if>
Please send comments about this document to
<a href='mailto:{$mail}'><xsl:value-of select='$mail'/></a>
(<a href='{$archive}'>archived</a>)<xsl:if test='$prefix != ""'>
with “<xsl:value-of select='$prefix'/>” at the start of the subject line</xsl:if>.
</p>
</xsl:template>
<xsl:template match='processing-instruction("sotd-bottom")'>
<xsl:variable name='ipp' select='.'/>
<p>
<xsl:choose>
<xsl:when test='$options/x:maturity="REC"'>
This document has been reviewed by W3C Members, by software developers,
and by other W3C groups and interested parties, and is endorsed by the
Director as a W3C Recommendation. It is a stable document and may be
used as reference material or cited from another document. W3C’s role
in making the Recommendation is to draw attention to the specification
and to promote its widespread deployment. This enhances the
functionality and interoperability of the Web.
</xsl:when>
<xsl:otherwise>
Publication as <xsl:call-template name='maturity-short'/> does not imply endorsement by the
W3C Membership. This is a draft document and may be updated, replaced
or obsoleted by other documents at any time. It is inappropriate to cite
this document as other than work in progress.
</xsl:otherwise>
</xsl:choose>
</p>
<p>
This document was produced by a group operating under the
<a href='http://www.w3.org/Consortium/Patent-Policy-20040205/'>5 February
2004 W3C Patent Policy</a>. W3C maintains a
<a href='{$ipp}'>public list of
any patent disclosures</a> made in connection with the deliverables of
the group; that page also includes instructions for disclosing a patent.
An individual who has actual knowledge of a patent which the individual
believes contains
<a href='http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential'>Essential
Claim(s)</a> must disclose the information in accordance with
<a href='http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure'>section
6 of the W3C Patent Policy</a>.
</p>
</xsl:template>
<xsl:template match='processing-instruction("productions")'>
<xsl:variable name='id' select='substring-before(., " ")'/>
<xsl:variable name='names' select='concat(" ", substring-after(., " "), " ")'/>
<table class='grammar'>
<xsl:call-template name='proddef'>
<xsl:with-param name='prods' select='//*[@id=$id]/x:prod[contains($names, concat(" ", @nt, " "))]'/>
<xsl:with-param name='pi' select='.'/>
</xsl:call-template>
</table>
</xsl:template>
<xsl:template match='processing-instruction("toc")'>
<xsl:variable name='sectionsID' select='substring-before(., " ")'/>
<xsl:variable name='appendicesID' select='substring-after(., " ")'/>
<div class='toc'>
<xsl:for-each select='//*[@id=$sectionsID]'>
<xsl:call-template name='toc1'/>
</xsl:for-each>
<xsl:for-each select='//*[@id=$appendicesID]'>
<xsl:call-template name='toc1'>
<xsl:with-param name='alpha' select='true()'/>
</xsl:call-template>
</xsl:for-each>
</div>
</xsl:template>
<xsl:template match='processing-instruction("sref")'>
<xsl:variable name='id' select='string(.)'/>
<xsl:variable name='s' select='//*[@id=$id]/self::h:div[@class="section"]'/>
<xsl:choose>
<xsl:when test='$s'>
<xsl:call-template name='section-number'>
<xsl:with-param name='section' select='$s'/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>@@</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match='processing-instruction("sdir")'>
<xsl:variable name='id' select='string(.)'/>
<xsl:choose>
<xsl:when test='preceding::h:div[@id=$id][@class="section"]'>above</xsl:when>
<xsl:when test='following::h:div[@id=$id][@class="section"]'>below</xsl:when>
<xsl:otherwise>@@</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match='processing-instruction("slink")'>
<xsl:variable name='id' select='string(.)'/>
<a href='#{$id}'>
<xsl:text>section </xsl:text>
<xsl:variable name='s' select='//*[@id=$id]/self::h:div[@class="section"]'/>
<xsl:choose>
<xsl:when test='$s'>
<xsl:call-template name='section-number'>
<xsl:with-param name='section' select='$s'/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>@@</xsl:otherwise>
</xsl:choose>
</a>
<xsl:text> </xsl:text>
<xsl:choose>
<xsl:when test='preceding::h:div[@id=$id][@class="section"]'>above</xsl:when>
<xsl:when test='following::h:div[@id=$id][@class="section"]'>below</xsl:when>
<xsl:otherwise>@@</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match='processing-instruction("slink-nodir")'>
<xsl:variable name='id' select='string(.)'/>
<a href='#{$id}'>
<xsl:text>section </xsl:text>
<xsl:variable name='s' select='//*[@id=$id]/self::h:div[@class="section"]'/>
<xsl:choose>
<xsl:when test='$s'>
<xsl:call-template name='section-number'>
<xsl:with-param name='section' select='$s'/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>@@</xsl:otherwise>
</xsl:choose>
</a>
</xsl:template>
<xsl:template match='processing-instruction("revision-note")'>
<xsl:if test='$options/x:maturity="ED"'>
<div class='ednote'>
<div class='ednoteHeader'>Editorial note</div>
<p>This version of the document is built from source revision <xsl:text disable-output-escaping='yes'>&#36;</xsl:text><xsl:value-of select='substring($id, 2)'/>.</p>
<xsl:variable name='n' select='count(//h:div[@class="ednote"])'/>
<xsl:if test='$n'>
<p>
There are <xsl:value-of select='$n'/> further editorial notes in the document.
<xsl:if test='string(.)'>
In addition, there is a list of <a href='{.}'>open bugs</a> on the document, some of which may be covered by editorial notes.
</xsl:if>
</p>
</xsl:if>
</div>
</xsl:if>
</xsl:template>
<xsl:template match='processing-instruction("stepref")'>
<xsl:variable name='step' select='string(.)'/>
<xsl:variable name='li' select='ancestor::*[@class="algorithm"]/*[@x:step=$step]'/>
<xsl:choose>
<xsl:when test='$li'>
<xsl:value-of select='count($li/preceding-sibling::*) + 1'/>
</xsl:when>
<xsl:otherwise>@@</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match='processing-instruction()|comment()'/>
<xsl:template name='toc1'>
<xsl:param name='prefix'/>
<xsl:param name='alpha'/>
<xsl:variable name='subsections' select='h:div[@class="section"]'/>
<xsl:if test='$subsections'>
<ul>
<xsl:for-each select='h:div[@class="section"]'>
<xsl:variable name='number'>
<xsl:value-of select='$prefix'/>
<xsl:if test='$prefix'>.</xsl:if>
<xsl:choose>
<xsl:when test='$alpha'><xsl:number value='position()' format='A'/></xsl:when>
<xsl:otherwise><xsl:value-of select='position()'/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name='frag'>
<xsl:choose>
<xsl:when test='@id'><xsl:value-of select='@id'/></xsl:when>
<xsl:otherwise><xsl:value-of select='generate-id(.)'/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<li>
<a href='#{$frag}'>
<xsl:value-of select='$number'/>
<xsl:text>. </xsl:text>
<xsl:for-each select='h:h2|h:h3|h:h4|h:h5|h:h6'>
<xsl:call-template name='toc-entry-name'/>
</xsl:for-each>
</a>
<xsl:call-template name='toc1'>
<xsl:with-param name='prefix' select='$number'/>
</xsl:call-template>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:template>
<xsl:template name='toc-entry-name'>
<xsl:for-each select='node()'>
<xsl:choose>
<xsl:when test='self::h:var'>
<var>
<xsl:value-of select='.'/>
</var>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select='.'/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<xsl:template name='section-number'>
<xsl:param name='section'/>
<xsl:variable name='sections' select='//*[@id=substring-before($tocpi, " ")]'/>
<xsl:variable name='appendices' select='//*[@id=substring-after($tocpi, " ")]'/>
<xsl:choose>
<xsl:when test='$section/ancestor::* = $sections'>
<xsl:for-each select='$section/ancestor-or-self::h:div[@class="section"]'>
<xsl:value-of select='count(preceding-sibling::h:div[@class="section"]) + 1'/>
<xsl:if test='position() != last()'>
<xsl:text>.</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:when>
<xsl:when test='$section/ancestor::* = $appendices'>
<xsl:for-each select='$section/ancestor-or-self::h:div[@class="section"]'>
<xsl:choose>
<xsl:when test='position()=1'>
<xsl:number value='count(preceding-sibling::h:div[@class="section"]) + 1' format='A'/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select='count(preceding-sibling::h:div[@class="section"]) + 1'/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test='position() != last()'>
<xsl:text>.</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match='h:div[@class="section"]/h:h2 | h:div[@class="section"]/h:h3 | h:div[@class="section"]/h:h4 | h:div[@class="section"]/h:h5 | h:div[@class="section"]/h:h6'>
<xsl:element name="{name()}" namespace="{namespace-uri()}">
<xsl:copy-of select='@*[namespace-uri()="" or namespace-uri="http://www.w3.org/XML/1998/namespace"]'/>
<xsl:if test='$tocpi'>
<xsl:variable name='num'>
<xsl:call-template name='section-number'>
<xsl:with-param name='section' select='..'/>
</xsl:call-template>
</xsl:variable>
<xsl:if test='$num != ""'>
<xsl:value-of select='$num'/>
<xsl:text>. </xsl:text>
</xsl:if>
</xsl:if>
<xsl:apply-templates select='node()'/>
</xsl:element>
</xsl:template>
<xsl:template match='h:div[@class="ednote"]'>
<div>
<xsl:copy-of select='@*[namespace-uri()="" or namespace-uri="http://www.w3.org/XML/1998/namespace"]'/>
<div class='ednoteHeader'>Editorial note</div>
<xsl:apply-templates select='node()'/>
</div>
</xsl:template>
<xsl:template match='h:div[@class="warning"]'>
<div>
<xsl:copy-of select='@*[namespace-uri()="" or namespace-uri="http://www.w3.org/XML/1998/namespace"]'/>
<div class='warningHeader'>Warning</div>
<xsl:apply-templates select='node()'/>
</div>
</xsl:template>
<xsl:template match='h:div[@class="example"]'>
<div>
<xsl:copy-of select='@*[namespace-uri()="" or namespace-uri="http://www.w3.org/XML/1998/namespace"]'/>
<div class='exampleHeader'>Example</div>
<xsl:apply-templates select='node()'/>
</div>
</xsl:template>
<xsl:template match='h:div[@class="note"]'>
<div>
<xsl:copy-of select='@*[namespace-uri()="" or namespace-uri="http://www.w3.org/XML/1998/namespace"]'/>
<div class='noteHeader'>Note</div>
<xsl:apply-templates select='node()'/>
</div>
</xsl:template>
<!--
<xsl:template match='h:tr'>
<xsl:copy>
<xsl:attribute name='class'>
<xsl:value-of select='@class'/>
<xsl:if test='@class'><xsl:text> </xsl:text></xsl:if>
<xsl:choose>
<xsl:when test='count(preceding-sibling::h:tr) mod 2 = 0'>odd</xsl:when>
<xsl:otherwise>even</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:copy-of select='node()[not(self::class)]'/>
</xsl:copy>
</xsl:template>
-->
<xsl:template match='x:codeblock'>
<div class='block'>
<div class='blockTitleDiv'>
<span class='blockTitle'>
<xsl:choose>
<xsl:when test='@language="idl"'>IDL</xsl:when>
<xsl:when test='@language="es"'>ECMAScript</xsl:when>
<xsl:when test='@language="java"'>Java</xsl:when>
<xsl:when test='@language="c"'>C</xsl:when>
<xsl:when test='@language="html"'>HTML</xsl:when>
<xsl:otherwise>@@</xsl:otherwise>
</xsl:choose>
</span>
</div>
<div class='blockContent'>
<pre class='code'><code class='{@language}-code'><xsl:apply-templates select='node()'/></code></pre>
</div>
</div>
</xsl:template>
<xsl:template match='x:grammar'>
<table class='grammar'>
<xsl:apply-templates select='x:prod'/>
</table>
</xsl:template>
<xsl:template name='proddef'>
<xsl:param name='prods'/>
<xsl:param name='pi'/>
<xsl:for-each select='$prods'>
<xsl:variable name='nt' select='@nt'/>
<tr>
<xsl:if test='not($pi/preceding::processing-instruction("productions")[contains(concat(" ", substring-after(., " "), " "), concat(" ", $nt, " "))])'>
<xsl:attribute name='id'>proddef-<xsl:value-of select='@nt'/></xsl:attribute>
</xsl:if>
<td><span class='prod-number'>[<xsl:value-of select='count(preceding-sibling::x:prod) + 1'/>]</span></td>
<td>
<a class='sym' href='#prod-{@nt}'><xsl:value-of select='@nt'/></a>
<xsl:if test='@whitespace="explicit"'>
<sub class='nt-attr'>explicit</sub>
</xsl:if>
</td>
<td class='prod-mid'>→</td>
<td class='prod-rhs'>
<span class='prod-lines'>
<xsl:call-template name='bnf'>
<xsl:with-param name='s' select='string(.)'/>
</xsl:call-template>
</span>
</td>
</tr>
</xsl:for-each>
</xsl:template>
<xsl:template match='x:prod'>
<tr id='prod-{@nt}'>
<td><span class='prod-number'>[<xsl:value-of select='count(preceding-sibling::x:prod) + 1'/>]</span></td>
<td>
<xsl:choose>
<xsl:when test='../@links="off"'>
<xsl:value-of select='@nt'/>
</xsl:when>
<xsl:otherwise>
<a class='sym' href='#proddef-{@nt}'><xsl:value-of select='@nt'/></a>
</xsl:otherwise>
</xsl:choose>
<xsl:if test='@whitespace="explicit"'>
<sub class='nt-attr'>explicit</sub>
</xsl:if>
</td>
<td class='prod-mid'>→</td>
<td class='prod-rhs'>
<span class='prod-lines'>
<xsl:call-template name='bnf'>
<xsl:with-param name='s' select='string(.)'/>
<xsl:with-param name='links' select='../@links'/>
</xsl:call-template>
</span>
</td>
</tr>
</xsl:template>
<xsl:template name='bnf'>
<xsl:param name='s'/>
<xsl:param name='mode' select='0'/>
<xsl:param name='links'/>
<xsl:if test='$s != ""'>
<xsl:variable name='c' select='substring($s, 1, 1)'/>
<xsl:choose>
<xsl:when test='$mode = 0 and contains("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", $c)'>
<xsl:variable name='nt'>
<xsl:value-of select='$c'/>
<xsl:call-template name='bnf-nt'>
<xsl:with-param name='s' select='substring($s, 2)'/>
</xsl:call-template>
</xsl:variable>
<!--
<xsl:choose>
<xsl:when test='$links="off"'>
<xsl:value-of select='$nt'/>
</xsl:when>
<xsl:otherwise>
-->
<a class='sym' href='#prod-{$nt}'><xsl:value-of select='$nt'/></a>
<!--
</xsl:otherwise>
</xsl:choose>
-->
<xsl:call-template name='bnf'>
<xsl:with-param name='s' select='substring($s, string-length($nt) + 1)'/>
<xsl:with-param name='links' select='$links'/>
</xsl:call-template>
</xsl:when>
<xsl:when test='$mode = 0 and $c = "|"'>
<!--div class='prod-line-subsequent'--><br/> |
<xsl:call-template name='bnf'>
<xsl:with-param name='s' select='substring($s, 2)'/>
<xsl:with-param name='links' select='$links'/>
</xsl:call-template>
<!--/div-->
</xsl:when>
<xsl:when test='$c = '"''>
<xsl:value-of select='$c'/>
<xsl:variable name='newMode'>
<xsl:choose>
<xsl:when test='$mode = 1'>0</xsl:when>
<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:call-template name='bnf'>
<xsl:with-param name='s' select='substring($s, 2)'/>
<xsl:with-param name='mode' select='$newMode'/>
<xsl:with-param name='links' select='$links'/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$c = "'"">
<xsl:value-of select='$c'/>
<xsl:variable name='newMode'>
<xsl:choose>
<xsl:when test='$mode = 2'>0</xsl:when>
<xsl:otherwise>2</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:call-template name='bnf'>
<xsl:with-param name='s' select='substring($s, 2)'/>
<xsl:with-param name='mode' select='$newMode'/>
<xsl:with-param name='links' select='$links'/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$c = '[' and $mode = 0">
<xsl:value-of select='$c'/>
<xsl:choose>
<xsl:when test='substring($s, 2, 1) = "]"'>
<xsl:text>]</xsl:text>
<xsl:call-template name='bnf'>
<xsl:with-param name='s' select='substring($s, 3)'/>
<xsl:with-param name='links' select='$links'/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:variable name='newMode'>
<xsl:choose>
<xsl:when test='$mode = 3'>0</xsl:when>
<xsl:otherwise>3</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:call-template name='bnf'>
<xsl:with-param name='s' select='substring($s, 2)'/>
<xsl:with-param name='mode' select='$newMode'/>
<xsl:with-param name='links' select='$links'/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$c = ']' and $mode = 3">
<xsl:value-of select='$c'/>
<xsl:call-template name='bnf'>
<xsl:with-param name='s' select='substring($s, 2)'/>
<xsl:with-param name='links' select='$links'/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select='$c'/>
<xsl:call-template name='bnf'>
<xsl:with-param name='s' select='substring($s, 2)'/>
<xsl:with-param name='mode' select='$mode'/>
<xsl:with-param name='links' select='$links'/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
<xsl:template name='bnf-nt'>
<xsl:param name='s'/>
<xsl:if test='$s != ""'>
<xsl:variable name='c' select='substring($s, 1, 1)'/>
<xsl:if test='contains("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz", $c)'>
<xsl:value-of select='$c'/>
<xsl:call-template name='bnf-nt'>
<xsl:with-param name='s' select='substring($s, 2)'/>
</xsl:call-template>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template match='*'/>
<xsl:template match='comment()'>
<xsl:copy/>
</xsl:template>
</xsl:stylesheet>