forked from jcgregorio/uri-templates
-
Notifications
You must be signed in to change notification settings - Fork 2
/
rfc2629.xslt
7061 lines (6392 loc) · 264 KB
/
rfc2629.xslt
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
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!--
XSLT transformation from RFC2629 XML format to HTML
Copyright (c) 2006-2011, Julian Reschke ([email protected])
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Julian Reschke nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-->
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:date="http://exslt.org/dates-and-times"
xmlns:ed="http://greenbytes.de/2002/rfcedit"
xmlns:exslt="http://exslt.org/common"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:myns="mailto:[email protected]?subject=rcf2629.xslt"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:saxon="http://saxon.sf.net/"
xmlns:saxon-old="http://icl.com/saxon"
xmlns:x="http://purl.org/net/xml2rfc/ext"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="date ed exslt msxsl myns rdf saxon saxon-old x xhtml"
>
<xsl:strip-space elements="back front list middle rfc section"/>
<xsl:output method="html" encoding="iso-8859-1" version="4.0" doctype-public="-//W3C//DTD HTML 4.01//EN" indent="no"/>
<!-- rfc comments PI -->
<xsl:param name="xml2rfc-comments">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc')"/>
<xsl:with-param name="attr" select="'comments'"/>
<xsl:with-param name="default" select="'no'"/>
</xsl:call-template>
</xsl:param>
<!-- rfc compact PI -->
<xsl:param name="xml2rfc-compact">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc')"/>
<xsl:with-param name="attr" select="'compact'"/>
<xsl:with-param name="default" select="$xml2rfc-rfcedstyle"/>
</xsl:call-template>
</xsl:param>
<!-- rfc footer PI -->
<xsl:param name="xml2rfc-footer">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc')"/>
<xsl:with-param name="attr" select="'footer'"/>
</xsl:call-template>
</xsl:param>
<!-- rfc header PI -->
<xsl:param name="xml2rfc-header">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc')"/>
<xsl:with-param name="attr" select="'header'"/>
</xsl:call-template>
</xsl:param>
<!-- rfc inline PI -->
<xsl:param name="xml2rfc-inline">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc')"/>
<xsl:with-param name="attr" select="'inline'"/>
<xsl:with-param name="default" select="'no'"/>
</xsl:call-template>
</xsl:param>
<!-- include a table of contents if a processing instruction <?rfc?>
exists with contents toc="yes". Can be overriden by an XSLT parameter -->
<xsl:param name="xml2rfc-toc">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc')"/>
<xsl:with-param name="attr" select="'toc'"/>
<xsl:with-param name="default" select="'no'"/>
</xsl:call-template>
</xsl:param>
<!-- optional tocdepth-->
<xsl:param name="xml2rfc-tocdepth">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc')"/>
<xsl:with-param name="attr" select="'tocdepth'"/>
<xsl:with-param name="default" select="'3'"/>
</xsl:call-template>
</xsl:param>
<xsl:variable name="parsedTocDepth">
<xsl:choose>
<xsl:when test="$xml2rfc-tocdepth='1'">1</xsl:when>
<xsl:when test="$xml2rfc-tocdepth='2'">2</xsl:when>
<xsl:when test="$xml2rfc-tocdepth='3'">3</xsl:when>
<xsl:when test="$xml2rfc-tocdepth='4'">4</xsl:when>
<xsl:when test="$xml2rfc-tocdepth='5'">5</xsl:when>
<xsl:otherwise>99</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- suppress top block if a processing instruction <?rfc?>
exists with contents tocblock="no". Can be overriden by an XSLT parameter -->
<xsl:param name="xml2rfc-topblock">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc')"/>
<xsl:with-param name="attr" select="'topblock'"/>
<xsl:with-param name="default" select="'yes'"/>
</xsl:call-template>
</xsl:param>
<!-- Format to the RFC Editor's taste -->
<xsl:param name="xml2rfc-rfcedstyle">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc')"/>
<xsl:with-param name="attr" select="'rfcedstyle'"/>
<xsl:with-param name="default" select="'no'"/>
</xsl:call-template>
</xsl:param>
<!-- the name of an automatically inserted references section -->
<xsl:param name="xml2rfc-refparent">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc')"/>
<xsl:with-param name="attr" select="'refparent'"/>
<xsl:with-param name="default" select="'References'"/>
</xsl:call-template>
</xsl:param>
<!-- use symbolic reference names instead of numeric ones unless a processing instruction <?rfc?>
exists with contents symrefs="no". Can be overriden by an XSLT parameter -->
<xsl:param name="xml2rfc-symrefs">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc')"/>
<xsl:with-param name="attr" select="'symrefs'"/>
<xsl:with-param name="default" select="'yes'"/>
</xsl:call-template>
</xsl:param>
<!-- sort references if a processing instruction <?rfc?>
exists with contents sortrefs="yes". Can be overriden by an XSLT parameter -->
<xsl:param name="xml2rfc-sortrefs">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc')"/>
<xsl:with-param name="attr" select="'sortrefs'"/>
<xsl:with-param name="default" select="'no'"/>
</xsl:call-template>
</xsl:param>
<!-- insert editing marks if a processing instruction <?rfc?>
exists with contents editing="yes". Can be overriden by an XSLT parameter -->
<xsl:param name="xml2rfc-editing">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc')"/>
<xsl:with-param name="attr" select="'editing'"/>
<xsl:with-param name="default" select="'no'"/>
</xsl:call-template>
</xsl:param>
<!-- make it a private paper -->
<xsl:param name="xml2rfc-private">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc')"/>
<xsl:with-param name="attr" select="'private'"/>
</xsl:call-template>
</xsl:param>
<!-- background image? -->
<xsl:param name="xml2rfc-background">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc')"/>
<xsl:with-param name="attr" select="'background'"/>
</xsl:call-template>
</xsl:param>
<!-- extension for XML parsing in artwork -->
<xsl:param name="xml2rfc-ext-parse-xml-in-artwork">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc-ext')"/>
<xsl:with-param name="attr" select="'parse-xml-in-artwork'"/>
<xsl:with-param name="default" select="'no'"/>
</xsl:call-template>
</xsl:param>
<xsl:param name="xml2rfc-ext-trace-parse-xml">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc-ext')"/>
<xsl:with-param name="attr" select="'trace-parse-xml'"/>
<xsl:with-param name="default" select="'no'"/>
</xsl:call-template>
</xsl:param>
<!-- extension for excluding the index -->
<xsl:param name="xml2rfc-ext-include-index">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc-ext')"/>
<xsl:with-param name="attr" select="'include-index'"/>
<xsl:with-param name="default" select="'yes'"/>
</xsl:call-template>
</xsl:param>
<!-- extension for excluding DCMI properties in meta tag (RFC2731) -->
<xsl:param name="xml2rfc-ext-support-rfc2731">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc-ext')"/>
<xsl:with-param name="attr" select="'support-rfc2731'"/>
<xsl:with-param name="default" select="'yes'"/>
</xsl:call-template>
</xsl:param>
<!-- extension for specifying the value for <vspace> after which it's taken as a page break -->
<xsl:param name="xml2rfc-ext-vspace-pagebreak">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc-ext')"/>
<xsl:with-param name="attr" select="'vspace-pagebreak'"/>
<xsl:with-param name="default" select="'100'"/>
</xsl:call-template>
</xsl:param>
<!-- extension for allowing markup inside artwork -->
<xsl:param name="xml2rfc-ext-allow-markup-in-artwork">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc-ext')"/>
<xsl:with-param name="attr" select="'allow-markup-in-artwork'"/>
<xsl:with-param name="default" select="'no'"/>
</xsl:call-template>
</xsl:param>
<!-- extension for including references into index -->
<xsl:param name="xml2rfc-ext-include-references-in-index">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc-ext')"/>
<xsl:with-param name="attr" select="'include-references-in-index'"/>
<xsl:with-param name="default" select="'no'"/>
</xsl:call-template>
</xsl:param>
<!-- position of author's section -->
<xsl:param name="xml2rfc-ext-authors-section">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc-ext')"/>
<xsl:with-param name="attr" select="'authors-section'"/>
</xsl:call-template>
</xsl:param>
<!-- justification? -->
<xsl:param name="xml2rfc-ext-justification">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc-ext')"/>
<xsl:with-param name="attr" select="'justification'"/>
<xsl:with-param name="default" select="'no'"/>
</xsl:call-template>
</xsl:param>
<!-- switch for doublesided layout -->
<xsl:param name="xml2rfc-ext-duplex">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc-ext')"/>
<xsl:with-param name="attr" select="'duplex'"/>
<xsl:with-param name="default" select="'no'"/>
</xsl:call-template>
</xsl:param>
<!-- trailing dots in section numbers -->
<xsl:param name="xml2rfc-ext-sec-no-trailing-dots">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc-ext')"/>
<xsl:with-param name="attr" select="'sec-no-trailing-dots'"/>
</xsl:call-template>
</xsl:param>
<!-- choose whether or not to do mailto links -->
<xsl:param name="xml2rfc-linkmailto">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc-ext')"/>
<xsl:with-param name="attr" select="'linkmailto'"/>
<xsl:with-param name="default" select="'yes'"/>
</xsl:call-template>
</xsl:param>
<!-- iprnotified switch -->
<xsl:param name="xml2rfc-iprnotified">
<xsl:call-template name="parse-pis">
<xsl:with-param name="nodes" select="/processing-instruction('rfc')"/>
<xsl:with-param name="attr" select="'iprnotified'"/>
<xsl:with-param name="default" select="'no'"/>
</xsl:call-template>
</xsl:param>
<!-- URL templates for RFCs and Internet Drafts. -->
<!-- Reference the authorative ASCII versions
<xsl:param name="rfcUrlPrefix" select="'http://www.ietf.org/rfc/rfc'" />
<xsl:param name="rfcUrlPostfix" select="'.txt'" />
-->
<!-- Reference the marked up versions over on http://tools.ietf.org/html. -->
<xsl:param name="rfcUrlPrefix" select="'http://tools.ietf.org/html/rfc'" />
<xsl:param name="rfcUrlPostfix" select="''" />
<xsl:param name="rfcUrlFragSection" select="'section-'" />
<xsl:param name="rfcUrlFragAppendix" select="'appendix-'" />
<xsl:param name="internetDraftUrlPrefix" select="'http://tools.ietf.org/html/'" />
<xsl:param name="internetDraftUrlPostfix" select="''" />
<xsl:param name="internetDraftUrlFrag" select="'section-'" />
<!-- warning re: absent node-set ext. function -->
<xsl:variable name="node-set-warning">
This stylesheet requires either an XSLT-1.0 processor with node-set()
extension function, or an XSLT-2.0 processor. Therefore, parts of the
document couldn't be displayed.
</xsl:variable>
<!-- character translation tables -->
<xsl:variable name="lcase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="ucase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
<xsl:variable name="digits" select="'0123456789'" />
<!-- build help keys for indices -->
<xsl:key name="index-first-letter"
match="iref|reference"
use="translate(substring(concat(@anchor,@item),1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
<xsl:key name="index-item"
match="iref"
use="@item" />
<xsl:key name="index-item-subitem"
match="iref"
use="concat(@item,'..',@subitem)" />
<xsl:key name="index-xref-by-sec"
match="xref[@x:sec]"
use="concat(@target,'..',@x:sec)" />
<xsl:key name="index-xref-by-anchor"
match="xref[@x:rel]"
use="concat(@target,'..',@x:rel)" />
<xsl:key name="anchor-item"
match="//*[@anchor]"
use="@anchor"/>
<xsl:key name="xref-item"
match="//xref"
use="@target"/>
<xsl:key name="extref-item"
match="//x:ref"
use="."/>
<!-- prefix for automatically generated anchors -->
<xsl:variable name="anchor-prefix" select="'rfc'" />
<!-- IPR version switch -->
<xsl:variable name="ipr-rfc3667" select="(
/rfc/@number > 3708) or
not(
(/rfc/@ipr = 'full2026') or
(/rfc/@ipr = 'noDerivativeWorks2026') or
(/rfc/@ipr = 'noDerivativeWorksNow') or
(/rfc/@ipr = 'none') or
(/rfc/@ipr = '') or
not(/rfc/@ipr)
)" />
<xsl:variable name="rfcno" select="/rfc/@number"/>
<xsl:variable name="submissionType">
<xsl:choose>
<xsl:when test="/rfc/@submissionType='IETF' or not(/rfc/@submissionType) or /rfc/submissionType=''">IETF</xsl:when>
<xsl:when test="/rfc/@submissionType='IAB' or /rfc/@submissionType='IRTF' or /rfc/@submissionType='independent'">
<xsl:value-of select="/rfc/@submissionType"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('(UNSUPPORTED SUBMISSION TYPE: ',/rfc/@submissionType,')')"/>
<xsl:call-template name="error">
<xsl:with-param name="msg" select="concat('Unsupported value for /rfc/@submissionType: ', /rfc/@submissionType)"/>
<xsl:with-param name="inline" select="'no'"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<!-- sanity check on @consensus -->
<xsl:if test="/rfc/@consensus and (/rfc/@submissionType='IAB' or /rfc/@submissionType='independent')">
<xsl:call-template name="warning">
<xsl:with-param name="msg" select="concat('/rfc/@consensus meaningless with a /rfc/@submissionType value of ', /rfc/@submissionType)"/>
</xsl:call-template>
</xsl:if>
</xsl:variable>
<xsl:variable name="consensus">
<xsl:choose>
<xsl:when test="/rfc/@consensus='yes' or not(/rfc/@consensus)">yes</xsl:when>
<xsl:when test="/rfc/@consensus='no'">no</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('(UNSUPPORTED VALUE FOR CONSENSUS: ',/rfc/@consensus,')')"/>
<xsl:call-template name="error">
<xsl:with-param name="msg" select="concat('Unsupported value for /rfc/@consensus: ', /rfc/@consensus)"/>
<xsl:with-param name="inline" select="'no'"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Header format as defined in RFC 5741, and deployed end of Dec 2009 -->
<xsl:variable name="header-format">
<xsl:choose>
<xsl:when test="$pub-yearmonth >= 201001 or
($rfcno=5741 or $rfcno=5742 or $rfcno=5743)"
>2010</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</xsl:variable>
<xsl:variable name="rfc-boilerplate">
<xsl:choose>
<!-- RFC boilerplate as defined in RFC 5741, and deployed end of Dec 2009 -->
<xsl:when test="$pub-yearmonth >= 201001 or
($rfcno=5741 or $rfcno=5742 or $rfcno=5743)"
>2010</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</xsl:variable>
<xsl:variable name="id-boilerplate">
<xsl:choose>
<!-- ID boilerplate approved by IESG on Jan 14 2010-->
<xsl:when test="$pub-yearmonth >= 201004"
>2010</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</xsl:variable>
<xsl:variable name="ipr-rfc4748" select="(
$ipr-rfc3667 and
( $rfcno >= 4715 and ( $rfcno != 4718 and $rfcno != 4735 and $rfcno != 4749 ))
or
( $rfcno=4578 or $rfcno=4582 or $rfcno=4583 or $rfcno=4628 or $rfcno=4629 or $rfcno=4639 or $rfcno=4651 or $rfcno=4682 or $rfcno=4684 or $rfcno=4695 or $rfcno=4696 )
or
( not(/rfc/@number) and $pub-yearmonth >= 200611)
)" />
<xsl:variable name="ipr-2007-08" select="(
$ipr-rfc4748 and
(
($rfcno > 5000
and $rfcno != 5020
and $rfcno != 5021
and $rfcno != 5034
and $rfcno != 5052
and $rfcno != 5065
and $rfcno != 5094) or
($xml2rfc-ext-pub-year >= 2008) or
(not(/rfc/@number) and $pub-yearmonth >= 200709)
)
)" />
<xsl:variable name="ipr-2008-11" select="(
/rfc/@number and $pub-yearmonth >= 200811
)
or
(
/rfc/@ipr = 'trust200811' or
/rfc/@ipr = 'noModificationTrust200811' or
/rfc/@ipr = 'noDerivativesTrust200902' or
/rfc/@ipr = 'trust200902' or
/rfc/@ipr = 'noModificationTrust200902' or
/rfc/@ipr = 'noDerivativesTrust200902' or
/rfc/@ipr = 'pre5378Trust200902'
)" />
<xsl:variable name="ipr-2009-02" select="(
$ipr-2008-11 and $pub-yearmonth >= 200902
)" />
<!-- this makes the Sep 2009 TLP text depend on the publication date to be >= 2009-11
for IDs, and around 2009-09 for RFCs-->
<xsl:variable name="ipr-2009-09" select="(
( not(/rfc/@number) and $pub-yearmonth >= 200911 )
or
(
/rfc/@number and $pub-yearmonth >= 200909 and
$rfcno!=5582 and $rfcno!=5621 and $rfcno!=5632 and $rfcno!=5645 and $rfcno!=5646 and $rfcno!=5681
)
)" />
<!-- this makes the Jan 2010 TLP text depend on the publication date to be >= 2010-04
for IDs, and around 2010-01 for RFCs-->
<xsl:variable name="ipr-2010-01" select="(
( not(/rfc/@number) and $pub-yearmonth >= 201004 )
or
(
/rfc/@number and ($pub-yearmonth >= 201001 or
$rfcno=5741 or $rfcno=5742 or $rfcno=5743)
)
)" />
<!-- see http://mailman.rfc-editor.org/pipermail/rfc-interest/2009-June/001373.html -->
<!-- for IDs, implement the change as 2009-11 -->
<xsl:variable name="abstract-first" select="(
(/rfc/@number and $pub-yearmonth >= 200907)
or
(not(/rfc/@number) and $pub-yearmonth >= 200911)
)" />
<!-- funding switch -->
<xsl:variable name="funding0" select="(
$rfcno > 2499) or
(not(/rfc/@number) and /rfc/@docName and $xml2rfc-ext-pub-year >= 1999
)" />
<xsl:variable name="funding1" select="(
$rfcno > 4320) or
(not(/rfc/@number) and /rfc/@docName and $xml2rfc-ext-pub-year >= 2006
)" />
<xsl:variable name="no-funding" select="$ipr-2007-08"/>
<xsl:variable name="no-copylong" select="$ipr-2008-11"/>
<!-- will document have an index -->
<xsl:variable name="has-index" select="(//iref or (//xref and $xml2rfc-ext-include-references-in-index='yes')) and $xml2rfc-ext-include-index!='no'" />
<!-- does the document contain edits? -->
<xsl:variable name="has-edits" select="//ed:ins | //ed:del | //ed:replace" />
<xsl:template match="text()[not(ancestor::artwork)]">
<xsl:variable name="ws" select="'	  '"/>
<xsl:variable name="starts-with-ws" select="translate(substring(.,1,1),$ws,'')"/>
<xsl:variable name="ends-with-ws" select="translate(substring(.,string-length(.),1),$ws,'')"/>
<!--<xsl:message> Orig: "<xsl:value-of select="."/>"</xsl:message>
<xsl:message>Start: "<xsl:value-of select="$starts-with-ws"/>"</xsl:message>
<xsl:message> End: "<xsl:value-of select="$ends-with-ws"/>"</xsl:message> -->
<xsl:if test="$starts-with-ws='' and preceding-sibling::node()">
<xsl:text> </xsl:text>
</xsl:if>
<xsl:value-of select="normalize-space(.)"/>
<xsl:if test="$ends-with-ws='' and following-sibling::node()">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="abstract">
<h1 id="{$anchor-prefix}.abstract"><a href="#{$anchor-prefix}.abstract">Abstract</a></h1>
<xsl:apply-templates />
</xsl:template>
<msxsl:script language="JScript" implements-prefix="myns">
function parseXml(str) {
try {
var doc = new ActiveXObject("MSXML2.DOMDocument");
doc.async = false;
if (doc.loadXML(str)) {
return "";
}
else {
return doc.parseError.reason + "\n" + doc.parseError.srcText + " (" + doc.parseError.line + "/" + doc.parseError.linepos + ")";
}
}
catch(e) {
return "";
}
}
</msxsl:script>
<xsl:template name="add-artwork-class">
<xsl:choose>
<xsl:when test="@type='abnf' or @type='abnf2045' or @type='abnf2616' or @type='application/xml-dtd' or @type='inline' or @type='application/relax-ng-compact-syntax'">
<xsl:attribute name="class">inline</xsl:attribute>
</xsl:when>
<xsl:when test="starts-with(@type,'message/http') and contains(@type,'msgtype="request"')">
<xsl:attribute name="class">text2</xsl:attribute>
</xsl:when>
<xsl:when test="starts-with(@type,'message/http')">
<xsl:attribute name="class">text</xsl:attribute>
</xsl:when>
<xsl:when test="starts-with(@type,'drawing')">
<xsl:attribute name="class">drawing</xsl:attribute>
</xsl:when>
<xsl:when test="starts-with(@type,'text/plain') or @type='example' or @type='code'">
<xsl:attribute name="class">text</xsl:attribute>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</xsl:template>
<xsl:template name="insert-begin-code">
<xsl:if test="@x:isCodeComponent='yes'">
<pre class="ccmarker cct"><span><CODE BEGINS></span></pre>
</xsl:if>
</xsl:template>
<xsl:template name="insert-end-code">
<xsl:if test="@x:isCodeComponent='yes'">
<pre class="ccmarker ccb"><span><CODE ENDS></span></pre>
</xsl:if>
</xsl:template>
<xsl:template match="artwork">
<xsl:if test="not(ancestor::ed:del) and $xml2rfc-ext-parse-xml-in-artwork='yes' and function-available('myns:parseXml')">
<xsl:if test="contains(.,'<?xml')">
<xsl:variable name="body" select="substring-after(substring-after(.,'<?xml'),'?>')" />
<xsl:if test="$body!='' and myns:parseXml($body)!=''">
<table style="background-color: red; border-width: thin; border-style: solid; border-color: black;">
<tr><td>
XML PARSE ERROR; parsed the body below:
<pre>
<xsl:value-of select="$body"/>
</pre>
resulting in:
<pre>
<xsl:value-of select="myns:parseXml($body)" />
</pre>
</td></tr></table>
</xsl:if>
</xsl:if>
<xsl:if test="@ed:parse-xml-after">
<xsl:if test="myns:parseXml(string(.))!=''">
<table style="background-color: red; border-width: thin; border-style: solid; border-color: black;">
<tr><td>
XML PARSE ERROR:
<pre><xsl:value-of select="myns:parseXml(string(.))" /></pre>
</td></tr></table>
</xsl:if>
</xsl:if>
</xsl:if>
<xsl:variable name="display">
<xsl:choose>
<xsl:when test="$xml2rfc-ext-allow-markup-in-artwork='yes'">
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="@align='right'">
<div style="display:table; margin-left: auto; margin-right: 0pt;">
<xsl:call-template name="insert-begin-code"/>
<pre style="margin-left: 0em;">
<xsl:call-template name="add-artwork-class"/>
<xsl:call-template name="insertInsDelClass"/>
<xsl:copy-of select="$display"/>
</pre>
<xsl:call-template name="insert-end-code"/>
</div>
</xsl:when>
<xsl:when test="@align='center'">
<div style="display:table; margin-left: auto; margin-right: auto;">
<xsl:call-template name="insert-begin-code"/>
<pre style="margin-left: 0em;">
<xsl:call-template name="add-artwork-class"/>
<xsl:call-template name="insertInsDelClass"/>
<xsl:copy-of select="$display"/>
</pre>
<xsl:call-template name="insert-end-code"/>
</div>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="insert-begin-code"/>
<pre>
<xsl:call-template name="add-artwork-class"/>
<xsl:call-template name="insertInsDelClass"/>
<xsl:copy-of select="$display"/>
</pre>
<xsl:call-template name="insert-end-code"/>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="check-artwork-width">
<xsl:with-param name="content"><xsl:apply-templates/></xsl:with-param>
<xsl:with-param name="indent"><xsl:value-of select="string-length(@x:indent-with)"/></xsl:with-param>
</xsl:call-template>
</xsl:template>
<!-- special case for first text node in artwork -->
<xsl:template match="artwork/text()[1]">
<xsl:choose>
<xsl:when test="starts-with(.,' ')">
<!-- reduce leading whitespace -->
<xsl:value-of select="substring(.,2)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="check-artwork-width">
<xsl:param name="content"/>
<xsl:param name="indent"/>
<xsl:choose>
<xsl:when test="not(contains($content,' '))">
<xsl:if test="string-length($content) > 69 + $indent">
<xsl:call-template name="warning">
<xsl:with-param name="msg">artwork line too long: '<xsl:value-of select="$content"/>' (<xsl:value-of select="string-length($content)"/> characters)</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="start" select="substring-before($content,' ')"/>
<xsl:variable name="end" select="substring-after($content,' ')"/>
<xsl:variable name="max">
<xsl:choose>
<xsl:when test="$indent!=''"><xsl:value-of select="69 + $indent"/></xsl:when>
<xsl:otherwise>69</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="string-length($start) > $max">
<xsl:call-template name="warning">
<xsl:with-param name="msg">artwork line too long: '<xsl:value-of select="$start"/>' (<xsl:value-of select="string-length($start)"/> characters)</xsl:with-param>
</xsl:call-template>
</xsl:if>
<xsl:call-template name="check-artwork-width">
<xsl:with-param name="content" select="$end"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="artwork[@src and starts-with(@type,'image/')]">
<p>
<xsl:choose>
<xsl:when test="@align='center'">
<xsl:attribute name="style">text-align: center</xsl:attribute>
</xsl:when>
<xsl:when test="@align='right'">
<xsl:attribute name="style">text-align: right</xsl:attribute>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
<xsl:choose>
<xsl:when test="@type='image/svg+xml'">
<object data="{@src}" type="image/svg+xml">
<xsl:choose>
<xsl:when test="@width!='' or @height!=''">
<xsl:copy-of select="@width|@height"/>
</xsl:when>
<xsl:otherwise xmlns:svg="http://www.w3.org/2000/svg">
<!-- try to find width and height from SVG -->
<xsl:variable name="svg" select="document(@src)"/>
<xsl:for-each select="$svg/svg:svg/@width|$svg/svg:svg/@height">
<!-- strip out the units, cross the fingers pixels are meant -->
<xsl:attribute name="{local-name()}">
<xsl:value-of select="translate(.,concat($ucase,$lcase),'')"/>
</xsl:attribute>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates/>
</object>
</xsl:when>
<xsl:otherwise>
<img src="{@src}" alt="{.}">
<xsl:if test="@width and @width!=''">
<xsl:copy-of select="@width"/>
</xsl:if>
<xsl:if test="@height and @height!=''">
<xsl:copy-of select="@height"/>
</xsl:if>
</img>
</xsl:otherwise>
</xsl:choose>
</p>
</xsl:template>
<xsl:template match="author">
<address class="vcard">
<span class="vcardline">
<span class="fn">
<xsl:value-of select="@fullname" />
</span>
<xsl:if test="@role">
(<xsl:value-of select="@role" />)
</xsl:if>
<!-- annotation support for Martin "uuml" Duerst -->
<xsl:if test="@x:annotation">
<xsl:text> </xsl:text>
<i><xsl:value-of select="@x:annotation"/></i>
</xsl:if>
<!-- components of name (hidden from display -->
<span class="n hidden">
<span class="family-name"><xsl:value-of select="@surname"/></span>
<!-- given-name family-name -->
<xsl:if test="@surname=substring(@fullname,1 + string-length(@fullname) - string-length(@surname))">
<span class="given-name"><xsl:value-of select="normalize-space(substring(@fullname,1,string-length(@fullname) - string-length(@surname)))"/></span>
</xsl:if>
<!-- family-name given-name -->
<xsl:if test="starts-with(@fullname,@surname)">
<span class="given-name"><xsl:value-of select="normalize-space(substring-after(@fullname,@surname))"/></span>
</xsl:if>
</span>
</span>
<xsl:if test="normalize-space(organization) != ''">
<span class="org vcardline">
<xsl:value-of select="organization" />
</span>
</xsl:if>
<xsl:if test="address/postal">
<span class="adr">
<xsl:if test="address/postal/street!=''">
<xsl:for-each select="address/postal/street">
<span class="street-address vcardline">
<xsl:call-template name="extract-normalized">
<xsl:with-param name="node" select="."/>
<xsl:with-param name="name" select="'street'"/>
</xsl:call-template>
</span>
</xsl:for-each>
</xsl:if>
<xsl:if test="address/postal/city|address/postal/region|address/postal/code">
<span class="vcardline">
<xsl:if test="address/postal/city">
<span class="locality">
<xsl:call-template name="extract-normalized">
<xsl:with-param name="node" select="address/postal/city"/>
<xsl:with-param name="name" select="'address/postal/city'"/>
</xsl:call-template>
</span>
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:if test="address/postal/region">
<span class="region">
<xsl:call-template name="extract-normalized">
<xsl:with-param name="node" select="address/postal/region"/>
<xsl:with-param name="name" select="'address/postal/region'"/>
</xsl:call-template>
</span>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:if test="address/postal/code">
<span class="postal-code">
<xsl:call-template name="extract-normalized">
<xsl:with-param name="node" select="address/postal/code"/>
<xsl:with-param name="name" select="'address/postal/code'"/>
</xsl:call-template>
</span>
</xsl:if>
</span>
</xsl:if>
<xsl:if test="address/postal/country">
<span class="country-name vcardline">
<xsl:call-template name="extract-normalized">
<xsl:with-param name="node" select="address/postal/country"/>
<xsl:with-param name="name" select="'address/postal/country'"/>
</xsl:call-template>
</span>
</xsl:if>
</span>
</xsl:if>
<xsl:if test="address/phone">
<span class="vcardline tel">
<xsl:text>Phone: </xsl:text>
<a href="tel:{translate(address/phone,' ','')}"><span class="value"><xsl:value-of select="address/phone" /></span></a>
</span>
</xsl:if>
<xsl:if test="address/facsimile">
<span class="vcardline tel">
<span class="type">Fax</span><xsl:text>: </xsl:text>
<a href="fax:{translate(address/facsimile,' ','')}"><span class="value"><xsl:value-of select="address/facsimile" /></span></a>
</span>
</xsl:if>
<xsl:for-each select="address/email">
<xsl:variable name="email">
<xsl:call-template name="extract-email"/>
</xsl:variable>
<span class="vcardline">
<xsl:choose>
<xsl:when test="$xml2rfc-rfcedstyle='yes'">Email: </xsl:when>
<xsl:otherwise>EMail: </xsl:otherwise>
</xsl:choose>
<a>
<xsl:if test="$xml2rfc-linkmailto!='no'">
<xsl:attribute name="href">mailto:<xsl:value-of select="$email" /></xsl:attribute>
</xsl:if>
<span class="email"><xsl:value-of select="$email" /></span>
</a>
</span>
</xsl:for-each>
<xsl:for-each select="address/uri">
<xsl:variable name="uri">
<xsl:call-template name="extract-uri"/>
</xsl:variable>
<span class="vcardline">
<xsl:text>URI: </xsl:text>
<a href="{$uri}" class="url"><xsl:value-of select="$uri" /></a>
<xsl:if test="@x:annotation">
<xsl:text> </xsl:text>
<i><xsl:value-of select="@x:annotation"/></i>
</xsl:if>
</span>
</xsl:for-each>
</address>
</xsl:template>
<!-- this is a named template because <back> may be absent -->
<xsl:template name="back">
<!-- add editorial comments -->
<xsl:if test="//cref and $xml2rfc-comments='yes' and $xml2rfc-inline!='yes'">
<xsl:call-template name="insertComments" />
</xsl:if>
<!-- next, add information about the document's authors -->
<xsl:if test="$xml2rfc-ext-authors-section!='end'">
<xsl:call-template name="insertAuthors" />
</xsl:if>
<!-- add all other top-level sections under <back> -->
<xsl:apply-templates select="back/*[not(self::references) and not(self::ed:replace and .//references)]" />
<!-- insert the index if index entries exist -->
<!-- note it always comes before the authors section -->
<xsl:if test="$has-index">
<xsl:call-template name="insertIndex" />
</xsl:if>
<!-- Authors section is the absolute last thing, except for copyright stuff -->
<xsl:if test="$xml2rfc-ext-authors-section='end'">
<xsl:call-template name="insertAuthors" />
</xsl:if>
<xsl:if test="$xml2rfc-private=''">
<!-- copyright statements -->
<xsl:variable name="copyright"><xsl:call-template name="insertCopyright" /></xsl:variable>
<!-- emit it -->
<xsl:choose>
<xsl:when test="function-available('exslt:node-set')">
<xsl:apply-templates select="exslt:node-set($copyright)" />
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="error">
<xsl:with-param name="msg" select="$node-set-warning"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
<xsl:template match="eref[node()]">
<a href="{@target}"><xsl:apply-templates /></a>
</xsl:template>